e2fs_defs.h 18 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561
  1. /* 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. #ifndef _LINUX_EXT2_FS_H
  13. #define _LINUX_EXT2_FS_H
  14. /*
  15. * Special inode numbers
  16. */
  17. #define EXT2_BAD_INO 1 /* Bad blocks inode */
  18. #define EXT2_ROOT_INO 2 /* Root inode */
  19. #define EXT2_ACL_IDX_INO 3 /* ACL inode */
  20. #define EXT2_ACL_DATA_INO 4 /* ACL inode */
  21. #define EXT2_BOOT_LOADER_INO 5 /* Boot loader inode */
  22. #define EXT2_UNDEL_DIR_INO 6 /* Undelete directory inode */
  23. #define EXT2_RESIZE_INO 7 /* Reserved group descriptors inode */
  24. #define EXT2_JOURNAL_INO 8 /* Journal inode */
  25. /* First non-reserved inode for old ext2 filesystems */
  26. #define EXT2_GOOD_OLD_FIRST_INO 11
  27. /*
  28. * The second extended file system magic number
  29. */
  30. #define EXT2_SUPER_MAGIC 0xEF53
  31. /* Assume that user mode programs are passing in an ext2fs superblock, not
  32. * a kernel struct super_block. This will allow us to call the feature-test
  33. * macros from user land. */
  34. #define EXT2_SB(sb) (sb)
  35. /*
  36. * Maximal count of links to a file
  37. */
  38. #define EXT2_LINK_MAX 32000
  39. /*
  40. * Macro-instructions used to manage several block sizes
  41. */
  42. #define EXT2_MIN_BLOCK_LOG_SIZE 10 /* 1024 */
  43. #define EXT2_MAX_BLOCK_LOG_SIZE 16 /* 65536 */
  44. #define EXT2_MIN_BLOCK_SIZE (1 << EXT2_MIN_BLOCK_LOG_SIZE)
  45. #define EXT2_MAX_BLOCK_SIZE (1 << EXT2_MAX_BLOCK_LOG_SIZE)
  46. #define EXT2_BLOCK_SIZE(s) (EXT2_MIN_BLOCK_SIZE << (s)->s_log_block_size)
  47. #define EXT2_BLOCK_SIZE_BITS(s) ((s)->s_log_block_size + 10)
  48. #define EXT2_INODE_SIZE(s) (((s)->s_rev_level == EXT2_GOOD_OLD_REV) ? \
  49. EXT2_GOOD_OLD_INODE_SIZE : (s)->s_inode_size)
  50. #define EXT2_FIRST_INO(s) (((s)->s_rev_level == EXT2_GOOD_OLD_REV) ? \
  51. EXT2_GOOD_OLD_FIRST_INO : (s)->s_first_ino)
  52. #define EXT2_ADDR_PER_BLOCK(s) (EXT2_BLOCK_SIZE(s) / sizeof(uint32_t))
  53. /*
  54. * Macro-instructions used to manage fragments
  55. */
  56. #define EXT2_MIN_FRAG_SIZE EXT2_MIN_BLOCK_SIZE
  57. #define EXT2_MAX_FRAG_SIZE EXT2_MAX_BLOCK_SIZE
  58. #define EXT2_MIN_FRAG_LOG_SIZE EXT2_MIN_BLOCK_LOG_SIZE
  59. #define EXT2_FRAG_SIZE(s) (EXT2_MIN_FRAG_SIZE << (s)->s_log_frag_size)
  60. #define EXT2_FRAGS_PER_BLOCK(s) (EXT2_BLOCK_SIZE(s) / EXT2_FRAG_SIZE(s))
  61. /*
  62. * ACL structures
  63. */
  64. struct ext2_acl_header { /* Header of Access Control Lists */
  65. uint32_t aclh_size;
  66. uint32_t aclh_file_count;
  67. uint32_t aclh_acle_count;
  68. uint32_t aclh_first_acle;
  69. };
  70. struct ext2_acl_entry { /* Access Control List Entry */
  71. uint32_t acle_size;
  72. uint16_t acle_perms; /* Access permissions */
  73. uint16_t acle_type; /* Type of entry */
  74. uint16_t acle_tag; /* User or group identity */
  75. uint16_t acle_pad1;
  76. uint32_t acle_next; /* Pointer on next entry for the */
  77. /* same inode or on next free entry */
  78. };
  79. /*
  80. * Structure of a blocks group descriptor
  81. */
  82. struct ext2_group_desc {
  83. uint32_t bg_block_bitmap; /* Blocks bitmap block */
  84. uint32_t bg_inode_bitmap; /* Inodes bitmap block */
  85. uint32_t bg_inode_table; /* Inodes table block */
  86. uint16_t bg_free_blocks_count; /* Free blocks count */
  87. uint16_t bg_free_inodes_count; /* Free inodes count */
  88. uint16_t bg_used_dirs_count; /* Directories count */
  89. uint16_t bg_pad;
  90. uint32_t bg_reserved[3];
  91. };
  92. /*
  93. * Data structures used by the directory indexing feature
  94. *
  95. * Note: all of the multibyte integer fields are little endian.
  96. */
  97. /*
  98. * Note: dx_root_info is laid out so that if it should somehow get
  99. * overlaid by a dirent the two low bits of the hash version will be
  100. * zero. Therefore, the hash version mod 4 should never be 0.
  101. * Sincerely, the paranoia department.
  102. */
  103. struct ext2_dx_root_info {
  104. uint32_t reserved_zero;
  105. uint8_t hash_version; /* 0 now, 1 at release */
  106. uint8_t info_length; /* 8 */
  107. uint8_t indirect_levels;
  108. uint8_t unused_flags;
  109. };
  110. #define EXT2_HASH_LEGACY 0
  111. #define EXT2_HASH_HALF_MD4 1
  112. #define EXT2_HASH_TEA 2
  113. #define EXT2_HASH_FLAG_INCOMPAT 0x1
  114. struct ext2_dx_entry {
  115. uint32_t hash;
  116. uint32_t block;
  117. };
  118. struct ext2_dx_countlimit {
  119. uint16_t limit;
  120. uint16_t count;
  121. };
  122. /*
  123. * Macro-instructions used to manage group descriptors
  124. */
  125. #define EXT2_BLOCKS_PER_GROUP(s) (EXT2_SB(s)->s_blocks_per_group)
  126. #define EXT2_INODES_PER_GROUP(s) (EXT2_SB(s)->s_inodes_per_group)
  127. #define EXT2_INODES_PER_BLOCK(s) (EXT2_BLOCK_SIZE(s)/EXT2_INODE_SIZE(s))
  128. /* limits imposed by 16-bit value gd_free_{blocks,inode}_count */
  129. #define EXT2_MAX_BLOCKS_PER_GROUP(s) ((1 << 16) - 8)
  130. #define EXT2_MAX_INODES_PER_GROUP(s) ((1 << 16) - EXT2_INODES_PER_BLOCK(s))
  131. #define EXT2_DESC_PER_BLOCK(s) (EXT2_BLOCK_SIZE(s) / sizeof (struct ext2_group_desc))
  132. /*
  133. * Constants relative to the data blocks
  134. */
  135. #define EXT2_NDIR_BLOCKS 12
  136. #define EXT2_IND_BLOCK EXT2_NDIR_BLOCKS
  137. #define EXT2_DIND_BLOCK (EXT2_IND_BLOCK + 1)
  138. #define EXT2_TIND_BLOCK (EXT2_DIND_BLOCK + 1)
  139. #define EXT2_N_BLOCKS (EXT2_TIND_BLOCK + 1)
  140. /*
  141. * Inode flags
  142. */
  143. #define EXT2_SECRM_FL 0x00000001 /* Secure deletion */
  144. #define EXT2_UNRM_FL 0x00000002 /* Undelete */
  145. #define EXT2_COMPR_FL 0x00000004 /* Compress file */
  146. #define EXT2_SYNC_FL 0x00000008 /* Synchronous updates */
  147. #define EXT2_IMMUTABLE_FL 0x00000010 /* Immutable file */
  148. #define EXT2_APPEND_FL 0x00000020 /* writes to file may only append */
  149. #define EXT2_NODUMP_FL 0x00000040 /* do not dump file */
  150. #define EXT2_NOATIME_FL 0x00000080 /* do not update atime */
  151. /* Reserved for compression usage... */
  152. #define EXT2_DIRTY_FL 0x00000100
  153. #define EXT2_COMPRBLK_FL 0x00000200 /* One or more compressed clusters */
  154. #define EXT2_NOCOMPR_FL 0x00000400 /* Access raw compressed data */
  155. #define EXT2_ECOMPR_FL 0x00000800 /* Compression error */
  156. /* End compression flags --- maybe not all used */
  157. #define EXT2_BTREE_FL 0x00001000 /* btree format dir */
  158. #define EXT2_INDEX_FL 0x00001000 /* hash-indexed directory */
  159. #define EXT2_IMAGIC_FL 0x00002000
  160. #define EXT3_JOURNAL_DATA_FL 0x00004000 /* file data should be journaled */
  161. #define EXT2_NOTAIL_FL 0x00008000 /* file tail should not be merged */
  162. #define EXT2_DIRSYNC_FL 0x00010000 /* Synchronous directory modifications */
  163. #define EXT2_TOPDIR_FL 0x00020000 /* Top of directory hierarchies*/
  164. #define EXT3_EXTENTS_FL 0x00080000 /* Inode uses extents */
  165. #define EXT2_RESERVED_FL 0x80000000 /* reserved for ext2 lib */
  166. #define EXT2_FL_USER_VISIBLE 0x0003DFFF /* User visible flags */
  167. #define EXT2_FL_USER_MODIFIABLE 0x000080FF /* User modifiable flags */
  168. /*
  169. * ioctl commands
  170. */
  171. #define EXT2_IOC_GETFLAGS _IOR('f', 1, long)
  172. #define EXT2_IOC_SETFLAGS _IOW('f', 2, long)
  173. #define EXT2_IOC_GETVERSION _IOR('v', 1, long)
  174. #define EXT2_IOC_SETVERSION _IOW('v', 2, long)
  175. /*
  176. * Structure of an inode on the disk
  177. */
  178. struct ext2_inode {
  179. uint16_t i_mode; /* File mode */
  180. uint16_t i_uid; /* Low 16 bits of Owner Uid */
  181. uint32_t i_size; /* Size in bytes */
  182. uint32_t i_atime; /* Access time */
  183. uint32_t i_ctime; /* Creation time */
  184. uint32_t i_mtime; /* Modification time */
  185. uint32_t i_dtime; /* Deletion Time */
  186. uint16_t i_gid; /* Low 16 bits of Group Id */
  187. uint16_t i_links_count; /* Links count */
  188. uint32_t i_blocks; /* Blocks count */
  189. uint32_t i_flags; /* File flags */
  190. union {
  191. struct {
  192. uint32_t l_i_reserved1;
  193. } linux1;
  194. struct {
  195. uint32_t h_i_translator;
  196. } hurd1;
  197. struct {
  198. uint32_t m_i_reserved1;
  199. } masix1;
  200. } osd1; /* OS dependent 1 */
  201. uint32_t i_block[EXT2_N_BLOCKS];/* Pointers to blocks */
  202. uint32_t i_generation; /* File version (for NFS) */
  203. uint32_t i_file_acl; /* File ACL */
  204. uint32_t i_dir_acl; /* Directory ACL */
  205. uint32_t i_faddr; /* Fragment address */
  206. union {
  207. struct {
  208. uint8_t l_i_frag; /* Fragment number */
  209. uint8_t l_i_fsize; /* Fragment size */
  210. uint16_t i_pad1;
  211. uint16_t l_i_uid_high; /* these 2 fields */
  212. uint16_t l_i_gid_high; /* were reserved2[0] */
  213. uint32_t l_i_reserved2;
  214. } linux2;
  215. struct {
  216. uint8_t h_i_frag; /* Fragment number */
  217. uint8_t h_i_fsize; /* Fragment size */
  218. uint16_t h_i_mode_high;
  219. uint16_t h_i_uid_high;
  220. uint16_t h_i_gid_high;
  221. uint32_t h_i_author;
  222. } hurd2;
  223. struct {
  224. uint8_t m_i_frag; /* Fragment number */
  225. uint8_t m_i_fsize; /* Fragment size */
  226. uint16_t m_pad1;
  227. uint32_t m_i_reserved2[2];
  228. } masix2;
  229. } osd2; /* OS dependent 2 */
  230. };
  231. /*
  232. * Permanent part of an large inode on the disk
  233. */
  234. struct ext2_inode_large {
  235. uint16_t i_mode; /* File mode */
  236. uint16_t i_uid; /* Low 16 bits of Owner Uid */
  237. uint32_t i_size; /* Size in bytes */
  238. uint32_t i_atime; /* Access time */
  239. uint32_t i_ctime; /* Creation time */
  240. uint32_t i_mtime; /* Modification time */
  241. uint32_t i_dtime; /* Deletion Time */
  242. uint16_t i_gid; /* Low 16 bits of Group Id */
  243. uint16_t i_links_count; /* Links count */
  244. uint32_t i_blocks; /* Blocks count */
  245. uint32_t i_flags; /* File flags */
  246. union {
  247. struct {
  248. uint32_t l_i_reserved1;
  249. } linux1;
  250. struct {
  251. uint32_t h_i_translator;
  252. } hurd1;
  253. struct {
  254. uint32_t m_i_reserved1;
  255. } masix1;
  256. } osd1; /* OS dependent 1 */
  257. uint32_t i_block[EXT2_N_BLOCKS];/* Pointers to blocks */
  258. uint32_t i_generation; /* File version (for NFS) */
  259. uint32_t i_file_acl; /* File ACL */
  260. uint32_t i_dir_acl; /* Directory ACL */
  261. uint32_t i_faddr; /* Fragment address */
  262. union {
  263. struct {
  264. uint8_t l_i_frag; /* Fragment number */
  265. uint8_t l_i_fsize; /* Fragment size */
  266. uint16_t i_pad1;
  267. uint16_t l_i_uid_high; /* these 2 fields */
  268. uint16_t l_i_gid_high; /* were reserved2[0] */
  269. uint32_t l_i_reserved2;
  270. } linux2;
  271. struct {
  272. uint8_t h_i_frag; /* Fragment number */
  273. uint8_t h_i_fsize; /* Fragment size */
  274. uint16_t h_i_mode_high;
  275. uint16_t h_i_uid_high;
  276. uint16_t h_i_gid_high;
  277. uint32_t h_i_author;
  278. } hurd2;
  279. struct {
  280. uint8_t m_i_frag; /* Fragment number */
  281. uint8_t m_i_fsize; /* Fragment size */
  282. uint16_t m_pad1;
  283. uint32_t m_i_reserved2[2];
  284. } masix2;
  285. } osd2; /* OS dependent 2 */
  286. uint16_t i_extra_isize;
  287. uint16_t i_pad1;
  288. };
  289. #define i_size_high i_dir_acl
  290. /*
  291. * File system states
  292. */
  293. #define EXT2_VALID_FS 0x0001 /* Unmounted cleanly */
  294. #define EXT2_ERROR_FS 0x0002 /* Errors detected */
  295. /*
  296. * Mount flags
  297. */
  298. #define EXT2_MOUNT_CHECK 0x0001 /* Do mount-time checks */
  299. #define EXT2_MOUNT_GRPID 0x0004 /* Create files with directory's group */
  300. #define EXT2_MOUNT_DEBUG 0x0008 /* Some debugging messages */
  301. #define EXT2_MOUNT_ERRORS_CONT 0x0010 /* Continue on errors */
  302. #define EXT2_MOUNT_ERRORS_RO 0x0020 /* Remount fs ro on errors */
  303. #define EXT2_MOUNT_ERRORS_PANIC 0x0040 /* Panic on errors */
  304. #define EXT2_MOUNT_MINIX_DF 0x0080 /* Mimics the Minix statfs */
  305. #define EXT2_MOUNT_NO_UID32 0x0200 /* Disable 32-bit UIDs */
  306. #define clear_opt(o, opt) o &= ~EXT2_MOUNT_##opt
  307. #define set_opt(o, opt) o |= EXT2_MOUNT_##opt
  308. #define test_opt(sb, opt) (EXT2_SB(sb)->s_mount_opt & \
  309. EXT2_MOUNT_##opt)
  310. /*
  311. * Maximal mount counts between two filesystem checks
  312. */
  313. #define EXT2_DFL_MAX_MNT_COUNT 20 /* Allow 20 mounts */
  314. #define EXT2_DFL_CHECKINTERVAL 0 /* Don't use interval check */
  315. /*
  316. * Behaviour when detecting errors
  317. */
  318. #define EXT2_ERRORS_CONTINUE 1 /* Continue execution */
  319. #define EXT2_ERRORS_RO 2 /* Remount fs read-only */
  320. #define EXT2_ERRORS_PANIC 3 /* Panic */
  321. #define EXT2_ERRORS_DEFAULT EXT2_ERRORS_CONTINUE
  322. /*
  323. * Structure of the super block
  324. */
  325. struct ext2_super_block {
  326. uint32_t s_inodes_count; /* Inodes count */
  327. uint32_t s_blocks_count; /* Blocks count */
  328. uint32_t s_r_blocks_count; /* Reserved blocks count */
  329. uint32_t s_free_blocks_count; /* Free blocks count */
  330. uint32_t s_free_inodes_count; /* Free inodes count */
  331. uint32_t s_first_data_block; /* First Data Block */
  332. uint32_t s_log_block_size; /* Block size */
  333. int32_t s_log_frag_size; /* Fragment size */
  334. uint32_t s_blocks_per_group; /* # Blocks per group */
  335. uint32_t s_frags_per_group; /* # Fragments per group */
  336. uint32_t s_inodes_per_group; /* # Inodes per group */
  337. uint32_t s_mtime; /* Mount time */
  338. uint32_t s_wtime; /* Write time */
  339. uint16_t s_mnt_count; /* Mount count */
  340. int16_t s_max_mnt_count; /* Maximal mount count */
  341. uint16_t s_magic; /* Magic signature */
  342. uint16_t s_state; /* File system state */
  343. uint16_t s_errors; /* Behaviour when detecting errors */
  344. uint16_t s_minor_rev_level; /* minor revision level */
  345. uint32_t s_lastcheck; /* time of last check */
  346. uint32_t s_checkinterval; /* max. time between checks */
  347. uint32_t s_creator_os; /* OS */
  348. uint32_t s_rev_level; /* Revision level */
  349. uint16_t s_def_resuid; /* Default uid for reserved blocks */
  350. uint16_t s_def_resgid; /* Default gid for reserved blocks */
  351. /*
  352. * These fields are for EXT2_DYNAMIC_REV superblocks only.
  353. *
  354. * Note: the difference between the compatible feature set and
  355. * the incompatible feature set is that if there is a bit set
  356. * in the incompatible feature set that the kernel doesn't
  357. * know about, it should refuse to mount the filesystem.
  358. *
  359. * e2fsck's requirements are more strict; if it doesn't know
  360. * about a feature in either the compatible or incompatible
  361. * feature set, it must abort and not try to meddle with
  362. * things it doesn't understand...
  363. */
  364. uint32_t s_first_ino; /* First non-reserved inode */
  365. uint16_t s_inode_size; /* size of inode structure */
  366. uint16_t s_block_group_nr; /* block group # of this superblock */
  367. uint32_t s_feature_compat; /* compatible feature set */
  368. uint32_t s_feature_incompat; /* incompatible feature set */
  369. uint32_t s_feature_ro_compat; /* readonly-compatible feature set */
  370. uint8_t s_uuid[16]; /* 128-bit uuid for volume */
  371. char s_volume_name[16]; /* volume name */
  372. char s_last_mounted[64]; /* directory where last mounted */
  373. uint32_t s_algorithm_usage_bitmap; /* For compression */
  374. /*
  375. * Performance hints. Directory preallocation should only
  376. * happen if the EXT2_FEATURE_COMPAT_DIR_PREALLOC flag is on.
  377. */
  378. uint8_t s_prealloc_blocks; /* Nr of blocks to try to preallocate*/
  379. uint8_t s_prealloc_dir_blocks; /* Nr to preallocate for dirs */
  380. uint16_t s_reserved_gdt_blocks; /* Per group table for online growth */
  381. /*
  382. * Journaling support valid if EXT2_FEATURE_COMPAT_HAS_JOURNAL set.
  383. */
  384. uint8_t s_journal_uuid[16]; /* uuid of journal superblock */
  385. uint32_t s_journal_inum; /* inode number of journal file */
  386. uint32_t s_journal_dev; /* device number of journal file */
  387. uint32_t s_last_orphan; /* start of list of inodes to delete */
  388. uint32_t s_hash_seed[4]; /* HTREE hash seed */
  389. uint8_t s_def_hash_version; /* Default hash version to use */
  390. uint8_t s_jnl_backup_type; /* Default type of journal backup */
  391. uint16_t s_reserved_word_pad;
  392. uint32_t s_default_mount_opts;
  393. uint32_t s_first_meta_bg; /* First metablock group */
  394. uint32_t s_mkfs_time; /* When the filesystem was created */
  395. uint32_t s_jnl_blocks[17]; /* Backup of the journal inode */
  396. uint32_t s_reserved[172]; /* Padding to the end of the block */
  397. };
  398. /*
  399. * Codes for operating systems
  400. */
  401. #define EXT2_OS_LINUX 0
  402. #define EXT2_OS_HURD 1
  403. #define EXT2_OS_MASIX 2
  404. #define EXT2_OS_FREEBSD 3
  405. #define EXT2_OS_LITES 4
  406. /*
  407. * Revision levels
  408. */
  409. #define EXT2_GOOD_OLD_REV 0 /* The good old (original) format */
  410. #define EXT2_DYNAMIC_REV 1 /* V2 format w/ dynamic inode sizes */
  411. #define EXT2_CURRENT_REV EXT2_GOOD_OLD_REV
  412. #define EXT2_MAX_SUPP_REV EXT2_DYNAMIC_REV
  413. #define EXT2_GOOD_OLD_INODE_SIZE 128
  414. /*
  415. * Journal inode backup types
  416. */
  417. #define EXT3_JNL_BACKUP_BLOCKS 1
  418. /*
  419. * Feature set definitions
  420. */
  421. #define EXT2_HAS_COMPAT_FEATURE(sb,mask) \
  422. ( EXT2_SB(sb)->s_feature_compat & (mask) )
  423. #define EXT2_HAS_RO_COMPAT_FEATURE(sb,mask) \
  424. ( EXT2_SB(sb)->s_feature_ro_compat & (mask) )
  425. #define EXT2_HAS_INCOMPAT_FEATURE(sb,mask) \
  426. ( EXT2_SB(sb)->s_feature_incompat & (mask) )
  427. #define EXT2_FEATURE_COMPAT_DIR_PREALLOC 0x0001
  428. #define EXT2_FEATURE_COMPAT_IMAGIC_INODES 0x0002
  429. #define EXT3_FEATURE_COMPAT_HAS_JOURNAL 0x0004
  430. #define EXT2_FEATURE_COMPAT_EXT_ATTR 0x0008
  431. #define EXT2_FEATURE_COMPAT_RESIZE_INODE 0x0010
  432. #define EXT2_FEATURE_COMPAT_DIR_INDEX 0x0020
  433. #define EXT2_FEATURE_RO_COMPAT_SPARSE_SUPER 0x0001
  434. #define EXT2_FEATURE_RO_COMPAT_LARGE_FILE 0x0002
  435. /* #define EXT2_FEATURE_RO_COMPAT_BTREE_DIR 0x0004 not used */
  436. #define EXT2_FEATURE_INCOMPAT_COMPRESSION 0x0001
  437. #define EXT2_FEATURE_INCOMPAT_FILETYPE 0x0002
  438. #define EXT3_FEATURE_INCOMPAT_RECOVER 0x0004 /* Needs recovery */
  439. #define EXT3_FEATURE_INCOMPAT_JOURNAL_DEV 0x0008 /* Journal device */
  440. #define EXT2_FEATURE_INCOMPAT_META_BG 0x0010
  441. #define EXT3_FEATURE_INCOMPAT_EXTENTS 0x0040
  442. #define EXT2_FEATURE_COMPAT_SUPP 0
  443. #define EXT2_FEATURE_INCOMPAT_SUPP (EXT2_FEATURE_INCOMPAT_FILETYPE)
  444. #define EXT2_FEATURE_RO_COMPAT_SUPP (EXT2_FEATURE_RO_COMPAT_SPARSE_SUPER| \
  445. EXT2_FEATURE_RO_COMPAT_LARGE_FILE| \
  446. EXT2_FEATURE_RO_COMPAT_BTREE_DIR)
  447. /*
  448. * Default values for user and/or group using reserved blocks
  449. */
  450. #define EXT2_DEF_RESUID 0
  451. #define EXT2_DEF_RESGID 0
  452. /*
  453. * Default mount options
  454. */
  455. #define EXT2_DEFM_DEBUG 0x0001
  456. #define EXT2_DEFM_BSDGROUPS 0x0002
  457. #define EXT2_DEFM_XATTR_USER 0x0004
  458. #define EXT2_DEFM_ACL 0x0008
  459. #define EXT2_DEFM_UID16 0x0010
  460. #define EXT3_DEFM_JMODE 0x0060
  461. #define EXT3_DEFM_JMODE_DATA 0x0020
  462. #define EXT3_DEFM_JMODE_ORDERED 0x0040
  463. #define EXT3_DEFM_JMODE_WBACK 0x0060
  464. /*
  465. * Structure of a directory entry
  466. */
  467. #define EXT2_NAME_LEN 255
  468. struct ext2_dir_entry {
  469. uint32_t inode; /* Inode number */
  470. uint16_t rec_len; /* Directory entry length */
  471. uint16_t name_len; /* Name length */
  472. char name[EXT2_NAME_LEN]; /* File name */
  473. };
  474. /*
  475. * The new version of the directory entry. Since EXT2 structures are
  476. * stored in intel byte order, and the name_len field could never be
  477. * bigger than 255 chars, it's safe to reclaim the extra byte for the
  478. * file_type field.
  479. */
  480. struct ext2_dir_entry_2 {
  481. uint32_t inode; /* Inode number */
  482. uint16_t rec_len; /* Directory entry length */
  483. uint8_t name_len; /* Name length */
  484. uint8_t file_type;
  485. char name[EXT2_NAME_LEN]; /* File name */
  486. };
  487. /*
  488. * Ext2 directory file types. Only the low 3 bits are used. The
  489. * other bits are reserved for now.
  490. */
  491. #define EXT2_FT_UNKNOWN 0
  492. #define EXT2_FT_REG_FILE 1
  493. #define EXT2_FT_DIR 2
  494. #define EXT2_FT_CHRDEV 3
  495. #define EXT2_FT_BLKDEV 4
  496. #define EXT2_FT_FIFO 5
  497. #define EXT2_FT_SOCK 6
  498. #define EXT2_FT_SYMLINK 7
  499. #define EXT2_FT_MAX 8
  500. /*
  501. * EXT2_DIR_PAD defines the directory entries boundaries
  502. *
  503. * NOTE: It must be a multiple of 4
  504. */
  505. #define EXT2_DIR_PAD 4
  506. #define EXT2_DIR_ROUND (EXT2_DIR_PAD - 1)
  507. #define EXT2_DIR_REC_LEN(name_len) (((name_len) + 8 + EXT2_DIR_ROUND) & \
  508. ~EXT2_DIR_ROUND)
  509. #endif /* _LINUX_EXT2_FS_H */