blob: 608cbf0b0e2ec0551d601bb2a3376bcbdeee60b0 [file] [log] [blame]
Denis Vlasenkoc4f623e2006-12-26 01:30:59 +00001/* vi: set sw=4 ts=4: */
2/*
3 * linux/include/linux/ext2_fs.h
4 *
5 * Copyright (C) 1992, 1993, 1994, 1995
6 * Remy Card (card@masi.ibp.fr)
7 * Laboratoire MASI - Institut Blaise Pascal
8 * Universite Pierre et Marie Curie (Paris VI)
9 *
10 * Copyright (C) 1991, 1992 Linus Torvalds
11 */
12
Denis Vlasenkof81e8db2009-04-09 12:35:13 +000013#ifndef LINUX_EXT2_FS_H
14#define LINUX_EXT2_FS_H 1
Denis Vlasenkoc4f623e2006-12-26 01:30:59 +000015
16/*
17 * Special inode numbers
18 */
19#define EXT2_BAD_INO 1 /* Bad blocks inode */
20#define EXT2_ROOT_INO 2 /* Root inode */
21#define EXT2_ACL_IDX_INO 3 /* ACL inode */
22#define EXT2_ACL_DATA_INO 4 /* ACL inode */
23#define EXT2_BOOT_LOADER_INO 5 /* Boot loader inode */
24#define EXT2_UNDEL_DIR_INO 6 /* Undelete directory inode */
25#define EXT2_RESIZE_INO 7 /* Reserved group descriptors inode */
26#define EXT2_JOURNAL_INO 8 /* Journal inode */
27
28/* First non-reserved inode for old ext2 filesystems */
29#define EXT2_GOOD_OLD_FIRST_INO 11
30
31/*
32 * The second extended file system magic number
33 */
34#define EXT2_SUPER_MAGIC 0xEF53
35
36/* Assume that user mode programs are passing in an ext2fs superblock, not
37 * a kernel struct super_block. This will allow us to call the feature-test
38 * macros from user land. */
39#define EXT2_SB(sb) (sb)
40
41/*
42 * Maximal count of links to a file
43 */
44#define EXT2_LINK_MAX 32000
45
46/*
47 * Macro-instructions used to manage several block sizes
48 */
49#define EXT2_MIN_BLOCK_LOG_SIZE 10 /* 1024 */
50#define EXT2_MAX_BLOCK_LOG_SIZE 16 /* 65536 */
51#define EXT2_MIN_BLOCK_SIZE (1 << EXT2_MIN_BLOCK_LOG_SIZE)
52#define EXT2_MAX_BLOCK_SIZE (1 << EXT2_MAX_BLOCK_LOG_SIZE)
53#define EXT2_BLOCK_SIZE(s) (EXT2_MIN_BLOCK_SIZE << (s)->s_log_block_size)
54#define EXT2_BLOCK_SIZE_BITS(s) ((s)->s_log_block_size + 10)
55#define EXT2_INODE_SIZE(s) (((s)->s_rev_level == EXT2_GOOD_OLD_REV) ? \
56 EXT2_GOOD_OLD_INODE_SIZE : (s)->s_inode_size)
57#define EXT2_FIRST_INO(s) (((s)->s_rev_level == EXT2_GOOD_OLD_REV) ? \
58 EXT2_GOOD_OLD_FIRST_INO : (s)->s_first_ino)
59#define EXT2_ADDR_PER_BLOCK(s) (EXT2_BLOCK_SIZE(s) / sizeof(uint32_t))
60
61/*
62 * Macro-instructions used to manage fragments
63 */
64#define EXT2_MIN_FRAG_SIZE EXT2_MIN_BLOCK_SIZE
65#define EXT2_MAX_FRAG_SIZE EXT2_MAX_BLOCK_SIZE
66#define EXT2_MIN_FRAG_LOG_SIZE EXT2_MIN_BLOCK_LOG_SIZE
67#define EXT2_FRAG_SIZE(s) (EXT2_MIN_FRAG_SIZE << (s)->s_log_frag_size)
68#define EXT2_FRAGS_PER_BLOCK(s) (EXT2_BLOCK_SIZE(s) / EXT2_FRAG_SIZE(s))
69
70/*
71 * ACL structures
72 */
73struct ext2_acl_header { /* Header of Access Control Lists */
74 uint32_t aclh_size;
75 uint32_t aclh_file_count;
76 uint32_t aclh_acle_count;
77 uint32_t aclh_first_acle;
78};
79
80struct ext2_acl_entry { /* Access Control List Entry */
81 uint32_t acle_size;
82 uint16_t acle_perms; /* Access permissions */
83 uint16_t acle_type; /* Type of entry */
84 uint16_t acle_tag; /* User or group identity */
85 uint16_t acle_pad1;
86 uint32_t acle_next; /* Pointer on next entry for the */
87 /* same inode or on next free entry */
88};
89
90/*
91 * Structure of a blocks group descriptor
92 */
93struct ext2_group_desc {
94 uint32_t bg_block_bitmap; /* Blocks bitmap block */
95 uint32_t bg_inode_bitmap; /* Inodes bitmap block */
96 uint32_t bg_inode_table; /* Inodes table block */
97 uint16_t bg_free_blocks_count; /* Free blocks count */
98 uint16_t bg_free_inodes_count; /* Free inodes count */
99 uint16_t bg_used_dirs_count; /* Directories count */
100 uint16_t bg_pad;
101 uint32_t bg_reserved[3];
102};
103
104/*
105 * Data structures used by the directory indexing feature
106 *
107 * Note: all of the multibyte integer fields are little endian.
108 */
109
110/*
111 * Note: dx_root_info is laid out so that if it should somehow get
112 * overlaid by a dirent the two low bits of the hash version will be
113 * zero. Therefore, the hash version mod 4 should never be 0.
114 * Sincerely, the paranoia department.
115 */
116struct ext2_dx_root_info {
117 uint32_t reserved_zero;
118 uint8_t hash_version; /* 0 now, 1 at release */
119 uint8_t info_length; /* 8 */
120 uint8_t indirect_levels;
121 uint8_t unused_flags;
122};
123
124#define EXT2_HASH_LEGACY 0
125#define EXT2_HASH_HALF_MD4 1
126#define EXT2_HASH_TEA 2
127
128#define EXT2_HASH_FLAG_INCOMPAT 0x1
129
130struct ext2_dx_entry {
131 uint32_t hash;
132 uint32_t block;
133};
134
135struct ext2_dx_countlimit {
136 uint16_t limit;
137 uint16_t count;
138};
139
140
141/*
142 * Macro-instructions used to manage group descriptors
143 */
144#define EXT2_BLOCKS_PER_GROUP(s) (EXT2_SB(s)->s_blocks_per_group)
145#define EXT2_INODES_PER_GROUP(s) (EXT2_SB(s)->s_inodes_per_group)
146#define EXT2_INODES_PER_BLOCK(s) (EXT2_BLOCK_SIZE(s)/EXT2_INODE_SIZE(s))
147/* limits imposed by 16-bit value gd_free_{blocks,inode}_count */
148#define EXT2_MAX_BLOCKS_PER_GROUP(s) ((1 << 16) - 8)
149#define EXT2_MAX_INODES_PER_GROUP(s) ((1 << 16) - EXT2_INODES_PER_BLOCK(s))
150#define EXT2_DESC_PER_BLOCK(s) (EXT2_BLOCK_SIZE(s) / sizeof (struct ext2_group_desc))
151
152/*
153 * Constants relative to the data blocks
154 */
155#define EXT2_NDIR_BLOCKS 12
156#define EXT2_IND_BLOCK EXT2_NDIR_BLOCKS
157#define EXT2_DIND_BLOCK (EXT2_IND_BLOCK + 1)
158#define EXT2_TIND_BLOCK (EXT2_DIND_BLOCK + 1)
159#define EXT2_N_BLOCKS (EXT2_TIND_BLOCK + 1)
160
161/*
162 * Inode flags
163 */
164#define EXT2_SECRM_FL 0x00000001 /* Secure deletion */
165#define EXT2_UNRM_FL 0x00000002 /* Undelete */
166#define EXT2_COMPR_FL 0x00000004 /* Compress file */
167#define EXT2_SYNC_FL 0x00000008 /* Synchronous updates */
168#define EXT2_IMMUTABLE_FL 0x00000010 /* Immutable file */
169#define EXT2_APPEND_FL 0x00000020 /* writes to file may only append */
170#define EXT2_NODUMP_FL 0x00000040 /* do not dump file */
171#define EXT2_NOATIME_FL 0x00000080 /* do not update atime */
172/* Reserved for compression usage... */
173#define EXT2_DIRTY_FL 0x00000100
174#define EXT2_COMPRBLK_FL 0x00000200 /* One or more compressed clusters */
175#define EXT2_NOCOMPR_FL 0x00000400 /* Access raw compressed data */
176#define EXT2_ECOMPR_FL 0x00000800 /* Compression error */
177/* End compression flags --- maybe not all used */
178#define EXT2_BTREE_FL 0x00001000 /* btree format dir */
179#define EXT2_INDEX_FL 0x00001000 /* hash-indexed directory */
180#define EXT2_IMAGIC_FL 0x00002000
181#define EXT3_JOURNAL_DATA_FL 0x00004000 /* file data should be journaled */
182#define EXT2_NOTAIL_FL 0x00008000 /* file tail should not be merged */
183#define EXT2_DIRSYNC_FL 0x00010000 /* Synchronous directory modifications */
184#define EXT2_TOPDIR_FL 0x00020000 /* Top of directory hierarchies*/
Denys Vlasenko83dff7f2021-06-20 12:34:05 +0200185#define EXT2_EXTENT_FL 0x00080000 /* Extents */
186#define EXT2_VERITY_FL 0x00100000
187#define EXT2_NOCOW_FL 0x00800000 /* Do not cow file */
188#define EXT2_INLINE_DATA_FL 0x10000000
189#define EXT2_PROJINHERIT_FL 0x20000000
190#define EXT2_CASEFOLD_FL 0x40000000
Denis Vlasenkoc4f623e2006-12-26 01:30:59 +0000191
192/*
193 * ioctl commands
194 */
195#define EXT2_IOC_GETFLAGS _IOR('f', 1, long)
196#define EXT2_IOC_SETFLAGS _IOW('f', 2, long)
197#define EXT2_IOC_GETVERSION _IOR('v', 1, long)
198#define EXT2_IOC_SETVERSION _IOW('v', 2, long)
Denys Vlasenko526b8342021-06-20 10:57:24 +0200199//NB: despite "long" in defs above, these ioctls use an _int_!
200//passing them a pointer to long will read/write only int-sized data!
201struct ext2_fsxattr {
202 uint32_t fsx_xflags; /* xflags field value (get/set) */
203 uint32_t fsx_extsize; /* extsize field value (get/set)*/
204 uint32_t fsx_nextents; /* nextents field value (get) */
205 uint32_t fsx_projid; /* project identifier (get/set) */
206 uint32_t fsx_cowextsize; /* CoW extsize field value (get/set)*/
207 unsigned char fsx_pad[8];
208};
209#define EXT2_IOC_FSGETXATTR _IOR('X', 31, struct ext2_fsxattr)
210#define EXT2_IOC_FSSETXATTR _IOW('X', 32, struct ext2_fsxattr)
Denis Vlasenkoc4f623e2006-12-26 01:30:59 +0000211
212/*
213 * Structure of an inode on the disk
214 */
215struct ext2_inode {
216 uint16_t i_mode; /* File mode */
217 uint16_t i_uid; /* Low 16 bits of Owner Uid */
218 uint32_t i_size; /* Size in bytes */
219 uint32_t i_atime; /* Access time */
220 uint32_t i_ctime; /* Creation time */
221 uint32_t i_mtime; /* Modification time */
222 uint32_t i_dtime; /* Deletion Time */
223 uint16_t i_gid; /* Low 16 bits of Group Id */
224 uint16_t i_links_count; /* Links count */
225 uint32_t i_blocks; /* Blocks count */
226 uint32_t i_flags; /* File flags */
227 union {
228 struct {
229 uint32_t l_i_reserved1;
230 } linux1;
231 struct {
232 uint32_t h_i_translator;
233 } hurd1;
234 struct {
235 uint32_t m_i_reserved1;
236 } masix1;
237 } osd1; /* OS dependent 1 */
238 uint32_t i_block[EXT2_N_BLOCKS];/* Pointers to blocks */
239 uint32_t i_generation; /* File version (for NFS) */
240 uint32_t i_file_acl; /* File ACL */
241 uint32_t i_dir_acl; /* Directory ACL */
242 uint32_t i_faddr; /* Fragment address */
243 union {
244 struct {
245 uint8_t l_i_frag; /* Fragment number */
246 uint8_t l_i_fsize; /* Fragment size */
247 uint16_t i_pad1;
248 uint16_t l_i_uid_high; /* these 2 fields */
249 uint16_t l_i_gid_high; /* were reserved2[0] */
250 uint32_t l_i_reserved2;
251 } linux2;
252 struct {
253 uint8_t h_i_frag; /* Fragment number */
254 uint8_t h_i_fsize; /* Fragment size */
255 uint16_t h_i_mode_high;
256 uint16_t h_i_uid_high;
257 uint16_t h_i_gid_high;
258 uint32_t h_i_author;
259 } hurd2;
260 struct {
261 uint8_t m_i_frag; /* Fragment number */
262 uint8_t m_i_fsize; /* Fragment size */
263 uint16_t m_pad1;
264 uint32_t m_i_reserved2[2];
265 } masix2;
266 } osd2; /* OS dependent 2 */
267};
268
269/*
270 * Permanent part of an large inode on the disk
271 */
272struct ext2_inode_large {
273 uint16_t i_mode; /* File mode */
274 uint16_t i_uid; /* Low 16 bits of Owner Uid */
275 uint32_t i_size; /* Size in bytes */
276 uint32_t i_atime; /* Access time */
277 uint32_t i_ctime; /* Creation time */
278 uint32_t i_mtime; /* Modification time */
279 uint32_t i_dtime; /* Deletion Time */
280 uint16_t i_gid; /* Low 16 bits of Group Id */
281 uint16_t i_links_count; /* Links count */
282 uint32_t i_blocks; /* Blocks count */
283 uint32_t i_flags; /* File flags */
284 union {
285 struct {
286 uint32_t l_i_reserved1;
287 } linux1;
288 struct {
289 uint32_t h_i_translator;
290 } hurd1;
291 struct {
292 uint32_t m_i_reserved1;
293 } masix1;
294 } osd1; /* OS dependent 1 */
295 uint32_t i_block[EXT2_N_BLOCKS];/* Pointers to blocks */
296 uint32_t i_generation; /* File version (for NFS) */
297 uint32_t i_file_acl; /* File ACL */
298 uint32_t i_dir_acl; /* Directory ACL */
299 uint32_t i_faddr; /* Fragment address */
300 union {
301 struct {
302 uint8_t l_i_frag; /* Fragment number */
303 uint8_t l_i_fsize; /* Fragment size */
304 uint16_t i_pad1;
305 uint16_t l_i_uid_high; /* these 2 fields */
306 uint16_t l_i_gid_high; /* were reserved2[0] */
307 uint32_t l_i_reserved2;
308 } linux2;
309 struct {
310 uint8_t h_i_frag; /* Fragment number */
311 uint8_t h_i_fsize; /* Fragment size */
312 uint16_t h_i_mode_high;
313 uint16_t h_i_uid_high;
314 uint16_t h_i_gid_high;
315 uint32_t h_i_author;
316 } hurd2;
317 struct {
318 uint8_t m_i_frag; /* Fragment number */
319 uint8_t m_i_fsize; /* Fragment size */
320 uint16_t m_pad1;
321 uint32_t m_i_reserved2[2];
322 } masix2;
323 } osd2; /* OS dependent 2 */
324 uint16_t i_extra_isize;
325 uint16_t i_pad1;
326};
327
328#define i_size_high i_dir_acl
329
330/*
331 * File system states
332 */
333#define EXT2_VALID_FS 0x0001 /* Unmounted cleanly */
334#define EXT2_ERROR_FS 0x0002 /* Errors detected */
335
336/*
337 * Mount flags
338 */
339#define EXT2_MOUNT_CHECK 0x0001 /* Do mount-time checks */
340#define EXT2_MOUNT_GRPID 0x0004 /* Create files with directory's group */
341#define EXT2_MOUNT_DEBUG 0x0008 /* Some debugging messages */
342#define EXT2_MOUNT_ERRORS_CONT 0x0010 /* Continue on errors */
343#define EXT2_MOUNT_ERRORS_RO 0x0020 /* Remount fs ro on errors */
344#define EXT2_MOUNT_ERRORS_PANIC 0x0040 /* Panic on errors */
345#define EXT2_MOUNT_MINIX_DF 0x0080 /* Mimics the Minix statfs */
346#define EXT2_MOUNT_NO_UID32 0x0200 /* Disable 32-bit UIDs */
347
348#define clear_opt(o, opt) o &= ~EXT2_MOUNT_##opt
349#define set_opt(o, opt) o |= EXT2_MOUNT_##opt
350#define test_opt(sb, opt) (EXT2_SB(sb)->s_mount_opt & \
351 EXT2_MOUNT_##opt)
352/*
353 * Maximal mount counts between two filesystem checks
354 */
355#define EXT2_DFL_MAX_MNT_COUNT 20 /* Allow 20 mounts */
356#define EXT2_DFL_CHECKINTERVAL 0 /* Don't use interval check */
357
358/*
359 * Behaviour when detecting errors
360 */
361#define EXT2_ERRORS_CONTINUE 1 /* Continue execution */
362#define EXT2_ERRORS_RO 2 /* Remount fs read-only */
363#define EXT2_ERRORS_PANIC 3 /* Panic */
364#define EXT2_ERRORS_DEFAULT EXT2_ERRORS_CONTINUE
365
366/*
367 * Structure of the super block
368 */
369struct ext2_super_block {
370 uint32_t s_inodes_count; /* Inodes count */
371 uint32_t s_blocks_count; /* Blocks count */
372 uint32_t s_r_blocks_count; /* Reserved blocks count */
373 uint32_t s_free_blocks_count; /* Free blocks count */
374 uint32_t s_free_inodes_count; /* Free inodes count */
375 uint32_t s_first_data_block; /* First Data Block */
376 uint32_t s_log_block_size; /* Block size */
377 int32_t s_log_frag_size; /* Fragment size */
378 uint32_t s_blocks_per_group; /* # Blocks per group */
379 uint32_t s_frags_per_group; /* # Fragments per group */
380 uint32_t s_inodes_per_group; /* # Inodes per group */
381 uint32_t s_mtime; /* Mount time */
382 uint32_t s_wtime; /* Write time */
383 uint16_t s_mnt_count; /* Mount count */
384 int16_t s_max_mnt_count; /* Maximal mount count */
385 uint16_t s_magic; /* Magic signature */
386 uint16_t s_state; /* File system state */
387 uint16_t s_errors; /* Behaviour when detecting errors */
388 uint16_t s_minor_rev_level; /* minor revision level */
389 uint32_t s_lastcheck; /* time of last check */
390 uint32_t s_checkinterval; /* max. time between checks */
391 uint32_t s_creator_os; /* OS */
392 uint32_t s_rev_level; /* Revision level */
393 uint16_t s_def_resuid; /* Default uid for reserved blocks */
394 uint16_t s_def_resgid; /* Default gid for reserved blocks */
395 /*
396 * These fields are for EXT2_DYNAMIC_REV superblocks only.
397 *
398 * Note: the difference between the compatible feature set and
399 * the incompatible feature set is that if there is a bit set
400 * in the incompatible feature set that the kernel doesn't
401 * know about, it should refuse to mount the filesystem.
402 *
403 * e2fsck's requirements are more strict; if it doesn't know
404 * about a feature in either the compatible or incompatible
405 * feature set, it must abort and not try to meddle with
406 * things it doesn't understand...
407 */
408 uint32_t s_first_ino; /* First non-reserved inode */
409 uint16_t s_inode_size; /* size of inode structure */
410 uint16_t s_block_group_nr; /* block group # of this superblock */
411 uint32_t s_feature_compat; /* compatible feature set */
412 uint32_t s_feature_incompat; /* incompatible feature set */
413 uint32_t s_feature_ro_compat; /* readonly-compatible feature set */
414 uint8_t s_uuid[16]; /* 128-bit uuid for volume */
415 char s_volume_name[16]; /* volume name */
416 char s_last_mounted[64]; /* directory where last mounted */
417 uint32_t s_algorithm_usage_bitmap; /* For compression */
418 /*
419 * Performance hints. Directory preallocation should only
420 * happen if the EXT2_FEATURE_COMPAT_DIR_PREALLOC flag is on.
421 */
Denys Vlasenkoc9a13112012-06-21 16:50:46 +0200422 uint8_t s_prealloc_blocks; /* Nr of blocks to try to preallocate*/
423 uint8_t s_prealloc_dir_blocks; /* Nr to preallocate for dirs */
Denis Vlasenkoc4f623e2006-12-26 01:30:59 +0000424 uint16_t s_reserved_gdt_blocks; /* Per group table for online growth */
425 /*
426 * Journaling support valid if EXT2_FEATURE_COMPAT_HAS_JOURNAL set.
427 */
Denys Vlasenkoc9a13112012-06-21 16:50:46 +0200428/*D0*/ uint8_t s_journal_uuid[16]; /* uuid of journal superblock */
429/*E0*/ uint32_t s_journal_inum; /* inode number of journal file */
Denis Vlasenkoc4f623e2006-12-26 01:30:59 +0000430 uint32_t s_journal_dev; /* device number of journal file */
431 uint32_t s_last_orphan; /* start of list of inodes to delete */
432 uint32_t s_hash_seed[4]; /* HTREE hash seed */
433 uint8_t s_def_hash_version; /* Default hash version to use */
434 uint8_t s_jnl_backup_type; /* Default type of journal backup */
435 uint16_t s_reserved_word_pad;
Denys Vlasenkoc9a13112012-06-21 16:50:46 +0200436/*100*/ uint32_t s_default_mount_opts;
Denis Vlasenkoc4f623e2006-12-26 01:30:59 +0000437 uint32_t s_first_meta_bg; /* First metablock group */
Denys Vlasenkoc9a13112012-06-21 16:50:46 +0200438 /* ext3 additions */
Denis Vlasenkoc4f623e2006-12-26 01:30:59 +0000439 uint32_t s_mkfs_time; /* When the filesystem was created */
440 uint32_t s_jnl_blocks[17]; /* Backup of the journal inode */
Denys Vlasenkoc9a13112012-06-21 16:50:46 +0200441 /* 64bit support valid if EXT4_FEATURE_COMPAT_64BIT */
442/*150*/ uint32_t s_blocks_count_hi; /* Blocks count */
443 uint32_t s_r_blocks_count_hi; /* Reserved blocks count */
444 uint32_t s_free_blocks_count_hi; /* Free blocks count */
445 uint16_t s_min_extra_isize; /* All inodes have at least # bytes */
446 uint16_t s_want_extra_isize; /* New inodes should reserve # bytes */
447 uint32_t s_flags; /* Miscellaneous flags */
448 uint16_t s_raid_stride; /* RAID stride */
449 uint16_t s_mmp_interval; /* # seconds to wait in MMP checking */
450 uint64_t s_mmp_block; /* Block for multi-mount protection */
451 uint32_t s_raid_stripe_width; /* blocks on all data disks (N*stride)*/
452 uint8_t s_log_groups_per_flex; /* FLEX_BG group size */
453 uint8_t s_reserved_char_pad2;
454 uint16_t s_reserved_pad;
455 uint32_t s_reserved[162]; /* Padding to the end of the block */
456};
457struct BUG_ext2_super_block {
Denys Vlasenko982e87f2013-07-30 11:52:58 +0200458 char bug[sizeof(struct ext2_super_block) == 1024 ? 1 : -1];
Denis Vlasenkoc4f623e2006-12-26 01:30:59 +0000459};
460
461/*
462 * Codes for operating systems
463 */
464#define EXT2_OS_LINUX 0
465#define EXT2_OS_HURD 1
466#define EXT2_OS_MASIX 2
467#define EXT2_OS_FREEBSD 3
468#define EXT2_OS_LITES 4
469
470/*
471 * Revision levels
472 */
473#define EXT2_GOOD_OLD_REV 0 /* The good old (original) format */
474#define EXT2_DYNAMIC_REV 1 /* V2 format w/ dynamic inode sizes */
475
476#define EXT2_CURRENT_REV EXT2_GOOD_OLD_REV
477#define EXT2_MAX_SUPP_REV EXT2_DYNAMIC_REV
478
479#define EXT2_GOOD_OLD_INODE_SIZE 128
480
481/*
482 * Journal inode backup types
483 */
484#define EXT3_JNL_BACKUP_BLOCKS 1
485
486/*
487 * Feature set definitions
488 */
489
490#define EXT2_HAS_COMPAT_FEATURE(sb,mask) \
491 ( EXT2_SB(sb)->s_feature_compat & (mask) )
492#define EXT2_HAS_RO_COMPAT_FEATURE(sb,mask) \
493 ( EXT2_SB(sb)->s_feature_ro_compat & (mask) )
494#define EXT2_HAS_INCOMPAT_FEATURE(sb,mask) \
495 ( EXT2_SB(sb)->s_feature_incompat & (mask) )
496
Denys Vlasenkoac164dd2012-06-12 15:00:35 +0200497/* for s_feature_compat */
Denis Vlasenkoc4f623e2006-12-26 01:30:59 +0000498#define EXT2_FEATURE_COMPAT_DIR_PREALLOC 0x0001
499#define EXT2_FEATURE_COMPAT_IMAGIC_INODES 0x0002
500#define EXT3_FEATURE_COMPAT_HAS_JOURNAL 0x0004
501#define EXT2_FEATURE_COMPAT_EXT_ATTR 0x0008
Denys Vlasenko176bc342012-04-17 15:06:55 +0200502#define EXT2_FEATURE_COMPAT_RESIZE_INO 0x0010
Denis Vlasenkoc4f623e2006-12-26 01:30:59 +0000503#define EXT2_FEATURE_COMPAT_DIR_INDEX 0x0020
504
Denys Vlasenkoac164dd2012-06-12 15:00:35 +0200505/* for s_feature_ro_compat */
Denis Vlasenkoc4f623e2006-12-26 01:30:59 +0000506#define EXT2_FEATURE_RO_COMPAT_SPARSE_SUPER 0x0001
507#define EXT2_FEATURE_RO_COMPAT_LARGE_FILE 0x0002
Denys Vlasenkoac164dd2012-06-12 15:00:35 +0200508#define EXT2_FEATURE_RO_COMPAT_BTREE_DIR 0x0004 /* not used */
509#define EXT4_FEATURE_RO_COMPAT_HUGE_FILE 0x0008
510#define EXT4_FEATURE_RO_COMPAT_GDT_CSUM 0x0010
511#define EXT4_FEATURE_RO_COMPAT_DIR_NLINK 0x0020
512#define EXT4_FEATURE_RO_COMPAT_EXTRA_ISIZE 0x0040
Denis Vlasenkoc4f623e2006-12-26 01:30:59 +0000513
Denys Vlasenkoac164dd2012-06-12 15:00:35 +0200514/* for s_feature_incompat */
Denis Vlasenkoc4f623e2006-12-26 01:30:59 +0000515#define EXT2_FEATURE_INCOMPAT_COMPRESSION 0x0001
516#define EXT2_FEATURE_INCOMPAT_FILETYPE 0x0002
Denys Vlasenkoac164dd2012-06-12 15:00:35 +0200517#define EXT3_FEATURE_INCOMPAT_RECOVER 0x0004
518#define EXT3_FEATURE_INCOMPAT_JOURNAL_DEV 0x0008
Denis Vlasenkoc4f623e2006-12-26 01:30:59 +0000519#define EXT2_FEATURE_INCOMPAT_META_BG 0x0010
Denys Vlasenkoac164dd2012-06-12 15:00:35 +0200520#define EXT4_FEATURE_INCOMPAT_EXTENTS 0x0040
521#define EXT4_FEATURE_INCOMPAT_64BIT 0x0080
522#define EXT4_FEATURE_INCOMPAT_MMP 0x0100
523#define EXT4_FEATURE_INCOMPAT_FLEX_BG 0x0200
Denis Vlasenkoc4f623e2006-12-26 01:30:59 +0000524
525
526#define EXT2_FEATURE_COMPAT_SUPP 0
Denis Vlasenkoc4f623e2006-12-26 01:30:59 +0000527#define EXT2_FEATURE_RO_COMPAT_SUPP (EXT2_FEATURE_RO_COMPAT_SPARSE_SUPER| \
528 EXT2_FEATURE_RO_COMPAT_LARGE_FILE| \
529 EXT2_FEATURE_RO_COMPAT_BTREE_DIR)
Denys Vlasenkoac164dd2012-06-12 15:00:35 +0200530#define EXT2_FEATURE_INCOMPAT_SUPP (EXT2_FEATURE_INCOMPAT_FILETYPE| \
531 EXT2_FEATURE_INCOMPAT_META_BG)
532#define EXT2_FEATURE_INCOMPAT_UNSUPPORTED (~EXT2_FEATURE_INCOMPAT_SUPP)
533#define EXT2_FEATURE_RO_COMPAT_UNSUPPORTED (~EXT2_FEATURE_RO_COMPAT_SUPP)
534
535#define EXT3_FEATURE_RO_COMPAT_SUPP (EXT2_FEATURE_RO_COMPAT_SPARSE_SUPER| \
536 EXT2_FEATURE_RO_COMPAT_LARGE_FILE| \
537 EXT2_FEATURE_RO_COMPAT_BTREE_DIR)
538#define EXT3_FEATURE_INCOMPAT_SUPP (EXT2_FEATURE_INCOMPAT_FILETYPE| \
539 EXT3_FEATURE_INCOMPAT_RECOVER| \
540 EXT2_FEATURE_INCOMPAT_META_BG)
541#define EXT3_FEATURE_INCOMPAT_UNSUPPORTED (~EXT3_FEATURE_INCOMPAT_SUPP)
542#define EXT3_FEATURE_RO_COMPAT_UNSUPPORTED (~EXT3_FEATURE_RO_COMPAT_SUPP)
543
Denis Vlasenkoc4f623e2006-12-26 01:30:59 +0000544
545/*
546 * Default values for user and/or group using reserved blocks
547 */
548#define EXT2_DEF_RESUID 0
549#define EXT2_DEF_RESGID 0
550
551/*
552 * Default mount options
553 */
554#define EXT2_DEFM_DEBUG 0x0001
555#define EXT2_DEFM_BSDGROUPS 0x0002
556#define EXT2_DEFM_XATTR_USER 0x0004
557#define EXT2_DEFM_ACL 0x0008
558#define EXT2_DEFM_UID16 0x0010
559#define EXT3_DEFM_JMODE 0x0060
560#define EXT3_DEFM_JMODE_DATA 0x0020
561#define EXT3_DEFM_JMODE_ORDERED 0x0040
562#define EXT3_DEFM_JMODE_WBACK 0x0060
563
564/*
565 * Structure of a directory entry
566 */
567#define EXT2_NAME_LEN 255
568
569struct ext2_dir_entry {
570 uint32_t inode; /* Inode number */
571 uint16_t rec_len; /* Directory entry length */
572 uint16_t name_len; /* Name length */
573 char name[EXT2_NAME_LEN]; /* File name */
574};
575
576/*
577 * The new version of the directory entry. Since EXT2 structures are
578 * stored in intel byte order, and the name_len field could never be
579 * bigger than 255 chars, it's safe to reclaim the extra byte for the
580 * file_type field.
581 */
582struct ext2_dir_entry_2 {
583 uint32_t inode; /* Inode number */
584 uint16_t rec_len; /* Directory entry length */
585 uint8_t name_len; /* Name length */
586 uint8_t file_type;
587 char name[EXT2_NAME_LEN]; /* File name */
588};
589
590/*
591 * Ext2 directory file types. Only the low 3 bits are used. The
592 * other bits are reserved for now.
593 */
594#define EXT2_FT_UNKNOWN 0
595#define EXT2_FT_REG_FILE 1
596#define EXT2_FT_DIR 2
597#define EXT2_FT_CHRDEV 3
598#define EXT2_FT_BLKDEV 4
599#define EXT2_FT_FIFO 5
600#define EXT2_FT_SOCK 6
601#define EXT2_FT_SYMLINK 7
602
603#define EXT2_FT_MAX 8
604
605/*
606 * EXT2_DIR_PAD defines the directory entries boundaries
607 *
608 * NOTE: It must be a multiple of 4
609 */
610#define EXT2_DIR_PAD 4
611#define EXT2_DIR_ROUND (EXT2_DIR_PAD - 1)
612#define EXT2_DIR_REC_LEN(name_len) (((name_len) + 8 + EXT2_DIR_ROUND) & \
613 ~EXT2_DIR_ROUND)
614
Denis Vlasenkof81e8db2009-04-09 12:35:13 +0000615#endif