3
0

bb_e2fs_defs.h 21 KB

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