• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /****************************************************************************
2  ****************************************************************************
3  ***
4  ***   This header was automatically generated from a Linux kernel header
5  ***   of the same name, to make information necessary for userspace to
6  ***   call into the kernel available to libc.  It contains only constants,
7  ***   structures, and macros generated from the original header, and thus,
8  ***   contains no copyrightable information.
9  ***
10  ****************************************************************************
11  ****************************************************************************/
12 #ifndef _EXT4_H
13 #define _EXT4_H
14 
15 #include <sys/types.h>
16 
17 #undef EXT4FS_DEBUG
18 
19 #ifdef EXT4FS_DEBUG
20 #define ext4_debug(f, a...)                                                             \
21     do {                                                                                \
22         printk(KERN_DEBUG "EXT4-fs DEBUG (%s, %d): %s:", __FILE__, __LINE__, __func__); \
23         printk(KERN_DEBUG f, ##a);                                                      \
24     } while (0)
25 #else
26 #define ext4_debug(f, a...) \
27     do {                    \
28     } while (0)
29 #endif
30 
31 #define EXT4_ERROR_INODE(inode, fmt, a...) ext4_error_inode(__func__, (inode), (fmt), ##a);
32 
33 #define EXT4_ERROR_FILE(file, fmt, a...) ext4_error_file(__func__, (file), (fmt), ##a);
34 
35 typedef int ext4_grpblk_t;
36 
37 typedef unsigned long long ext4_fsblk_t;
38 
39 typedef __u32 ext4_lblk_t;
40 
41 typedef unsigned int ext4_group_t;
42 
43 #define EXT4_MB_HINT_MERGE 0x0001
44 
45 #define EXT4_MB_HINT_RESERVED 0x0002
46 
47 #define EXT4_MB_HINT_METADATA 0x0004
48 
49 #define EXT4_MB_HINT_FIRST 0x0008
50 
51 #define EXT4_MB_HINT_BEST 0x0010
52 
53 #define EXT4_MB_HINT_DATA 0x0020
54 
55 #define EXT4_MB_HINT_NOPREALLOC 0x0040
56 
57 #define EXT4_MB_HINT_GROUP_ALLOC 0x0080
58 
59 #define EXT4_MB_HINT_GOAL_ONLY 0x0100
60 
61 #define EXT4_MB_HINT_TRY_GOAL 0x0200
62 
63 #define EXT4_MB_DELALLOC_RESERVED 0x0400
64 
65 #define EXT4_MB_STREAM_ALLOC 0x0800
66 
67 struct ext4_allocation_request {
68     struct inode* inode;
69 
70     unsigned int len;
71 
72     ext4_lblk_t logical;
73 
74     ext4_lblk_t lleft;
75 
76     ext4_lblk_t lright;
77 
78     ext4_fsblk_t goal;
79 
80     ext4_fsblk_t pleft;
81 
82     ext4_fsblk_t pright;
83 
84     unsigned int flags;
85 };
86 
87 #define EXT4_BAD_INO 1
88 #define EXT4_ROOT_INO 2
89 #define EXT4_BOOT_LOADER_INO 5
90 #define EXT4_UNDEL_DIR_INO 6
91 #define EXT4_RESIZE_INO 7
92 #define EXT4_JOURNAL_INO 8
93 
94 #define EXT4_GOOD_OLD_FIRST_INO 11
95 
96 #define EXT4_LINK_MAX 65000
97 
98 #define EXT4_MIN_BLOCK_SIZE 1024
99 #define EXT4_MAX_BLOCK_SIZE 65536
100 #define EXT4_MIN_BLOCK_LOG_SIZE 10
101 #define EXT4_BLOCK_SIZE(s) (EXT4_MIN_BLOCK_SIZE << (s)->s_log_block_size)
102 #define EXT4_ADDR_PER_BLOCK(s) (EXT4_BLOCK_SIZE(s) / sizeof(__u32))
103 #define EXT4_BLOCK_SIZE_BITS(s) ((s)->s_log_block_size + 10)
104 #define EXT4_INODE_SIZE(s) \
105     (((s)->s_rev_level == EXT4_GOOD_OLD_REV) ? EXT4_GOOD_OLD_INODE_SIZE : (s)->s_inode_size)
106 #define EXT4_FIRST_INO(s) \
107     (((s)->s_rev_level == EXT4_GOOD_OLD_REV) ? EXT4_GOOD_OLD_FIRST_INO : (s)->s_first_ino)
108 #define EXT4_BLOCK_ALIGN(size, blkbits) EXT4_ALIGN((size), (1 << (blkbits)))
109 
110 struct ext4_group_desc {
111     __le32 bg_block_bitmap_lo;
112     __le32 bg_inode_bitmap_lo;
113     __le32 bg_inode_table_lo;
114     __le16 bg_free_blocks_count_lo;
115     __le16 bg_free_inodes_count_lo;
116     __le16 bg_used_dirs_count_lo;
117     __le16 bg_flags;
118     __u32 bg_reserved[2];
119     __le16 bg_itable_unused_lo;
120     __le16 bg_checksum;
121     __le32 bg_block_bitmap_hi;
122     __le32 bg_inode_bitmap_hi;
123     __le32 bg_inode_table_hi;
124     __le16 bg_free_blocks_count_hi;
125     __le16 bg_free_inodes_count_hi;
126     __le16 bg_used_dirs_count_hi;
127     __le16 bg_itable_unused_hi;
128     __u32 bg_reserved2[3];
129 };
130 
131 #define EXT4_BG_INODE_UNINIT 0x0001
132 #define EXT4_BG_BLOCK_UNINIT 0x0002
133 #define EXT4_BG_INODE_ZEROED 0x0004
134 
135 #define EXT4_MIN_DESC_SIZE 32
136 #define EXT4_MIN_DESC_SIZE_64BIT 64
137 #define EXT4_MAX_DESC_SIZE EXT4_MIN_BLOCK_SIZE
138 #define EXT4_DESC_SIZE(s) (EXT4_SB(s)->s_desc_size)
139 #define EXT4_BLOCKS_PER_GROUP(s) ((s)->s_blocks_per_group)
140 #define EXT4_DESC_PER_BLOCK(s) (EXT4_BLOCK_SIZE(s) / EXT4_DESC_SIZE(s))
141 #define EXT4_INODES_PER_GROUP(s) ((s)->s_inodes_per_group)
142 
143 #define EXT4_NDIR_BLOCKS 12
144 #define EXT4_IND_BLOCK EXT4_NDIR_BLOCKS
145 #define EXT4_DIND_BLOCK (EXT4_IND_BLOCK + 1)
146 #define EXT4_TIND_BLOCK (EXT4_DIND_BLOCK + 1)
147 #define EXT4_N_BLOCKS (EXT4_TIND_BLOCK + 1)
148 
149 #define EXT4_SECRM_FL 0x00000001
150 #define EXT4_UNRM_FL 0x00000002
151 #define EXT4_COMPR_FL 0x00000004
152 #define EXT4_SYNC_FL 0x00000008
153 #define EXT4_IMMUTABLE_FL 0x00000010
154 #define EXT4_APPEND_FL 0x00000020
155 #define EXT4_NODUMP_FL 0x00000040
156 #define EXT4_NOATIME_FL 0x00000080
157 
158 #define EXT4_DIRTY_FL 0x00000100
159 #define EXT4_COMPRBLK_FL 0x00000200
160 #define EXT4_NOCOMPR_FL 0x00000400
161 #define EXT4_ECOMPR_FL 0x00000800
162 
163 #define EXT4_INDEX_FL 0x00001000
164 #define EXT4_IMAGIC_FL 0x00002000
165 #define EXT4_JOURNAL_DATA_FL 0x00004000
166 #define EXT4_NOTAIL_FL 0x00008000
167 #define EXT4_DIRSYNC_FL 0x00010000
168 #define EXT4_TOPDIR_FL 0x00020000
169 #define EXT4_HUGE_FILE_FL 0x00040000
170 #define EXT4_EXTENTS_FL 0x00080000
171 #define EXT4_EA_INODE_FL 0x00200000
172 #define EXT4_EOFBLOCKS_FL 0x00400000
173 #define EXT4_RESERVED_FL 0x80000000
174 
175 #define EXT4_FL_USER_VISIBLE 0x004BDFFF
176 #define EXT4_FL_USER_MODIFIABLE 0x004B80FF
177 
178 #define EXT4_FL_INHERITED                                                                         \
179     (EXT4_SECRM_FL | EXT4_UNRM_FL | EXT4_COMPR_FL | EXT4_SYNC_FL | EXT4_IMMUTABLE_FL |            \
180      EXT4_APPEND_FL | EXT4_NODUMP_FL | EXT4_NOATIME_FL | EXT4_NOCOMPR_FL | EXT4_JOURNAL_DATA_FL | \
181      EXT4_NOTAIL_FL | EXT4_DIRSYNC_FL)
182 
183 #define EXT4_REG_FLMASK (~(EXT4_DIRSYNC_FL | EXT4_TOPDIR_FL))
184 
185 #define EXT4_OTHER_FLMASK (EXT4_NODUMP_FL | EXT4_NOATIME_FL)
186 
187 struct ext4_new_group_data {
188     __u32 group;
189     __u64 block_bitmap;
190     __u64 inode_bitmap;
191     __u64 inode_table;
192     __u32 blocks_count;
193     __u16 reserved_blocks;
194     __u16 unused;
195     __u32 free_blocks_count;
196 };
197 
198 #define EXT4_GET_BLOCKS_CREATE 0x0001
199 
200 #define EXT4_GET_BLOCKS_UNINIT_EXT 0x0002
201 #define EXT4_GET_BLOCKS_CREATE_UNINIT_EXT (EXT4_GET_BLOCKS_UNINIT_EXT | EXT4_GET_BLOCKS_CREATE)
202 
203 #define EXT4_GET_BLOCKS_DELALLOC_RESERVE 0x0004
204 
205 #define EXT4_GET_BLOCKS_PRE_IO 0x0008
206 #define EXT4_GET_BLOCKS_CONVERT 0x0010
207 #define EXT4_GET_BLOCKS_IO_CREATE_EXT (EXT4_GET_BLOCKS_PRE_IO | EXT4_GET_BLOCKS_CREATE_UNINIT_EXT)
208 
209 #define EXT4_GET_BLOCKS_IO_CONVERT_EXT (EXT4_GET_BLOCKS_CONVERT | EXT4_GET_BLOCKS_CREATE_UNINIT_EXT)
210 
211 #define EXT4_FREE_BLOCKS_METADATA 0x0001
212 #define EXT4_FREE_BLOCKS_FORGET 0x0002
213 #define EXT4_FREE_BLOCKS_VALIDATED 0x0004
214 
215 #define EXT4_IOC_GETFLAGS FS_IOC_GETFLAGS
216 #define EXT4_IOC_SETFLAGS FS_IOC_SETFLAGS
217 #define EXT4_IOC_GETVERSION _IOR('f', 3, long)
218 #define EXT4_IOC_SETVERSION _IOW('f', 4, long)
219 #define EXT4_IOC_GETVERSION_OLD FS_IOC_GETVERSION
220 #define EXT4_IOC_SETVERSION_OLD FS_IOC_SETVERSION
221 #define EXT4_IOC_GETRSVSZ _IOR('f', 5, long)
222 #define EXT4_IOC_SETRSVSZ _IOW('f', 6, long)
223 #define EXT4_IOC_GROUP_EXTEND _IOW('f', 7, unsigned long)
224 #define EXT4_IOC_GROUP_ADD _IOW('f', 8, struct ext4_new_group_input)
225 #define EXT4_IOC_MIGRATE _IO('f', 9)
226 
227 #define EXT4_IOC_ALLOC_DA_BLKS _IO('f', 12)
228 #define EXT4_IOC_MOVE_EXT _IOWR('f', 15, struct move_extent)
229 
230 #define EXT4_IOC32_GETFLAGS FS_IOC32_GETFLAGS
231 #define EXT4_IOC32_SETFLAGS FS_IOC32_SETFLAGS
232 #define EXT4_IOC32_GETVERSION _IOR('f', 3, int)
233 #define EXT4_IOC32_SETVERSION _IOW('f', 4, int)
234 #define EXT4_IOC32_GETRSVSZ _IOR('f', 5, int)
235 #define EXT4_IOC32_SETRSVSZ _IOW('f', 6, int)
236 #define EXT4_IOC32_GROUP_EXTEND _IOW('f', 7, unsigned int)
237 #define EXT4_IOC32_GETVERSION_OLD FS_IOC32_GETVERSION
238 #define EXT4_IOC32_SETVERSION_OLD FS_IOC32_SETVERSION
239 
240 #define EXT4_MAX_BLOCK_FILE_PHYS 0xFFFFFFFF
241 
242 struct ext4_inode {
243     __le16 i_mode;
244     __le16 i_uid;
245     __le32 i_size_lo;
246     __le32 i_atime;
247     __le32 i_ctime;
248     __le32 i_mtime;
249     __le32 i_dtime;
250     __le16 i_gid;
251     __le16 i_links_count;
252     __le32 i_blocks_lo;
253     __le32 i_flags;
254     union {
255         struct {
256             __le32 l_i_version;
257         } linux1;
258         struct {
259             __u32 h_i_translator;
260         } hurd1;
261         struct {
262             __u32 m_i_reserved1;
263         } masix1;
264     } osd1;
265     __le32 i_block[EXT4_N_BLOCKS];
266     __le32 i_generation;
267     __le32 i_file_acl_lo;
268     __le32 i_size_high;
269     __le32 i_obso_faddr;
270     union {
271         struct {
272             __le16 l_i_blocks_high;
273             __le16 l_i_file_acl_high;
274             __le16 l_i_uid_high;
275             __le16 l_i_gid_high;
276             __u32 l_i_reserved2;
277         } linux2;
278         struct {
279             __le16 h_i_reserved1;
280             __u16 h_i_mode_high;
281             __u16 h_i_uid_high;
282             __u16 h_i_gid_high;
283             __u32 h_i_author;
284         } hurd2;
285         struct {
286             __le16 h_i_reserved1;
287             __le16 m_i_file_acl_high;
288             __u32 m_i_reserved2[2];
289         } masix2;
290     } osd2;
291     __le16 i_extra_isize;
292     __le16 i_pad1;
293     __le32 i_ctime_extra;
294     __le32 i_mtime_extra;
295     __le32 i_atime_extra;
296     __le32 i_crtime;
297     __le32 i_crtime_extra;
298     __le32 i_version_hi;
299 };
300 
301 struct move_extent {
302     __u32 reserved;
303     __u32 donor_fd;
304     __u64 orig_start;
305     __u64 donor_start;
306     __u64 len;
307     __u64 moved_len;
308 };
309 
310 #define EXT4_EPOCH_BITS 2
311 #define EXT4_EPOCH_MASK ((1 << EXT4_EPOCH_BITS) - 1)
312 #define EXT4_NSEC_MASK (~0UL << EXT4_EPOCH_BITS)
313 
314 #define EXT4_FITS_IN_INODE(ext4_inode, einode, field)                          \
315     ((offsetof(typeof(*(ext4_inode)), field) + sizeof((ext4_inode)->field)) <= \
316      (EXT4_GOOD_OLD_INODE_SIZE + (einode)->i_extra_isize))
317 #define EXT4_INODE_SET_XTIME(xtime, inode, raw_inode)                             \
318     do {                                                                          \
319         (raw_inode)->xtime = cpu_to_le32((inode)->xtime.tv_sec);                  \
320         if (EXT4_FITS_IN_INODE(raw_inode, EXT4_I(inode), xtime##_extra))          \
321             (raw_inode)->xtime##_extra = ext4_encode_extra_time(&(inode)->xtime); \
322     } while (0)
323 #define EXT4_EINODE_SET_XTIME(xtime, einode, raw_inode)                            \
324     do {                                                                           \
325         if (EXT4_FITS_IN_INODE(raw_inode, einode, xtime))                          \
326             (raw_inode)->xtime = cpu_to_le32((einode)->xtime.tv_sec);              \
327         if (EXT4_FITS_IN_INODE(raw_inode, einode, xtime##_extra))                  \
328             (raw_inode)->xtime##_extra = ext4_encode_extra_time(&(einode)->xtime); \
329     } while (0)
330 #define EXT4_INODE_GET_XTIME(xtime, inode, raw_inode)                            \
331     do {                                                                         \
332         (inode)->xtime.tv_sec = (signed)le32_to_cpu((raw_inode)->xtime);         \
333         if (EXT4_FITS_IN_INODE(raw_inode, EXT4_I(inode), xtime##_extra))         \
334             ext4_decode_extra_time(&(inode)->xtime, (raw_inode)->xtime##_extra); \
335     } while (0)
336 
337 #define EXT4_EINODE_GET_XTIME(xtime, einode, raw_inode)                           \
338     do {                                                                          \
339         if (EXT4_FITS_IN_INODE(raw_inode, einode, xtime))                         \
340             (einode)->xtime.tv_sec = (signed)le32_to_cpu((raw_inode)->xtime);     \
341         if (EXT4_FITS_IN_INODE(raw_inode, einode, xtime##_extra))                 \
342             ext4_decode_extra_time(&(einode)->xtime, (raw_inode)->xtime##_extra); \
343     } while (0)
344 #define i_disk_version osd1.linux1.l_i_version
345 
346 #define i_reserved1 osd1.linux1.l_i_reserved1
347 #define i_file_acl_high osd2.linux2.l_i_file_acl_high
348 #define i_blocks_high osd2.linux2.l_i_blocks_high
349 #define i_uid_low i_uid
350 #define i_gid_low i_gid
351 #define i_uid_high osd2.linux2.l_i_uid_high
352 #define i_gid_high osd2.linux2.l_i_gid_high
353 #define i_reserved2 osd2.linux2.l_i_reserved2
354 
355 #define EXT4_VALID_FS 0x0001
356 #define EXT4_ERROR_FS 0x0002
357 #define EXT4_ORPHAN_FS 0x0004
358 
359 #define EXT2_FLAGS_SIGNED_HASH 0x0001
360 #define EXT2_FLAGS_UNSIGNED_HASH 0x0002
361 #define EXT2_FLAGS_TEST_FILESYS 0x0004
362 
363 #define EXT4_MOUNT_OLDALLOC 0x00002
364 #define EXT4_MOUNT_GRPID 0x00004
365 #define EXT4_MOUNT_DEBUG 0x00008
366 #define EXT4_MOUNT_ERRORS_CONT 0x00010
367 #define EXT4_MOUNT_ERRORS_RO 0x00020
368 #define EXT4_MOUNT_ERRORS_PANIC 0x00040
369 #define EXT4_MOUNT_MINIX_DF 0x00080
370 #define EXT4_MOUNT_NOLOAD 0x00100
371 #define EXT4_MOUNT_DATA_FLAGS 0x00C00
372 #define EXT4_MOUNT_JOURNAL_DATA 0x00400
373 #define EXT4_MOUNT_ORDERED_DATA 0x00800
374 #define EXT4_MOUNT_WRITEBACK_DATA 0x00C00
375 #define EXT4_MOUNT_UPDATE_JOURNAL 0x01000
376 #define EXT4_MOUNT_NO_UID32 0x02000
377 #define EXT4_MOUNT_XATTR_USER 0x04000
378 #define EXT4_MOUNT_POSIX_ACL 0x08000
379 #define EXT4_MOUNT_NO_AUTO_DA_ALLOC 0x10000
380 #define EXT4_MOUNT_BARRIER 0x20000
381 #define EXT4_MOUNT_NOBH 0x40000
382 #define EXT4_MOUNT_QUOTA 0x80000
383 #define EXT4_MOUNT_USRQUOTA 0x100000
384 #define EXT4_MOUNT_GRPQUOTA 0x200000
385 #define EXT4_MOUNT_DIOREAD_NOLOCK 0x400000
386 #define EXT4_MOUNT_JOURNAL_CHECKSUM 0x800000
387 #define EXT4_MOUNT_JOURNAL_ASYNC_COMMIT 0x1000000
388 #define EXT4_MOUNT_I_VERSION 0x2000000
389 #define EXT4_MOUNT_DELALLOC 0x8000000
390 #define EXT4_MOUNT_DATA_ERR_ABORT 0x10000000
391 #define EXT4_MOUNT_BLOCK_VALIDITY 0x20000000
392 #define EXT4_MOUNT_DISCARD 0x40000000
393 
394 #define clear_opt(o, opt) o &= ~EXT4_MOUNT_##opt
395 #define set_opt(o, opt) o |= EXT4_MOUNT_##opt
396 #define test_opt(sb, opt) (EXT4_SB(sb)->s_mount_opt & EXT4_MOUNT_##opt)
397 
398 #define ext4_set_bit ext2_set_bit
399 #define ext4_set_bit_atomic ext2_set_bit_atomic
400 #define ext4_clear_bit ext2_clear_bit
401 #define ext4_clear_bit_atomic ext2_clear_bit_atomic
402 #define ext4_test_bit ext2_test_bit
403 #define ext4_find_first_zero_bit ext2_find_first_zero_bit
404 #define ext4_find_next_zero_bit ext2_find_next_zero_bit
405 #define ext4_find_next_bit ext2_find_next_bit
406 
407 #define EXT4_DFL_MAX_MNT_COUNT 20
408 #define EXT4_DFL_CHECKINTERVAL 0
409 
410 #define EXT4_ERRORS_CONTINUE 1
411 #define EXT4_ERRORS_RO 2
412 #define EXT4_ERRORS_PANIC 3
413 #define EXT4_ERRORS_DEFAULT EXT4_ERRORS_CONTINUE
414 
415 struct ext4_super_block {
416     __le32 s_inodes_count;
417     __le32 s_blocks_count_lo;
418     __le32 s_r_blocks_count_lo;
419     __le32 s_free_blocks_count_lo;
420     __le32 s_free_inodes_count;
421     __le32 s_first_data_block;
422     __le32 s_log_block_size;
423     __le32 s_obso_log_frag_size;
424     __le32 s_blocks_per_group;
425     __le32 s_obso_frags_per_group;
426     __le32 s_inodes_per_group;
427     __le32 s_mtime;
428     __le32 s_wtime;
429     __le16 s_mnt_count;
430     __le16 s_max_mnt_count;
431     __le16 s_magic;
432     __le16 s_state;
433     __le16 s_errors;
434     __le16 s_minor_rev_level;
435     __le32 s_lastcheck;
436     __le32 s_checkinterval;
437     __le32 s_creator_os;
438     __le32 s_rev_level;
439     __le16 s_def_resuid;
440     __le16 s_def_resgid;
441 
442     __le32 s_first_ino;
443     __le16 s_inode_size;
444     __le16 s_block_group_nr;
445     __le32 s_feature_compat;
446     __le32 s_feature_incompat;
447     __le32 s_feature_ro_compat;
448     __u8 s_uuid[16];
449     char s_volume_name[16];
450     char s_last_mounted[64];
451     __le32 s_algorithm_usage_bitmap;
452 
453     __u8 s_prealloc_blocks;
454     __u8 s_prealloc_dir_blocks;
455     __le16 s_reserved_gdt_blocks;
456 
457     __u8 s_journal_uuid[16];
458     __le32 s_journal_inum;
459     __le32 s_journal_dev;
460     __le32 s_last_orphan;
461     __le32 s_hash_seed[4];
462     __u8 s_def_hash_version;
463     __u8 s_reserved_char_pad;
464     __le16 s_desc_size;
465     __le32 s_default_mount_opts;
466     __le32 s_first_meta_bg;
467     __le32 s_mkfs_time;
468     __le32 s_jnl_blocks[17];
469 
470     __le32 s_blocks_count_hi;
471     __le32 s_r_blocks_count_hi;
472     __le32 s_free_blocks_count_hi;
473     __le16 s_min_extra_isize;
474     __le16 s_want_extra_isize;
475     __le32 s_flags;
476     __le16 s_raid_stride;
477     __le16 s_mmp_interval;
478     __le64 s_mmp_block;
479     __le32 s_raid_stripe_width;
480     __u8 s_log_groups_per_flex;
481     __u8 s_reserved_char_pad2;
482     __le16 s_reserved_pad;
483     __le64 s_kbytes_written;
484     __u32 s_reserved[160];
485 };
486 
487 #define EXT4_SB(sb) (sb)
488 
489 #define NEXT_ORPHAN(inode) EXT4_I(inode)->i_dtime
490 
491 #define EXT4_OS_LINUX 0
492 #define EXT4_OS_HURD 1
493 #define EXT4_OS_MASIX 2
494 #define EXT4_OS_FREEBSD 3
495 #define EXT4_OS_LITES 4
496 
497 #define EXT4_GOOD_OLD_REV 0
498 #define EXT4_DYNAMIC_REV 1
499 
500 #define EXT4_CURRENT_REV EXT4_GOOD_OLD_REV
501 #define EXT4_MAX_SUPP_REV EXT4_DYNAMIC_REV
502 
503 #define EXT4_GOOD_OLD_INODE_SIZE 128
504 
505 #define EXT4_HAS_COMPAT_FEATURE(sb, mask) \
506     ((EXT4_SB(sb)->s_es->s_feature_compat & cpu_to_le32(mask)) != 0)
507 #define EXT4_HAS_RO_COMPAT_FEATURE(sb, mask) \
508     ((EXT4_SB(sb)->s_es->s_feature_ro_compat & cpu_to_le32(mask)) != 0)
509 #define EXT4_HAS_INCOMPAT_FEATURE(sb, mask) \
510     ((EXT4_SB(sb)->s_es->s_feature_incompat & cpu_to_le32(mask)) != 0)
511 #define EXT4_SET_COMPAT_FEATURE(sb, mask) EXT4_SB(sb)->s_es->s_feature_compat |= cpu_to_le32(mask)
512 #define EXT4_SET_RO_COMPAT_FEATURE(sb, mask) \
513     EXT4_SB(sb)->s_es->s_feature_ro_compat |= cpu_to_le32(mask)
514 #define EXT4_SET_INCOMPAT_FEATURE(sb, mask) \
515     EXT4_SB(sb)->s_es->s_feature_incompat |= cpu_to_le32(mask)
516 #define EXT4_CLEAR_COMPAT_FEATURE(sb, mask) \
517     EXT4_SB(sb)->s_es->s_feature_compat &= ~cpu_to_le32(mask)
518 #define EXT4_CLEAR_RO_COMPAT_FEATURE(sb, mask) \
519     EXT4_SB(sb)->s_es->s_feature_ro_compat &= ~cpu_to_le32(mask)
520 #define EXT4_CLEAR_INCOMPAT_FEATURE(sb, mask) \
521     EXT4_SB(sb)->s_es->s_feature_incompat &= ~cpu_to_le32(mask)
522 
523 #define EXT4_FEATURE_COMPAT_DIR_PREALLOC 0x0001
524 #define EXT4_FEATURE_COMPAT_IMAGIC_INODES 0x0002
525 #define EXT4_FEATURE_COMPAT_HAS_JOURNAL 0x0004
526 #define EXT4_FEATURE_COMPAT_EXT_ATTR 0x0008
527 #define EXT4_FEATURE_COMPAT_RESIZE_INODE 0x0010
528 #define EXT4_FEATURE_COMPAT_DIR_INDEX 0x0020
529 
530 #define EXT4_FEATURE_RO_COMPAT_SPARSE_SUPER 0x0001
531 #define EXT4_FEATURE_RO_COMPAT_LARGE_FILE 0x0002
532 #define EXT4_FEATURE_RO_COMPAT_BTREE_DIR 0x0004
533 #define EXT4_FEATURE_RO_COMPAT_HUGE_FILE 0x0008
534 #define EXT4_FEATURE_RO_COMPAT_GDT_CSUM 0x0010
535 #define EXT4_FEATURE_RO_COMPAT_DIR_NLINK 0x0020
536 #define EXT4_FEATURE_RO_COMPAT_EXTRA_ISIZE 0x0040
537 #define EXT4_FEATURE_RO_COMPAT_HAS_SNAPSHOT 0x0080
538 #define EXT4_FEATURE_RO_COMPAT_QUOTA 0x0100
539 #define EXT4_FEATURE_RO_COMPAT_BIGALLOC 0x0200
540 #define EXT4_FEATURE_RO_COMPAT_METADATA_CSUM 0x0400
541 #define EXT4_FEATURE_RO_COMPAT_SHARED_BLOCKS 0x4000
542 #define EXT4_FEATURE_RO_COMPAT_VERITY 0x8000
543 
544 #define EXT4_FEATURE_INCOMPAT_COMPRESSION 0x0001
545 #define EXT4_FEATURE_INCOMPAT_FILETYPE 0x0002
546 #define EXT4_FEATURE_INCOMPAT_RECOVER 0x0004
547 #define EXT4_FEATURE_INCOMPAT_JOURNAL_DEV 0x0008
548 #define EXT4_FEATURE_INCOMPAT_META_BG 0x0010
549 #define EXT4_FEATURE_INCOMPAT_EXTENTS 0x0040
550 #define EXT4_FEATURE_INCOMPAT_64BIT 0x0080
551 #define EXT4_FEATURE_INCOMPAT_MMP 0x0100
552 #define EXT4_FEATURE_INCOMPAT_FLEX_BG 0x0200
553 #define EXT4_FEATURE_INCOMPAT_EA_INODE 0x0400
554 #define EXT4_FEATURE_INCOMPAT_DIRDATA 0x1000
555 #define EXT4_FEATURE_INCOMPAT_ENCRYPT 0x10000
556 #define EXT4_FEATURE_INCOMPAT_CASEFOLD 0x20000
557 
558 #define EXT4_FEATURE_COMPAT_SUPP EXT2_FEATURE_COMPAT_EXT_ATTR
559 #define EXT4_FEATURE_INCOMPAT_SUPP                                                                 \
560     (EXT4_FEATURE_INCOMPAT_FILETYPE | EXT4_FEATURE_INCOMPAT_RECOVER |                              \
561      EXT4_FEATURE_INCOMPAT_META_BG | EXT4_FEATURE_INCOMPAT_EXTENTS | EXT4_FEATURE_INCOMPAT_64BIT | \
562      EXT4_FEATURE_INCOMPAT_FLEX_BG)
563 #define EXT4_FEATURE_RO_COMPAT_SUPP                                            \
564     (EXT4_FEATURE_RO_COMPAT_SPARSE_SUPER | EXT4_FEATURE_RO_COMPAT_LARGE_FILE | \
565      EXT4_FEATURE_RO_COMPAT_GDT_CSUM | EXT4_FEATURE_RO_COMPAT_DIR_NLINK |      \
566      EXT4_FEATURE_RO_COMPAT_EXTRA_ISIZE | EXT4_FEATURE_RO_COMPAT_BTREE_DIR |   \
567      EXT4_FEATURE_RO_COMPAT_HUGE_FILE)
568 
569 #define EXT4_DEF_RESUID 0
570 #define EXT4_DEF_RESGID 0
571 
572 #define EXT4_DEF_INODE_READAHEAD_BLKS 32
573 
574 #define EXT4_DEFM_DEBUG 0x0001
575 #define EXT4_DEFM_BSDGROUPS 0x0002
576 #define EXT4_DEFM_XATTR_USER 0x0004
577 #define EXT4_DEFM_ACL 0x0008
578 #define EXT4_DEFM_UID16 0x0010
579 #define EXT4_DEFM_JMODE 0x0060
580 #define EXT4_DEFM_JMODE_DATA 0x0020
581 #define EXT4_DEFM_JMODE_ORDERED 0x0040
582 #define EXT4_DEFM_JMODE_WBACK 0x0060
583 
584 #define EXT4_DEF_MIN_BATCH_TIME 0
585 #define EXT4_DEF_MAX_BATCH_TIME 15000
586 
587 #define EXT4_FLEX_SIZE_DIR_ALLOC_SCHEME 4
588 
589 #define EXT4_NAME_LEN 255
590 
591 struct ext4_dir_entry {
592     __le32 inode;
593     __le16 rec_len;
594     __le16 name_len;
595     char name[EXT4_NAME_LEN];
596 };
597 
598 struct ext4_dir_entry_2 {
599     __le32 inode;
600     __le16 rec_len;
601     __u8 name_len;
602     __u8 file_type;
603     char name[EXT4_NAME_LEN];
604 };
605 
606 #define EXT4_FT_UNKNOWN 0
607 #define EXT4_FT_REG_FILE 1
608 #define EXT4_FT_DIR 2
609 #define EXT4_FT_CHRDEV 3
610 #define EXT4_FT_BLKDEV 4
611 #define EXT4_FT_FIFO 5
612 #define EXT4_FT_SOCK 6
613 #define EXT4_FT_SYMLINK 7
614 
615 #define EXT4_FT_MAX 8
616 
617 #define EXT4_DIR_PAD 4
618 #define EXT4_DIR_ROUND (EXT4_DIR_PAD - 1)
619 #define EXT4_DIR_REC_LEN(name_len) (((name_len) + 8 + EXT4_DIR_ROUND) & ~EXT4_DIR_ROUND)
620 #define EXT4_MAX_REC_LEN ((1 << 16) - 1)
621 
622 #define is_dx(dir)                                                          \
623     (EXT4_HAS_COMPAT_FEATURE((dir)->i_sb, EXT4_FEATURE_COMPAT_DIR_INDEX) && \
624      (EXT4_I(dir)->i_flags & EXT4_INDEX_FL))
625 #define EXT4_DIR_LINK_MAX(dir) (!is_dx(dir) && (dir)->i_nlink >= EXT4_LINK_MAX)
626 #define EXT4_DIR_LINK_EMPTY(dir) ((dir)->i_nlink == 2 || (dir)->i_nlink == 1)
627 
628 #define DX_HASH_LEGACY 0
629 #define DX_HASH_HALF_MD4 1
630 #define DX_HASH_TEA 2
631 #define DX_HASH_LEGACY_UNSIGNED 3
632 #define DX_HASH_HALF_MD4_UNSIGNED 4
633 #define DX_HASH_TEA_UNSIGNED 5
634 
635 #endif
636