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