ext2_fs.h 20 KB

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