blob: b400f8c119da2af8742beb99da1959609939bb8b [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*/
185#define EXT3_EXTENTS_FL 0x00080000 /* Inode uses extents */
186#define EXT2_RESERVED_FL 0x80000000 /* reserved for ext2 lib */
187
188#define EXT2_FL_USER_VISIBLE 0x0003DFFF /* User visible flags */
189#define EXT2_FL_USER_MODIFIABLE 0x000080FF /* User modifiable flags */
190
191/*
192 * ioctl commands
193 */
194#define EXT2_IOC_GETFLAGS _IOR('f', 1, long)
195#define EXT2_IOC_SETFLAGS _IOW('f', 2, long)
196#define EXT2_IOC_GETVERSION _IOR('v', 1, long)
197#define EXT2_IOC_SETVERSION _IOW('v', 2, long)
198
199/*
200 * Structure of an inode on the disk
201 */
202struct ext2_inode {
203 uint16_t i_mode; /* File mode */
204 uint16_t i_uid; /* Low 16 bits of Owner Uid */
205 uint32_t i_size; /* Size in bytes */
206 uint32_t i_atime; /* Access time */
207 uint32_t i_ctime; /* Creation time */
208 uint32_t i_mtime; /* Modification time */
209 uint32_t i_dtime; /* Deletion Time */
210 uint16_t i_gid; /* Low 16 bits of Group Id */
211 uint16_t i_links_count; /* Links count */
212 uint32_t i_blocks; /* Blocks count */
213 uint32_t i_flags; /* File flags */
214 union {
215 struct {
216 uint32_t l_i_reserved1;
217 } linux1;
218 struct {
219 uint32_t h_i_translator;
220 } hurd1;
221 struct {
222 uint32_t m_i_reserved1;
223 } masix1;
224 } osd1; /* OS dependent 1 */
225 uint32_t i_block[EXT2_N_BLOCKS];/* Pointers to blocks */
226 uint32_t i_generation; /* File version (for NFS) */
227 uint32_t i_file_acl; /* File ACL */
228 uint32_t i_dir_acl; /* Directory ACL */
229 uint32_t i_faddr; /* Fragment address */
230 union {
231 struct {
232 uint8_t l_i_frag; /* Fragment number */
233 uint8_t l_i_fsize; /* Fragment size */
234 uint16_t i_pad1;
235 uint16_t l_i_uid_high; /* these 2 fields */
236 uint16_t l_i_gid_high; /* were reserved2[0] */
237 uint32_t l_i_reserved2;
238 } linux2;
239 struct {
240 uint8_t h_i_frag; /* Fragment number */
241 uint8_t h_i_fsize; /* Fragment size */
242 uint16_t h_i_mode_high;
243 uint16_t h_i_uid_high;
244 uint16_t h_i_gid_high;
245 uint32_t h_i_author;
246 } hurd2;
247 struct {
248 uint8_t m_i_frag; /* Fragment number */
249 uint8_t m_i_fsize; /* Fragment size */
250 uint16_t m_pad1;
251 uint32_t m_i_reserved2[2];
252 } masix2;
253 } osd2; /* OS dependent 2 */
254};
255
256/*
257 * Permanent part of an large inode on the disk
258 */
259struct ext2_inode_large {
260 uint16_t i_mode; /* File mode */
261 uint16_t i_uid; /* Low 16 bits of Owner Uid */
262 uint32_t i_size; /* Size in bytes */
263 uint32_t i_atime; /* Access time */
264 uint32_t i_ctime; /* Creation time */
265 uint32_t i_mtime; /* Modification time */
266 uint32_t i_dtime; /* Deletion Time */
267 uint16_t i_gid; /* Low 16 bits of Group Id */
268 uint16_t i_links_count; /* Links count */
269 uint32_t i_blocks; /* Blocks count */
270 uint32_t i_flags; /* File flags */
271 union {
272 struct {
273 uint32_t l_i_reserved1;
274 } linux1;
275 struct {
276 uint32_t h_i_translator;
277 } hurd1;
278 struct {
279 uint32_t m_i_reserved1;
280 } masix1;
281 } osd1; /* OS dependent 1 */
282 uint32_t i_block[EXT2_N_BLOCKS];/* Pointers to blocks */
283 uint32_t i_generation; /* File version (for NFS) */
284 uint32_t i_file_acl; /* File ACL */
285 uint32_t i_dir_acl; /* Directory ACL */
286 uint32_t i_faddr; /* Fragment address */
287 union {
288 struct {
289 uint8_t l_i_frag; /* Fragment number */
290 uint8_t l_i_fsize; /* Fragment size */
291 uint16_t i_pad1;
292 uint16_t l_i_uid_high; /* these 2 fields */
293 uint16_t l_i_gid_high; /* were reserved2[0] */
294 uint32_t l_i_reserved2;
295 } linux2;
296 struct {
297 uint8_t h_i_frag; /* Fragment number */
298 uint8_t h_i_fsize; /* Fragment size */
299 uint16_t h_i_mode_high;
300 uint16_t h_i_uid_high;
301 uint16_t h_i_gid_high;
302 uint32_t h_i_author;
303 } hurd2;
304 struct {
305 uint8_t m_i_frag; /* Fragment number */
306 uint8_t m_i_fsize; /* Fragment size */
307 uint16_t m_pad1;
308 uint32_t m_i_reserved2[2];
309 } masix2;
310 } osd2; /* OS dependent 2 */
311 uint16_t i_extra_isize;
312 uint16_t i_pad1;
313};
314
315#define i_size_high i_dir_acl
316
317/*
318 * File system states
319 */
320#define EXT2_VALID_FS 0x0001 /* Unmounted cleanly */
321#define EXT2_ERROR_FS 0x0002 /* Errors detected */
322
323/*
324 * Mount flags
325 */
326#define EXT2_MOUNT_CHECK 0x0001 /* Do mount-time checks */
327#define EXT2_MOUNT_GRPID 0x0004 /* Create files with directory's group */
328#define EXT2_MOUNT_DEBUG 0x0008 /* Some debugging messages */
329#define EXT2_MOUNT_ERRORS_CONT 0x0010 /* Continue on errors */
330#define EXT2_MOUNT_ERRORS_RO 0x0020 /* Remount fs ro on errors */
331#define EXT2_MOUNT_ERRORS_PANIC 0x0040 /* Panic on errors */
332#define EXT2_MOUNT_MINIX_DF 0x0080 /* Mimics the Minix statfs */
333#define EXT2_MOUNT_NO_UID32 0x0200 /* Disable 32-bit UIDs */
334
335#define clear_opt(o, opt) o &= ~EXT2_MOUNT_##opt
336#define set_opt(o, opt) o |= EXT2_MOUNT_##opt
337#define test_opt(sb, opt) (EXT2_SB(sb)->s_mount_opt & \
338 EXT2_MOUNT_##opt)
339/*
340 * Maximal mount counts between two filesystem checks
341 */
342#define EXT2_DFL_MAX_MNT_COUNT 20 /* Allow 20 mounts */
343#define EXT2_DFL_CHECKINTERVAL 0 /* Don't use interval check */
344
345/*
346 * Behaviour when detecting errors
347 */
348#define EXT2_ERRORS_CONTINUE 1 /* Continue execution */
349#define EXT2_ERRORS_RO 2 /* Remount fs read-only */
350#define EXT2_ERRORS_PANIC 3 /* Panic */
351#define EXT2_ERRORS_DEFAULT EXT2_ERRORS_CONTINUE
352
353/*
354 * Structure of the super block
355 */
356struct ext2_super_block {
357 uint32_t s_inodes_count; /* Inodes count */
358 uint32_t s_blocks_count; /* Blocks count */
359 uint32_t s_r_blocks_count; /* Reserved blocks count */
360 uint32_t s_free_blocks_count; /* Free blocks count */
361 uint32_t s_free_inodes_count; /* Free inodes count */
362 uint32_t s_first_data_block; /* First Data Block */
363 uint32_t s_log_block_size; /* Block size */
364 int32_t s_log_frag_size; /* Fragment size */
365 uint32_t s_blocks_per_group; /* # Blocks per group */
366 uint32_t s_frags_per_group; /* # Fragments per group */
367 uint32_t s_inodes_per_group; /* # Inodes per group */
368 uint32_t s_mtime; /* Mount time */
369 uint32_t s_wtime; /* Write time */
370 uint16_t s_mnt_count; /* Mount count */
371 int16_t s_max_mnt_count; /* Maximal mount count */
372 uint16_t s_magic; /* Magic signature */
373 uint16_t s_state; /* File system state */
374 uint16_t s_errors; /* Behaviour when detecting errors */
375 uint16_t s_minor_rev_level; /* minor revision level */
376 uint32_t s_lastcheck; /* time of last check */
377 uint32_t s_checkinterval; /* max. time between checks */
378 uint32_t s_creator_os; /* OS */
379 uint32_t s_rev_level; /* Revision level */
380 uint16_t s_def_resuid; /* Default uid for reserved blocks */
381 uint16_t s_def_resgid; /* Default gid for reserved blocks */
382 /*
383 * These fields are for EXT2_DYNAMIC_REV superblocks only.
384 *
385 * Note: the difference between the compatible feature set and
386 * the incompatible feature set is that if there is a bit set
387 * in the incompatible feature set that the kernel doesn't
388 * know about, it should refuse to mount the filesystem.
389 *
390 * e2fsck's requirements are more strict; if it doesn't know
391 * about a feature in either the compatible or incompatible
392 * feature set, it must abort and not try to meddle with
393 * things it doesn't understand...
394 */
395 uint32_t s_first_ino; /* First non-reserved inode */
396 uint16_t s_inode_size; /* size of inode structure */
397 uint16_t s_block_group_nr; /* block group # of this superblock */
398 uint32_t s_feature_compat; /* compatible feature set */
399 uint32_t s_feature_incompat; /* incompatible feature set */
400 uint32_t s_feature_ro_compat; /* readonly-compatible feature set */
401 uint8_t s_uuid[16]; /* 128-bit uuid for volume */
402 char s_volume_name[16]; /* volume name */
403 char s_last_mounted[64]; /* directory where last mounted */
404 uint32_t s_algorithm_usage_bitmap; /* For compression */
405 /*
406 * Performance hints. Directory preallocation should only
407 * happen if the EXT2_FEATURE_COMPAT_DIR_PREALLOC flag is on.
408 */
Denys Vlasenkoc9a13112012-06-21 16:50:46 +0200409 uint8_t s_prealloc_blocks; /* Nr of blocks to try to preallocate*/
410 uint8_t s_prealloc_dir_blocks; /* Nr to preallocate for dirs */
Denis Vlasenkoc4f623e2006-12-26 01:30:59 +0000411 uint16_t s_reserved_gdt_blocks; /* Per group table for online growth */
412 /*
413 * Journaling support valid if EXT2_FEATURE_COMPAT_HAS_JOURNAL set.
414 */
Denys Vlasenkoc9a13112012-06-21 16:50:46 +0200415/*D0*/ uint8_t s_journal_uuid[16]; /* uuid of journal superblock */
416/*E0*/ uint32_t s_journal_inum; /* inode number of journal file */
Denis Vlasenkoc4f623e2006-12-26 01:30:59 +0000417 uint32_t s_journal_dev; /* device number of journal file */
418 uint32_t s_last_orphan; /* start of list of inodes to delete */
419 uint32_t s_hash_seed[4]; /* HTREE hash seed */
420 uint8_t s_def_hash_version; /* Default hash version to use */
421 uint8_t s_jnl_backup_type; /* Default type of journal backup */
422 uint16_t s_reserved_word_pad;
Denys Vlasenkoc9a13112012-06-21 16:50:46 +0200423/*100*/ uint32_t s_default_mount_opts;
Denis Vlasenkoc4f623e2006-12-26 01:30:59 +0000424 uint32_t s_first_meta_bg; /* First metablock group */
Denys Vlasenkoc9a13112012-06-21 16:50:46 +0200425 /* ext3 additions */
Denis Vlasenkoc4f623e2006-12-26 01:30:59 +0000426 uint32_t s_mkfs_time; /* When the filesystem was created */
427 uint32_t s_jnl_blocks[17]; /* Backup of the journal inode */
Denys Vlasenkoc9a13112012-06-21 16:50:46 +0200428 /* 64bit support valid if EXT4_FEATURE_COMPAT_64BIT */
429/*150*/ uint32_t s_blocks_count_hi; /* Blocks count */
430 uint32_t s_r_blocks_count_hi; /* Reserved blocks count */
431 uint32_t s_free_blocks_count_hi; /* Free blocks count */
432 uint16_t s_min_extra_isize; /* All inodes have at least # bytes */
433 uint16_t s_want_extra_isize; /* New inodes should reserve # bytes */
434 uint32_t s_flags; /* Miscellaneous flags */
435 uint16_t s_raid_stride; /* RAID stride */
436 uint16_t s_mmp_interval; /* # seconds to wait in MMP checking */
437 uint64_t s_mmp_block; /* Block for multi-mount protection */
438 uint32_t s_raid_stripe_width; /* blocks on all data disks (N*stride)*/
439 uint8_t s_log_groups_per_flex; /* FLEX_BG group size */
440 uint8_t s_reserved_char_pad2;
441 uint16_t s_reserved_pad;
442 uint32_t s_reserved[162]; /* Padding to the end of the block */
443};
444struct BUG_ext2_super_block {
445 char bug[sizeof(struct ext2_super_block) == 1024 ? 1 : -1];
Denis Vlasenkoc4f623e2006-12-26 01:30:59 +0000446};
447
448/*
449 * Codes for operating systems
450 */
451#define EXT2_OS_LINUX 0
452#define EXT2_OS_HURD 1
453#define EXT2_OS_MASIX 2
454#define EXT2_OS_FREEBSD 3
455#define EXT2_OS_LITES 4
456
457/*
458 * Revision levels
459 */
460#define EXT2_GOOD_OLD_REV 0 /* The good old (original) format */
461#define EXT2_DYNAMIC_REV 1 /* V2 format w/ dynamic inode sizes */
462
463#define EXT2_CURRENT_REV EXT2_GOOD_OLD_REV
464#define EXT2_MAX_SUPP_REV EXT2_DYNAMIC_REV
465
466#define EXT2_GOOD_OLD_INODE_SIZE 128
467
468/*
469 * Journal inode backup types
470 */
471#define EXT3_JNL_BACKUP_BLOCKS 1
472
473/*
474 * Feature set definitions
475 */
476
477#define EXT2_HAS_COMPAT_FEATURE(sb,mask) \
478 ( EXT2_SB(sb)->s_feature_compat & (mask) )
479#define EXT2_HAS_RO_COMPAT_FEATURE(sb,mask) \
480 ( EXT2_SB(sb)->s_feature_ro_compat & (mask) )
481#define EXT2_HAS_INCOMPAT_FEATURE(sb,mask) \
482 ( EXT2_SB(sb)->s_feature_incompat & (mask) )
483
Denys Vlasenkoac164dd2012-06-12 15:00:35 +0200484/* for s_feature_compat */
Denis Vlasenkoc4f623e2006-12-26 01:30:59 +0000485#define EXT2_FEATURE_COMPAT_DIR_PREALLOC 0x0001
486#define EXT2_FEATURE_COMPAT_IMAGIC_INODES 0x0002
487#define EXT3_FEATURE_COMPAT_HAS_JOURNAL 0x0004
488#define EXT2_FEATURE_COMPAT_EXT_ATTR 0x0008
Denys Vlasenko176bc342012-04-17 15:06:55 +0200489#define EXT2_FEATURE_COMPAT_RESIZE_INO 0x0010
Denis Vlasenkoc4f623e2006-12-26 01:30:59 +0000490#define EXT2_FEATURE_COMPAT_DIR_INDEX 0x0020
491
Denys Vlasenkoac164dd2012-06-12 15:00:35 +0200492/* for s_feature_ro_compat */
Denis Vlasenkoc4f623e2006-12-26 01:30:59 +0000493#define EXT2_FEATURE_RO_COMPAT_SPARSE_SUPER 0x0001
494#define EXT2_FEATURE_RO_COMPAT_LARGE_FILE 0x0002
Denys Vlasenkoac164dd2012-06-12 15:00:35 +0200495#define EXT2_FEATURE_RO_COMPAT_BTREE_DIR 0x0004 /* not used */
496#define EXT4_FEATURE_RO_COMPAT_HUGE_FILE 0x0008
497#define EXT4_FEATURE_RO_COMPAT_GDT_CSUM 0x0010
498#define EXT4_FEATURE_RO_COMPAT_DIR_NLINK 0x0020
499#define EXT4_FEATURE_RO_COMPAT_EXTRA_ISIZE 0x0040
Denis Vlasenkoc4f623e2006-12-26 01:30:59 +0000500
Denys Vlasenkoac164dd2012-06-12 15:00:35 +0200501/* for s_feature_incompat */
Denis Vlasenkoc4f623e2006-12-26 01:30:59 +0000502#define EXT2_FEATURE_INCOMPAT_COMPRESSION 0x0001
503#define EXT2_FEATURE_INCOMPAT_FILETYPE 0x0002
Denys Vlasenkoac164dd2012-06-12 15:00:35 +0200504#define EXT3_FEATURE_INCOMPAT_RECOVER 0x0004
505#define EXT3_FEATURE_INCOMPAT_JOURNAL_DEV 0x0008
Denis Vlasenkoc4f623e2006-12-26 01:30:59 +0000506#define EXT2_FEATURE_INCOMPAT_META_BG 0x0010
Denys Vlasenkoac164dd2012-06-12 15:00:35 +0200507#define EXT4_FEATURE_INCOMPAT_EXTENTS 0x0040
508#define EXT4_FEATURE_INCOMPAT_64BIT 0x0080
509#define EXT4_FEATURE_INCOMPAT_MMP 0x0100
510#define EXT4_FEATURE_INCOMPAT_FLEX_BG 0x0200
Denis Vlasenkoc4f623e2006-12-26 01:30:59 +0000511
512
513#define EXT2_FEATURE_COMPAT_SUPP 0
Denis Vlasenkoc4f623e2006-12-26 01:30:59 +0000514#define EXT2_FEATURE_RO_COMPAT_SUPP (EXT2_FEATURE_RO_COMPAT_SPARSE_SUPER| \
515 EXT2_FEATURE_RO_COMPAT_LARGE_FILE| \
516 EXT2_FEATURE_RO_COMPAT_BTREE_DIR)
Denys Vlasenkoac164dd2012-06-12 15:00:35 +0200517#define EXT2_FEATURE_INCOMPAT_SUPP (EXT2_FEATURE_INCOMPAT_FILETYPE| \
518 EXT2_FEATURE_INCOMPAT_META_BG)
519#define EXT2_FEATURE_INCOMPAT_UNSUPPORTED (~EXT2_FEATURE_INCOMPAT_SUPP)
520#define EXT2_FEATURE_RO_COMPAT_UNSUPPORTED (~EXT2_FEATURE_RO_COMPAT_SUPP)
521
522#define EXT3_FEATURE_RO_COMPAT_SUPP (EXT2_FEATURE_RO_COMPAT_SPARSE_SUPER| \
523 EXT2_FEATURE_RO_COMPAT_LARGE_FILE| \
524 EXT2_FEATURE_RO_COMPAT_BTREE_DIR)
525#define EXT3_FEATURE_INCOMPAT_SUPP (EXT2_FEATURE_INCOMPAT_FILETYPE| \
526 EXT3_FEATURE_INCOMPAT_RECOVER| \
527 EXT2_FEATURE_INCOMPAT_META_BG)
528#define EXT3_FEATURE_INCOMPAT_UNSUPPORTED (~EXT3_FEATURE_INCOMPAT_SUPP)
529#define EXT3_FEATURE_RO_COMPAT_UNSUPPORTED (~EXT3_FEATURE_RO_COMPAT_SUPP)
530
Denis Vlasenkoc4f623e2006-12-26 01:30:59 +0000531
532/*
533 * Default values for user and/or group using reserved blocks
534 */
535#define EXT2_DEF_RESUID 0
536#define EXT2_DEF_RESGID 0
537
538/*
539 * Default mount options
540 */
541#define EXT2_DEFM_DEBUG 0x0001
542#define EXT2_DEFM_BSDGROUPS 0x0002
543#define EXT2_DEFM_XATTR_USER 0x0004
544#define EXT2_DEFM_ACL 0x0008
545#define EXT2_DEFM_UID16 0x0010
546#define EXT3_DEFM_JMODE 0x0060
547#define EXT3_DEFM_JMODE_DATA 0x0020
548#define EXT3_DEFM_JMODE_ORDERED 0x0040
549#define EXT3_DEFM_JMODE_WBACK 0x0060
550
551/*
552 * Structure of a directory entry
553 */
554#define EXT2_NAME_LEN 255
555
556struct ext2_dir_entry {
557 uint32_t inode; /* Inode number */
558 uint16_t rec_len; /* Directory entry length */
559 uint16_t name_len; /* Name length */
560 char name[EXT2_NAME_LEN]; /* File name */
561};
562
563/*
564 * The new version of the directory entry. Since EXT2 structures are
565 * stored in intel byte order, and the name_len field could never be
566 * bigger than 255 chars, it's safe to reclaim the extra byte for the
567 * file_type field.
568 */
569struct ext2_dir_entry_2 {
570 uint32_t inode; /* Inode number */
571 uint16_t rec_len; /* Directory entry length */
572 uint8_t name_len; /* Name length */
573 uint8_t file_type;
574 char name[EXT2_NAME_LEN]; /* File name */
575};
576
577/*
578 * Ext2 directory file types. Only the low 3 bits are used. The
579 * other bits are reserved for now.
580 */
581#define EXT2_FT_UNKNOWN 0
582#define EXT2_FT_REG_FILE 1
583#define EXT2_FT_DIR 2
584#define EXT2_FT_CHRDEV 3
585#define EXT2_FT_BLKDEV 4
586#define EXT2_FT_FIFO 5
587#define EXT2_FT_SOCK 6
588#define EXT2_FT_SYMLINK 7
589
590#define EXT2_FT_MAX 8
591
592/*
593 * EXT2_DIR_PAD defines the directory entries boundaries
594 *
595 * NOTE: It must be a multiple of 4
596 */
597#define EXT2_DIR_PAD 4
598#define EXT2_DIR_ROUND (EXT2_DIR_PAD - 1)
599#define EXT2_DIR_REC_LEN(name_len) (((name_len) + 8 + EXT2_DIR_ROUND) & \
600 ~EXT2_DIR_ROUND)
601
Denis Vlasenkof81e8db2009-04-09 12:35:13 +0000602#endif