avoid using libc's internal sys/cdefs.h
[project/make_ext4fs.git] / ext4.h
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 #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)
310 #define i_disk_version osd1.linux1.l_i_version
311
312 #define i_reserved1 osd1.linux1.l_i_reserved1
313 #define i_file_acl_high osd2.linux2.l_i_file_acl_high
314 #define i_blocks_high osd2.linux2.l_i_blocks_high
315 #define i_uid_low i_uid
316 #define i_gid_low i_gid
317 #define i_uid_high osd2.linux2.l_i_uid_high
318 #define i_gid_high osd2.linux2.l_i_gid_high
319 #define i_reserved2 osd2.linux2.l_i_reserved2
320
321 #define EXT4_VALID_FS 0x0001  
322 #define EXT4_ERROR_FS 0x0002  
323 #define EXT4_ORPHAN_FS 0x0004  
324
325 #define EXT2_FLAGS_SIGNED_HASH 0x0001  
326 #define EXT2_FLAGS_UNSIGNED_HASH 0x0002  
327 #define EXT2_FLAGS_TEST_FILESYS 0x0004  
328
329 #define EXT4_MOUNT_OLDALLOC 0x00002  
330 #define EXT4_MOUNT_GRPID 0x00004  
331 #define EXT4_MOUNT_DEBUG 0x00008  
332 #define EXT4_MOUNT_ERRORS_CONT 0x00010  
333 #define EXT4_MOUNT_ERRORS_RO 0x00020  
334 #define EXT4_MOUNT_ERRORS_PANIC 0x00040  
335 #define EXT4_MOUNT_MINIX_DF 0x00080  
336 #define EXT4_MOUNT_NOLOAD 0x00100  
337 #define EXT4_MOUNT_DATA_FLAGS 0x00C00  
338 #define EXT4_MOUNT_JOURNAL_DATA 0x00400  
339 #define EXT4_MOUNT_ORDERED_DATA 0x00800  
340 #define EXT4_MOUNT_WRITEBACK_DATA 0x00C00  
341 #define EXT4_MOUNT_UPDATE_JOURNAL 0x01000  
342 #define EXT4_MOUNT_NO_UID32 0x02000  
343 #define EXT4_MOUNT_XATTR_USER 0x04000  
344 #define EXT4_MOUNT_POSIX_ACL 0x08000  
345 #define EXT4_MOUNT_NO_AUTO_DA_ALLOC 0x10000  
346 #define EXT4_MOUNT_BARRIER 0x20000  
347 #define EXT4_MOUNT_NOBH 0x40000  
348 #define EXT4_MOUNT_QUOTA 0x80000  
349 #define EXT4_MOUNT_USRQUOTA 0x100000  
350 #define EXT4_MOUNT_GRPQUOTA 0x200000  
351 #define EXT4_MOUNT_DIOREAD_NOLOCK 0x400000  
352 #define EXT4_MOUNT_JOURNAL_CHECKSUM 0x800000  
353 #define EXT4_MOUNT_JOURNAL_ASYNC_COMMIT 0x1000000  
354 #define EXT4_MOUNT_I_VERSION 0x2000000  
355 #define EXT4_MOUNT_DELALLOC 0x8000000  
356 #define EXT4_MOUNT_DATA_ERR_ABORT 0x10000000  
357 #define EXT4_MOUNT_BLOCK_VALIDITY 0x20000000  
358 #define EXT4_MOUNT_DISCARD 0x40000000  
359
360 #define clear_opt(o, opt) o &= ~EXT4_MOUNT_##opt
361 #define set_opt(o, opt) o |= EXT4_MOUNT_##opt
362 #define test_opt(sb, opt) (EXT4_SB(sb)->s_mount_opt &   EXT4_MOUNT_##opt)
363
364 #define ext4_set_bit ext2_set_bit
365 #define ext4_set_bit_atomic ext2_set_bit_atomic
366 #define ext4_clear_bit ext2_clear_bit
367 #define ext4_clear_bit_atomic ext2_clear_bit_atomic
368 #define ext4_test_bit ext2_test_bit
369 #define ext4_find_first_zero_bit ext2_find_first_zero_bit
370 #define ext4_find_next_zero_bit ext2_find_next_zero_bit
371 #define ext4_find_next_bit ext2_find_next_bit
372
373 #define EXT4_DFL_MAX_MNT_COUNT 20  
374 #define EXT4_DFL_CHECKINTERVAL 0  
375
376 #define EXT4_ERRORS_CONTINUE 1  
377 #define EXT4_ERRORS_RO 2  
378 #define EXT4_ERRORS_PANIC 3  
379 #define EXT4_ERRORS_DEFAULT EXT4_ERRORS_CONTINUE
380
381 struct ext4_super_block {
382   __le32 s_inodes_count;
383  __le32 s_blocks_count_lo;
384  __le32 s_r_blocks_count_lo;
385  __le32 s_free_blocks_count_lo;
386   __le32 s_free_inodes_count;
387  __le32 s_first_data_block;
388  __le32 s_log_block_size;
389  __le32 s_obso_log_frag_size;
390   __le32 s_blocks_per_group;
391  __le32 s_obso_frags_per_group;
392  __le32 s_inodes_per_group;
393  __le32 s_mtime;
394   __le32 s_wtime;
395  __le16 s_mnt_count;
396  __le16 s_max_mnt_count;
397  __le16 s_magic;
398  __le16 s_state;
399  __le16 s_errors;
400  __le16 s_minor_rev_level;
401   __le32 s_lastcheck;
402  __le32 s_checkinterval;
403  __le32 s_creator_os;
404  __le32 s_rev_level;
405   __le16 s_def_resuid;
406  __le16 s_def_resgid;
407
408  __le32 s_first_ino;
409  __le16 s_inode_size;
410  __le16 s_block_group_nr;
411  __le32 s_feature_compat;
412   __le32 s_feature_incompat;
413  __le32 s_feature_ro_compat;
414   __u8 s_uuid[16];
415   char s_volume_name[16];
416   char s_last_mounted[64];
417   __le32 s_algorithm_usage_bitmap;
418
419  __u8 s_prealloc_blocks;
420  __u8 s_prealloc_dir_blocks;
421  __le16 s_reserved_gdt_blocks;
422
423   __u8 s_journal_uuid[16];
424   __le32 s_journal_inum;
425  __le32 s_journal_dev;
426  __le32 s_last_orphan;
427  __le32 s_hash_seed[4];
428  __u8 s_def_hash_version;
429  __u8 s_reserved_char_pad;
430  __le16 s_desc_size;
431   __le32 s_default_mount_opts;
432  __le32 s_first_meta_bg;
433  __le32 s_mkfs_time;
434  __le32 s_jnl_blocks[17];
435
436   __le32 s_blocks_count_hi;
437  __le32 s_r_blocks_count_hi;
438  __le32 s_free_blocks_count_hi;
439  __le16 s_min_extra_isize;
440  __le16 s_want_extra_isize;
441  __le32 s_flags;
442  __le16 s_raid_stride;
443  __le16 s_mmp_interval;
444  __le64 s_mmp_block;
445  __le32 s_raid_stripe_width;
446  __u8 s_log_groups_per_flex;
447  __u8 s_reserved_char_pad2;
448  __le16 s_reserved_pad;
449  __le64 s_kbytes_written;
450  __u32 s_reserved[160];
451 };
452
453 #define EXT4_SB(sb) (sb)
454
455 #define NEXT_ORPHAN(inode) EXT4_I(inode)->i_dtime
456
457 #define EXT4_OS_LINUX 0
458 #define EXT4_OS_HURD 1
459 #define EXT4_OS_MASIX 2
460 #define EXT4_OS_FREEBSD 3
461 #define EXT4_OS_LITES 4
462
463 #define EXT4_GOOD_OLD_REV 0  
464 #define EXT4_DYNAMIC_REV 1  
465
466 #define EXT4_CURRENT_REV EXT4_GOOD_OLD_REV
467 #define EXT4_MAX_SUPP_REV EXT4_DYNAMIC_REV
468
469 #define EXT4_GOOD_OLD_INODE_SIZE 128
470
471 #define EXT4_HAS_COMPAT_FEATURE(sb,mask)   ((EXT4_SB(sb)->s_es->s_feature_compat & cpu_to_le32(mask)) != 0)
472 #define EXT4_HAS_RO_COMPAT_FEATURE(sb,mask)   ((EXT4_SB(sb)->s_es->s_feature_ro_compat & cpu_to_le32(mask)) != 0)
473 #define EXT4_HAS_INCOMPAT_FEATURE(sb,mask)   ((EXT4_SB(sb)->s_es->s_feature_incompat & cpu_to_le32(mask)) != 0)
474 #define EXT4_SET_COMPAT_FEATURE(sb,mask)   EXT4_SB(sb)->s_es->s_feature_compat |= cpu_to_le32(mask)
475 #define EXT4_SET_RO_COMPAT_FEATURE(sb,mask)   EXT4_SB(sb)->s_es->s_feature_ro_compat |= cpu_to_le32(mask)
476 #define EXT4_SET_INCOMPAT_FEATURE(sb,mask)   EXT4_SB(sb)->s_es->s_feature_incompat |= cpu_to_le32(mask)
477 #define EXT4_CLEAR_COMPAT_FEATURE(sb,mask)   EXT4_SB(sb)->s_es->s_feature_compat &= ~cpu_to_le32(mask)
478 #define EXT4_CLEAR_RO_COMPAT_FEATURE(sb,mask)   EXT4_SB(sb)->s_es->s_feature_ro_compat &= ~cpu_to_le32(mask)
479 #define EXT4_CLEAR_INCOMPAT_FEATURE(sb,mask)   EXT4_SB(sb)->s_es->s_feature_incompat &= ~cpu_to_le32(mask)
480
481 #define EXT4_FEATURE_COMPAT_DIR_PREALLOC 0x0001
482 #define EXT4_FEATURE_COMPAT_IMAGIC_INODES 0x0002
483 #define EXT4_FEATURE_COMPAT_HAS_JOURNAL 0x0004
484 #define EXT4_FEATURE_COMPAT_EXT_ATTR 0x0008
485 #define EXT4_FEATURE_COMPAT_RESIZE_INODE 0x0010
486 #define EXT4_FEATURE_COMPAT_DIR_INDEX 0x0020
487
488 #define EXT4_FEATURE_RO_COMPAT_SPARSE_SUPER 0x0001
489 #define EXT4_FEATURE_RO_COMPAT_LARGE_FILE 0x0002
490 #define EXT4_FEATURE_RO_COMPAT_BTREE_DIR 0x0004
491 #define EXT4_FEATURE_RO_COMPAT_HUGE_FILE 0x0008
492 #define EXT4_FEATURE_RO_COMPAT_GDT_CSUM 0x0010
493 #define EXT4_FEATURE_RO_COMPAT_DIR_NLINK 0x0020
494 #define EXT4_FEATURE_RO_COMPAT_EXTRA_ISIZE 0x0040
495
496 #define EXT4_FEATURE_INCOMPAT_COMPRESSION 0x0001
497 #define EXT4_FEATURE_INCOMPAT_FILETYPE 0x0002
498 #define EXT4_FEATURE_INCOMPAT_RECOVER 0x0004  
499 #define EXT4_FEATURE_INCOMPAT_JOURNAL_DEV 0x0008  
500 #define EXT4_FEATURE_INCOMPAT_META_BG 0x0010
501 #define EXT4_FEATURE_INCOMPAT_EXTENTS 0x0040  
502 #define EXT4_FEATURE_INCOMPAT_64BIT 0x0080
503 #define EXT4_FEATURE_INCOMPAT_MMP 0x0100
504 #define EXT4_FEATURE_INCOMPAT_FLEX_BG 0x0200
505 #define EXT4_FEATURE_INCOMPAT_EA_INODE 0x0400  
506 #define EXT4_FEATURE_INCOMPAT_DIRDATA 0x1000  
507
508 #define EXT4_FEATURE_COMPAT_SUPP EXT2_FEATURE_COMPAT_EXT_ATTR
509 #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)
510 #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)
511
512 #define EXT4_DEF_RESUID 0
513 #define EXT4_DEF_RESGID 0
514
515 #define EXT4_DEF_INODE_READAHEAD_BLKS 32
516
517 #define EXT4_DEFM_DEBUG 0x0001
518 #define EXT4_DEFM_BSDGROUPS 0x0002
519 #define EXT4_DEFM_XATTR_USER 0x0004
520 #define EXT4_DEFM_ACL 0x0008
521 #define EXT4_DEFM_UID16 0x0010
522 #define EXT4_DEFM_JMODE 0x0060
523 #define EXT4_DEFM_JMODE_DATA 0x0020
524 #define EXT4_DEFM_JMODE_ORDERED 0x0040
525 #define EXT4_DEFM_JMODE_WBACK 0x0060
526
527 #define EXT4_DEF_MIN_BATCH_TIME 0
528 #define EXT4_DEF_MAX_BATCH_TIME 15000  
529
530 #define EXT4_FLEX_SIZE_DIR_ALLOC_SCHEME 4
531
532 #define EXT4_NAME_LEN 255
533
534 struct ext4_dir_entry {
535  __le32 inode;
536  __le16 rec_len;
537  __le16 name_len;
538  char name[EXT4_NAME_LEN];
539 };
540
541 struct ext4_dir_entry_2 {
542  __le32 inode;
543  __le16 rec_len;
544  __u8 name_len;
545  __u8 file_type;
546  char name[EXT4_NAME_LEN];
547 };
548
549 #define EXT4_FT_UNKNOWN 0
550 #define EXT4_FT_REG_FILE 1
551 #define EXT4_FT_DIR 2
552 #define EXT4_FT_CHRDEV 3
553 #define EXT4_FT_BLKDEV 4
554 #define EXT4_FT_FIFO 5
555 #define EXT4_FT_SOCK 6
556 #define EXT4_FT_SYMLINK 7
557
558 #define EXT4_FT_MAX 8
559
560 #define EXT4_DIR_PAD 4
561 #define EXT4_DIR_ROUND (EXT4_DIR_PAD - 1)
562 #define EXT4_DIR_REC_LEN(name_len) (((name_len) + 8 + EXT4_DIR_ROUND) &   ~EXT4_DIR_ROUND)
563 #define EXT4_MAX_REC_LEN ((1<<16)-1)
564
565 #define is_dx(dir) (EXT4_HAS_COMPAT_FEATURE(dir->i_sb,   EXT4_FEATURE_COMPAT_DIR_INDEX) &&   (EXT4_I(dir)->i_flags & EXT4_INDEX_FL))
566 #define EXT4_DIR_LINK_MAX(dir) (!is_dx(dir) && (dir)->i_nlink >= EXT4_LINK_MAX)
567 #define EXT4_DIR_LINK_EMPTY(dir) ((dir)->i_nlink == 2 || (dir)->i_nlink == 1)
568
569 #define DX_HASH_LEGACY 0
570 #define DX_HASH_HALF_MD4 1
571 #define DX_HASH_TEA 2
572 #define DX_HASH_LEGACY_UNSIGNED 3
573 #define DX_HASH_HALF_MD4_UNSIGNED 4
574 #define DX_HASH_TEA_UNSIGNED 5
575
576 #endif
577