Refactor header files dependencies.
[lwext4.git] / include / ext4_types.h
1 /*
2  * Copyright (c) 2013 Grzegorz Kostka (kostka.grzegorz@gmail.com)
3  *
4  *
5  * HelenOS:
6  * Copyright (c) 2012 Martin Sucha
7  * Copyright (c) 2012 Frantisek Princ
8  * All rights reserved.
9  *
10  * Redistribution and use in source and binary forms, with or without
11  * modification, are permitted provided that the following conditions
12  * are met:
13  *
14  * - Redistributions of source code must retain the above copyright
15  *   notice, this list of conditions and the following disclaimer.
16  * - Redistributions in binary form must reproduce the above copyright
17  *   notice, this list of conditions and the following disclaimer in the
18  *   documentation and/or other materials provided with the distribution.
19  * - The name of the author may not be used to endorse or promote products
20  *   derived from this software without specific prior written permission.
21  *
22  * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
23  * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
24  * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
25  * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
26  * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
27  * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
28  * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
29  * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
30  * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
31  * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
32  */
33
34 /** @addtogroup lwext4
35  * @{
36  */
37 /**
38  * @file  ext4_types.h
39  * @brief Ext4 data structure definitions.
40  */
41
42 #ifndef EXT4_TYPES_H_
43 #define EXT4_TYPES_H_
44
45 #ifdef __cplusplus
46 extern "C" {
47 #endif
48
49 #include "ext4_config.h"
50 #include "ext4_blockdev.h"
51 #include "misc/tree.h"
52
53 #include <stddef.h>
54 #include <stdint.h>
55
56 /*
57  * Types of blocks.
58  */
59 typedef uint32_t ext4_lblk_t;
60 typedef uint64_t ext4_fsblk_t;
61
62
63 #define EXT4_CHECKSUM_CRC32C 1
64
65 #define UUID_SIZE 16
66
67 #pragma pack(push, 1)
68
69 /*
70  * Structure of the super block
71  */
72 struct ext4_sblock {
73         uint32_t inodes_count;             /* I-nodes count */
74         uint32_t blocks_count_lo;         /* Blocks count */
75         uint32_t reserved_blocks_count_lo; /* Reserved blocks count */
76         uint32_t free_blocks_count_lo;     /* Free blocks count */
77         uint32_t free_inodes_count;     /* Free inodes count */
78         uint32_t first_data_block;       /* First Data Block */
79         uint32_t log_block_size;           /* Block size */
80         uint32_t log_cluster_size;       /* Obsoleted fragment size */
81         uint32_t blocks_per_group;       /* Number of blocks per group */
82         uint32_t frags_per_group;         /* Obsoleted fragments per group */
83         uint32_t inodes_per_group;       /* Number of inodes per group */
84         uint32_t mount_time;               /* Mount time */
85         uint32_t write_time;               /* Write time */
86         uint16_t mount_count;              /* Mount count */
87         uint16_t max_mount_count;         /* Maximal mount count */
88         uint16_t magic;                    /* Magic signature */
89         uint16_t state;                    /* File system state */
90         uint16_t errors;                   /* Behavior when detecting errors */
91         uint16_t minor_rev_level;         /* Minor revision level */
92         uint32_t last_check_time;         /* Time of last check */
93         uint32_t check_interval;           /* Maximum time between checks */
94         uint32_t creator_os;               /* Creator OS */
95         uint32_t rev_level;                /* Revision level */
96         uint16_t def_resuid;               /* Default uid for reserved blocks */
97         uint16_t def_resgid;               /* Default gid for reserved blocks */
98
99         /* Fields for EXT4_DYNAMIC_REV superblocks only. */
100         uint32_t first_inode;    /* First non-reserved inode */
101         uint16_t inode_size;      /* Size of inode structure */
102         uint16_t block_group_index;   /* Block group index of this superblock */
103         uint32_t features_compatible; /* Compatible feature set */
104         uint32_t features_incompatible;  /* Incompatible feature set */
105         uint32_t features_read_only;     /* Readonly-compatible feature set */
106         uint8_t uuid[UUID_SIZE];                 /* 128-bit uuid for volume */
107         char volume_name[16];            /* Volume name */
108         char last_mounted[64];           /* Directory where last mounted */
109         uint32_t algorithm_usage_bitmap; /* For compression */
110
111         /*
112          * Performance hints. Directory preallocation should only
113          * happen if the EXT4_FEATURE_COMPAT_DIR_PREALLOC flag is on.
114          */
115         uint8_t s_prealloc_blocks; /* Number of blocks to try to preallocate */
116         uint8_t s_prealloc_dir_blocks;  /* Number to preallocate for dirs */
117         uint16_t s_reserved_gdt_blocks; /* Per group desc for online growth */
118
119         /*
120          * Journaling support valid if EXT4_FEATURE_COMPAT_HAS_JOURNAL set.
121          */
122         uint8_t journal_uuid[UUID_SIZE];      /* UUID of journal superblock */
123         uint32_t journal_inode_number; /* Inode number of journal file */
124         uint32_t journal_dev;     /* Device number of journal file */
125         uint32_t last_orphan;     /* Head of list of inodes to delete */
126         uint32_t hash_seed[4];   /* HTREE hash seed */
127         uint8_t default_hash_version;  /* Default hash version to use */
128         uint8_t journal_backup_type;
129         uint16_t desc_size;       /* Size of group descriptor */
130         uint32_t default_mount_opts; /* Default mount options */
131         uint32_t first_meta_bg;      /* First metablock block group */
132         uint32_t mkfs_time;       /* When the filesystem was created */
133         uint32_t journal_blocks[17]; /* Backup of the journal inode */
134
135         /* 64bit support valid if EXT4_FEATURE_COMPAT_64BIT */
136         uint32_t blocks_count_hi;         /* Blocks count */
137         uint32_t reserved_blocks_count_hi; /* Reserved blocks count */
138         uint32_t free_blocks_count_hi;     /* Free blocks count */
139         uint16_t min_extra_isize;    /* All inodes have at least # bytes */
140         uint16_t want_extra_isize;   /* New inodes should reserve # bytes */
141         uint32_t flags;              /* Miscellaneous flags */
142         uint16_t raid_stride;   /* RAID stride */
143         uint16_t mmp_interval;       /* # seconds to wait in MMP checking */
144         uint64_t mmp_block;       /* Block for multi-mount protection */
145         uint32_t raid_stripe_width;  /* Blocks on all data disks (N * stride) */
146         uint8_t log_groups_per_flex; /* FLEX_BG group size */
147         uint8_t checksum_type;
148         uint16_t reserved_pad;
149         uint64_t kbytes_written; /* Number of lifetime kilobytes written */
150         uint32_t snapshot_inum;  /* I-node number of active snapshot */
151         uint32_t snapshot_id;    /* Sequential ID of active snapshot */
152         uint64_t
153             snapshot_r_blocks_count; /* Reserved blocks for active snapshot's
154                                         future use */
155         uint32_t
156             snapshot_list; /* I-node number of the head of the on-disk snapshot
157                               list */
158         uint32_t error_count;    /* Number of file system errors */
159         uint32_t first_error_time;    /* First time an error happened */
160         uint32_t first_error_ino;     /* I-node involved in first error */
161         uint64_t first_error_block;   /* Block involved of first error */
162         uint8_t first_error_func[32]; /* Function where the error happened */
163         uint32_t first_error_line;    /* Line number where error happened */
164         uint32_t last_error_time;     /* Most recent time of an error */
165         uint32_t last_error_ino;      /* I-node involved in last error */
166         uint32_t last_error_line;     /* Line number where error happened */
167         uint64_t last_error_block;    /* Block involved of last error */
168         uint8_t last_error_func[32];  /* Function where the error happened */
169         uint8_t mount_opts[64];
170         uint32_t usr_quota_inum;        /* inode for tracking user quota */
171         uint32_t grp_quota_inum;        /* inode for tracking group quota */
172         uint32_t overhead_clusters;     /* overhead blocks/clusters in fs */
173         uint32_t backup_bgs[2]; /* groups with sparse_super2 SBs */
174         uint8_t  encrypt_algos[4];      /* Encryption algorithms in use  */
175         uint8_t  encrypt_pw_salt[16];   /* Salt used for string2key algorithm */
176         uint32_t lpf_ino;               /* Location of the lost+found inode */
177         uint32_t padding[100];  /* Padding to the end of the block */
178         uint32_t checksum;              /* crc32c(superblock) */
179 };
180
181 #pragma pack(pop)
182
183 #define EXT4_SUPERBLOCK_MAGIC 0xEF53
184 #define EXT4_SUPERBLOCK_SIZE 1024
185 #define EXT4_SUPERBLOCK_OFFSET 1024
186
187 #define EXT4_SUPERBLOCK_OS_LINUX 0
188 #define EXT4_SUPERBLOCK_OS_HURD 1
189
190 /*
191  * Misc. filesystem flags
192  */
193 #define EXT4_SUPERBLOCK_FLAGS_SIGNED_HASH 0x0001
194 #define EXT4_SUPERBLOCK_FLAGS_UNSIGNED_HASH 0x0002
195 #define EXT4_SUPERBLOCK_FLAGS_TEST_FILESYS 0x0004
196 /*
197  * Filesystem states
198  */
199 #define EXT4_SUPERBLOCK_STATE_VALID_FS 0x0001  /* Unmounted cleanly */
200 #define EXT4_SUPERBLOCK_STATE_ERROR_FS 0x0002  /* Errors detected */
201 #define EXT4_SUPERBLOCK_STATE_ORPHAN_FS 0x0004 /* Orphans being recovered */
202
203 /*
204  * Behaviour when errors detected
205  */
206 #define EXT4_SUPERBLOCK_ERRORS_CONTINUE 1 /* Continue execution */
207 #define EXT4_SUPERBLOCK_ERRORS_RO 2       /* Remount fs read-only */
208 #define EXT4_SUPERBLOCK_ERRORS_PANIC 3    /* Panic */
209 #define EXT4_SUPERBLOCK_ERRORS_DEFAULT EXT4_ERRORS_CONTINUE
210
211 /*
212  * Compatible features
213  */
214 #define EXT4_FCOM_DIR_PREALLOC 0x0001
215 #define EXT4_FCOM_IMAGIC_INODES 0x0002
216 #define EXT4_FCOM_HAS_JOURNAL 0x0004
217 #define EXT4_FCOM_EXT_ATTR 0x0008
218 #define EXT4_FCOM_RESIZE_INODE 0x0010
219 #define EXT4_FCOM_DIR_INDEX 0x0020
220
221 /*
222  * Read-only compatible features
223  */
224 #define EXT4_FRO_COM_SPARSE_SUPER 0x0001
225 #define EXT4_FRO_COM_LARGE_FILE 0x0002
226 #define EXT4_FRO_COM_BTREE_DIR 0x0004
227 #define EXT4_FRO_COM_HUGE_FILE 0x0008
228 #define EXT4_FRO_COM_GDT_CSUM 0x0010
229 #define EXT4_FRO_COM_DIR_NLINK 0x0020
230 #define EXT4_FRO_COM_EXTRA_ISIZE 0x0040
231 #define EXT4_FRO_COM_QUOTA 0x0100
232 #define EXT4_FRO_COM_BIGALLOC 0x0200
233 #define EXT4_FRO_COM_METADATA_CSUM 0x0400
234
235 /*
236  * Incompatible features
237  */
238 #define EXT4_FINCOM_COMPRESSION 0x0001
239 #define EXT4_FINCOM_FILETYPE 0x0002
240 #define EXT4_FINCOM_RECOVER 0x0004     /* Needs recovery */
241 #define EXT4_FINCOM_JOURNAL_DEV 0x0008 /* Journal device */
242 #define EXT4_FINCOM_META_BG 0x0010
243 #define EXT4_FINCOM_EXTENTS 0x0040 /* extents support */
244 #define EXT4_FINCOM_64BIT 0x0080
245 #define EXT4_FINCOM_MMP 0x0100
246 #define EXT4_FINCOM_FLEX_BG 0x0200
247 #define EXT4_FINCOM_EA_INODE 0x0400      /* EA in inode */
248 #define EXT4_FINCOM_DIRDATA 0x1000        /* data in dirent */
249 #define EXT4_FINCOM_BG_USE_META_CSUM 0x2000 /* use crc32c for bg */
250 #define EXT4_FINCOM_LARGEDIR 0x4000      /* >2GB or 3-lvl htree */
251 #define EXT4_FINCOM_INLINE_DATA 0x8000      /* data in inode */
252
253 /*
254  * EXT2 supported feature set
255  */
256 #define EXT2_SUPPORTED_FCOM 0x0000
257
258 #define EXT2_SUPPORTED_FINCOM                                   \
259         (EXT4_FINCOM_FILETYPE | EXT4_FINCOM_META_BG)
260
261 #define EXT2_SUPPORTED_FRO_COM                                  \
262         (EXT4_FRO_COM_SPARSE_SUPER |                            \
263          EXT4_FRO_COM_LARGE_FILE)
264
265 /*
266  * EXT3 supported feature set
267  */
268 #define EXT3_SUPPORTED_FCOM (EXT4_FCOM_DIR_INDEX)
269
270 #define EXT3_SUPPORTED_FINCOM                                 \
271         (EXT4_FINCOM_FILETYPE | EXT4_FINCOM_META_BG)
272
273 #define EXT3_SUPPORTED_FRO_COM                                \
274         (EXT4_FRO_COM_SPARSE_SUPER | EXT4_FRO_COM_LARGE_FILE)
275
276 /*
277  * EXT4 supported feature set
278  */
279 #define EXT4_SUPPORTED_FCOM (EXT4_FCOM_DIR_INDEX)
280
281 #define EXT4_SUPPORTED_FINCOM                              \
282         (EXT4_FINCOM_FILETYPE | EXT4_FINCOM_META_BG |      \
283          EXT4_FINCOM_EXTENTS | EXT4_FINCOM_FLEX_BG |       \
284          EXT4_FINCOM_64BIT)
285
286 #define EXT4_SUPPORTED_FRO_COM                             \
287         (EXT4_FRO_COM_SPARSE_SUPER |                       \
288          EXT4_FRO_COM_METADATA_CSUM |                      \
289          EXT4_FRO_COM_LARGE_FILE | EXT4_FRO_COM_GDT_CSUM | \
290          EXT4_FRO_COM_DIR_NLINK |                          \
291          EXT4_FRO_COM_EXTRA_ISIZE | EXT4_FRO_COM_HUGE_FILE)
292
293 /*Ignored features:
294  * RECOVER - journaling in lwext4 is not supported
295  *           (probably won't be ever...)
296  * MMP - multi-mout protection (impossible scenario)
297  * */
298 #define EXT_FINCOM_IGNORED                                 \
299         EXT4_FINCOM_RECOVER | EXT4_FINCOM_MMP
300
301 #if 0
302 /*TODO: Features incompatible to implement*/
303 #define EXT4_SUPPORTED_FINCOM
304                      (EXT4_FINCOM_INLINE_DATA)
305
306 /*TODO: Features read only to implement*/
307 #define EXT4_SUPPORTED_FRO_COM
308                      EXT4_FRO_COM_BIGALLOC |\
309                      EXT4_FRO_COM_QUOTA)
310 #endif
311
312
313 /* Inode table/bitmap not in use */
314 #define EXT4_BLOCK_GROUP_INODE_UNINIT 0x0001
315 /* Block bitmap not in use */
316 #define EXT4_BLOCK_GROUP_BLOCK_UNINIT 0x0002
317 /* On-disk itable initialized to zero */
318 #define EXT4_BLOCK_GROUP_ITABLE_ZEROED 0x0004
319
320 /*
321  * Structure of a blocks group descriptor
322  */
323 struct ext4_bgroup {
324         uint32_t block_bitmap_lo;           /* Blocks bitmap block */
325         uint32_t inode_bitmap_lo;           /* Inodes bitmap block */
326         uint32_t inode_table_first_block_lo; /* Inodes table block */
327         uint16_t free_blocks_count_lo;       /* Free blocks count */
328         uint16_t free_inodes_count_lo;       /* Free inodes count */
329         uint16_t used_dirs_count_lo;     /* Directories count */
330         uint16_t flags;                /* EXT4_BG_flags (INODE_UNINIT, etc) */
331         uint32_t exclude_bitmap_lo;    /* Exclude bitmap for snapshots */
332         uint16_t block_bitmap_csum_lo; /* crc32c(s_uuid+grp_num+bbitmap) LE */
333         uint16_t inode_bitmap_csum_lo; /* crc32c(s_uuid+grp_num+ibitmap) LE */
334         uint16_t itable_unused_lo;     /* Unused inodes count */
335         uint16_t checksum;           /* crc16(sb_uuid+group+desc) */
336
337         uint32_t block_bitmap_hi;           /* Blocks bitmap block MSB */
338         uint32_t inode_bitmap_hi;           /* I-nodes bitmap block MSB */
339         uint32_t inode_table_first_block_hi; /* I-nodes table block MSB */
340         uint16_t free_blocks_count_hi;       /* Free blocks count MSB */
341         uint16_t free_inodes_count_hi;       /* Free i-nodes count MSB */
342         uint16_t used_dirs_count_hi;     /* Directories count MSB */
343         uint16_t itable_unused_hi;         /* Unused inodes count MSB */
344         uint32_t exclude_bitmap_hi;       /* Exclude bitmap block MSB */
345         uint16_t block_bitmap_csum_hi; /* crc32c(s_uuid+grp_num+bbitmap) BE */
346         uint16_t inode_bitmap_csum_hi; /* crc32c(s_uuid+grp_num+ibitmap) BE */
347         uint32_t reserved;           /* Padding */
348 };
349
350
351 #define EXT4_MIN_BLOCK_GROUP_DESCRIPTOR_SIZE 32
352 #define EXT4_MAX_BLOCK_GROUP_DESCRIPTOR_SIZE 64
353
354 #define EXT4_MIN_BLOCK_SIZE 1024  /* 1 KiB */
355 #define EXT4_MAX_BLOCK_SIZE 65536 /* 64 KiB */
356 #define EXT4_REV0_INODE_SIZE 128
357
358 #define EXT4_INODE_BLOCK_SIZE 512
359
360 #define EXT4_INODE_DIRECT_BLOCK_COUNT 12
361 #define EXT4_INODE_INDIRECT_BLOCK EXT4_INODE_DIRECT_BLOCK_COUNT
362 #define EXT4_INODE_DOUBLE_INDIRECT_BLOCK (EXT4_INODE_INDIRECT_BLOCK + 1)
363 #define EXT4_INODE_TRIPPLE_INDIRECT_BLOCK (EXT4_INODE_DOUBLE_INDIRECT_BLOCK + 1)
364 #define EXT4_INODE_BLOCKS (EXT4_INODE_TRIPPLE_INDIRECT_BLOCK + 1)
365 #define EXT4_INODE_INDIRECT_BLOCK_COUNT                                        \
366         (EXT4_INODE_BLOCKS - EXT4_INODE_DIRECT_BLOCK_COUNT)
367
368 #pragma pack(push, 1)
369
370 /*
371  * Structure of an inode on the disk
372  */
373 struct ext4_inode {
374         uint16_t mode;              /* File mode */
375         uint16_t uid;               /* Low 16 bits of owner uid */
376         uint32_t size_lo;          /* Size in bytes */
377         uint32_t access_time;       /* Access time */
378         uint32_t change_inode_time; /* I-node change time */
379         uint32_t modification_time; /* Modification time */
380         uint32_t deletion_time;     /* Deletion time */
381         uint16_t gid;               /* Low 16 bits of group id */
382         uint16_t links_count;       /* Links count */
383         uint32_t blocks_count_lo;   /* Blocks count */
384         uint32_t flags;             /* File flags */
385         uint32_t unused_osd1;       /* OS dependent - not used in HelenOS */
386         uint32_t blocks[EXT4_INODE_BLOCKS]; /* Pointers to blocks */
387         uint32_t generation;                /* File version (for NFS) */
388         uint32_t file_acl_lo;               /* File ACL */
389         uint32_t size_hi;
390         uint32_t obso_faddr; /* Obsoleted fragment address */
391
392         union {
393                 struct {
394                         uint16_t blocks_high;
395                         uint16_t file_acl_high;
396                         uint16_t uid_high;
397                         uint16_t gid_high;
398                         uint16_t checksum_lo; /* crc32c(uuid+inum+inode) LE */
399                         uint16_t reserved2;
400                 } linux2;
401                 struct {
402                         uint16_t reserved1;
403                         uint16_t mode_high;
404                         uint16_t uid_high;
405                         uint16_t gid_high;
406                         uint32_t author;
407                 } hurd2;
408         } osd2;
409
410         uint16_t extra_isize;
411         uint16_t checksum_hi;   /* crc32c(uuid+inum+inode) BE */
412         uint32_t ctime_extra; /* Extra change time (nsec << 2 | epoch) */
413         uint32_t mtime_extra; /* Extra Modification time (nsec << 2 | epoch) */
414         uint32_t atime_extra; /* Extra Access time (nsec << 2 | epoch) */
415         uint32_t crtime;      /* File creation time */
416         uint32_t
417             crtime_extra;    /* Extra file creation time (nsec << 2 | epoch) */
418         uint32_t version_hi; /* High 32 bits for 64-bit version */
419 };
420
421 #pragma pack(pop)
422
423 #define EXT4_INODE_MODE_FIFO 0x1000
424 #define EXT4_INODE_MODE_CHARDEV 0x2000
425 #define EXT4_INODE_MODE_DIRECTORY 0x4000
426 #define EXT4_INODE_MODE_BLOCKDEV 0x6000
427 #define EXT4_INODE_MODE_FILE 0x8000
428 #define EXT4_INODE_MODE_SOFTLINK 0xA000
429 #define EXT4_INODE_MODE_SOCKET 0xC000
430 #define EXT4_INODE_MODE_TYPE_MASK 0xF000
431
432 /*
433  * Inode flags
434  */
435 #define EXT4_INODE_FLAG_SECRM 0x00000001     /* Secure deletion */
436 #define EXT4_INODE_FLAG_UNRM 0x00000002      /* Undelete */
437 #define EXT4_INODE_FLAG_COMPR 0x00000004     /* Compress file */
438 #define EXT4_INODE_FLAG_SYNC 0x00000008      /* Synchronous updates */
439 #define EXT4_INODE_FLAG_IMMUTABLE 0x00000010 /* Immutable file */
440 #define EXT4_INODE_FLAG_APPEND 0x00000020  /* writes to file may only append */
441 #define EXT4_INODE_FLAG_NODUMP 0x00000040  /* do not dump file */
442 #define EXT4_INODE_FLAG_NOATIME 0x00000080 /* do not update atime */
443
444 /* Compression flags */
445 #define EXT4_INODE_FLAG_DIRTY 0x00000100
446 #define EXT4_INODE_FLAG_COMPRBLK                                               \
447         0x00000200                         /* One or more compressed clusters */
448 #define EXT4_INODE_FLAG_NOCOMPR 0x00000400 /* Don't compress */
449 #define EXT4_INODE_FLAG_ECOMPR 0x00000800  /* Compression error */
450
451 #define EXT4_INODE_FLAG_INDEX 0x00001000  /* hash-indexed directory */
452 #define EXT4_INODE_FLAG_IMAGIC 0x00002000 /* AFS directory */
453 #define EXT4_INODE_FLAG_JOURNAL_DATA                                           \
454         0x00004000                        /* File data should be journaled */
455 #define EXT4_INODE_FLAG_NOTAIL 0x00008000 /* File tail should not be merged */
456 #define EXT4_INODE_FLAG_DIRSYNC                                                \
457         0x00010000 /* Dirsync behaviour (directories only) */
458 #define EXT4_INODE_FLAG_TOPDIR 0x00020000    /* Top of directory hierarchies */
459 #define EXT4_INODE_FLAG_HUGE_FILE 0x00040000 /* Set to each huge file */
460 #define EXT4_INODE_FLAG_EXTENTS 0x00080000   /* Inode uses extents */
461 #define EXT4_INODE_FLAG_EA_INODE 0x00200000  /* Inode used for large EA */
462 #define EXT4_INODE_FLAG_EOFBLOCKS 0x00400000 /* Blocks allocated beyond EOF */
463 #define EXT4_INODE_FLAG_RESERVED 0x80000000  /* reserved for ext4 lib */
464
465 #define EXT4_INODE_ROOT_INDEX 2
466
467 struct ext4_inode_ref {
468         struct ext4_block block;
469         struct ext4_inode *inode;
470         struct ext4_fs *fs;
471         uint32_t index;
472         bool dirty;
473 };
474
475 #define EXT4_DIRECTORY_FILENAME_LEN 255
476
477 /**@brief   Directory entry types. */
478 enum { EXT4_DE_UNKNOWN = 0,
479        EXT4_DE_REG_FILE,
480        EXT4_DE_DIR,
481        EXT4_DE_CHRDEV,
482        EXT4_DE_BLKDEV,
483        EXT4_DE_FIFO,
484        EXT4_DE_SOCK,
485        EXT4_DE_SYMLINK };
486
487 #define EXT4_DIRENTRY_DIR_CSUM 0xDE
488
489 #pragma pack(push, 1)
490
491 union ext4_dir_en_internal {
492         uint8_t name_length_high; /* Higher 8 bits of name length */
493         uint8_t inode_type;       /* Type of referenced inode (in rev >= 0.5) */
494 };
495
496 /**
497  * Linked list directory entry structure
498  */
499 struct ext4_dir_en {
500         uint32_t inode; /* I-node for the entry */
501         uint16_t entry_len; /* Distance to the next directory entry */
502         uint8_t name_len;   /* Lower 8 bits of name length */
503
504         union ext4_dir_en_internal in;
505
506         uint8_t name[EXT4_DIRECTORY_FILENAME_LEN]; /* Entry name */
507 };
508
509 struct ext4_dir_iter {
510         struct ext4_inode_ref *inode_ref;
511         struct ext4_block curr_blk;
512         uint64_t curr_off;
513         struct ext4_dir_en *curr;
514 };
515
516 struct ext4_dir_search_result {
517         struct ext4_block block;
518         struct ext4_dir_en *dentry;
519 };
520
521 /* Structures for indexed directory */
522
523 struct ext4_dir_idx_climit {
524         uint16_t limit;
525         uint16_t count;
526 };
527
528 struct ext4_dir_idx_dot_en {
529         uint32_t inode;
530         uint16_t entry_length;
531         uint8_t name_length;
532         uint8_t inode_type;
533         uint8_t name[4];
534 };
535
536 struct ext4_dir_idx_rinfo {
537         uint32_t reserved_zero;
538         uint8_t hash_version;
539         uint8_t info_length;
540         uint8_t indirect_levels;
541         uint8_t unused_flags;
542 };
543
544 struct ext4_dir_idx_entry {
545         uint32_t hash;
546         uint32_t block;
547 };
548
549 struct ext4_dir_idx_root {
550         struct ext4_dir_idx_dot_en dots[2];
551         struct ext4_dir_idx_rinfo info;
552         struct ext4_dir_idx_entry en[];
553 };
554
555 struct ext4_fake_dir_entry {
556         uint32_t inode;
557         uint16_t entry_length;
558         uint8_t name_length;
559         uint8_t inode_type;
560 };
561
562 struct ext4_dir_idx_node {
563         struct ext4_fake_dir_entry fake;
564         struct ext4_dir_idx_entry entries[];
565 };
566
567 struct ext4_dir_idx_block {
568         struct ext4_block b;
569         struct ext4_dir_idx_entry *entries;
570         struct ext4_dir_idx_entry *position;
571 };
572
573 /*
574  * This goes at the end of each htree block.
575  */
576 struct ext4_dir_idx_tail {
577         uint32_t reserved;
578         uint32_t checksum;      /* crc32c(uuid+inum+dirblock) */
579 };
580
581 /*
582  * This is a bogus directory entry at the end of each leaf block that
583  * records checksums.
584  */
585 struct ext4_dir_entry_tail {
586         uint32_t reserved_zero1;        /* Pretend to be unused */
587         uint16_t rec_len;               /* 12 */
588         uint8_t reserved_zero2; /* Zero name length */
589         uint8_t reserved_ft;    /* 0xDE, fake file type */
590         uint32_t checksum;              /* crc32c(uuid+inum+dirblock) */
591 };
592
593 #pragma pack(pop)
594
595 #define EXT4_DIRENT_TAIL(block, blocksize) \
596         ((struct ext4_dir_entry_tail *)(((char *)(block)) + ((blocksize) - \
597                                         sizeof(struct ext4_dir_entry_tail))))
598
599 #define EXT4_ERR_BAD_DX_DIR (-25000)
600
601 #define EXT4_LINK_MAX 65000
602
603 #define EXT4_BAD_INO 1
604 #define EXT4_ROOT_INO 2
605 #define EXT4_BOOT_LOADER_INO 5
606 #define EXT4_UNDEL_DIR_INO 6
607 #define EXT4_RESIZE_INO 7
608 #define EXT4_JOURNAL_INO 8
609
610 #define EXT4_GOOD_OLD_FIRST_INO 11
611
612 #define EXT4_EXT_UNWRITTEN_MASK (1L << 15)
613
614 #define EXT4_EXT_MAX_LEN_WRITTEN (1L << 15)
615 #define EXT4_EXT_MAX_LEN_UNWRITTEN \
616         (EXT4_EXT_MAX_LEN_WRITTEN - 1)
617
618 #define EXT4_EXT_GET_LEN(ex) to_le16((ex)->block_count)
619 #define EXT4_EXT_GET_LEN_UNWRITTEN(ex) \
620         (EXT4_EXT_GET_LEN(ex) &= ~(EXT4_EXT_UNWRITTEN_MASK))
621 #define EXT4_EXT_SET_LEN(ex, count) \
622         ((ex)->block_count = to_le16(count))
623
624 #define EXT4_EXT_IS_UNWRITTEN(ex) \
625         (EXT4_EXT_GET_LEN(ex) > EXT4_EXT_MAX_LEN_WRITTEN)
626 #define EXT4_EXT_SET_UNWRITTEN(ex) \
627         ((ex)->block_count |= to_le16(EXT4_EXT_UNWRITTEN_MASK))
628 #define EXT4_EXT_SET_WRITTEN(ex) \
629         ((ex)->block_count &= ~(to_le16(EXT4_EXT_UNWRITTEN_MASK)))
630
631 #pragma pack(push, 1)
632
633 /*
634  * This is the extent tail on-disk structure.
635  * All other extent structures are 12 bytes long.  It turns out that
636  * block_size % 12 >= 4 for at least all powers of 2 greater than 512, which
637  * covers all valid ext4 block sizes.  Therefore, this tail structure can be
638  * crammed into the end of the block without having to rebalance the tree.
639  */
640 struct ext4_extent_tail
641 {
642         uint32_t et_checksum; /* crc32c(uuid+inum+extent_block) */
643 };
644
645 /*
646  * This is the extent on-disk structure.
647  * It's used at the bottom of the tree.
648  */
649 struct ext4_extent {
650         uint32_t first_block; /* First logical block extent covers */
651         uint16_t block_count; /* Number of blocks covered by extent */
652         uint16_t start_hi;    /* High 16 bits of physical block */
653         uint32_t start_lo;    /* Low 32 bits of physical block */
654 };
655
656 /*
657  * This is index on-disk structure.
658  * It's used at all the levels except the bottom.
659  */
660 struct ext4_extent_index {
661         uint32_t first_block; /* Index covers logical blocks from 'block' */
662
663         /**
664          * Pointer to the physical block of the next
665          * level. leaf or next index could be there
666          * high 16 bits of physical block
667          */
668         uint32_t leaf_lo;
669         uint16_t leaf_hi;
670         uint16_t padding;
671 };
672
673 /*
674  * Each block (leaves and indexes), even inode-stored has header.
675  */
676 struct ext4_extent_header {
677         uint16_t magic;
678         uint16_t entries_count;     /* Number of valid entries */
679         uint16_t max_entries_count; /* Capacity of store in entries */
680         uint16_t depth;             /* Has tree real underlying blocks? */
681         uint32_t generation;    /* generation of the tree */
682 };
683
684 #pragma pack(pop)
685
686
687 #define EXT4_EXTENT_MAGIC 0xF30A
688
689 #define EXT4_EXTENT_FIRST(header)                                              \
690         ((struct ext4_extent *)(((char *)(header)) +                           \
691                                 sizeof(struct ext4_extent_header)))
692
693 #define EXT4_EXTENT_FIRST_INDEX(header)                                        \
694         ((struct ext4_extent_index *)(((char *)(header)) +                     \
695                                       sizeof(struct ext4_extent_header)))
696
697 /*
698  * EXT_INIT_MAX_LEN is the maximum number of blocks we can have in an
699  * initialized extent. This is 2^15 and not (2^16 - 1), since we use the
700  * MSB of ee_len field in the extent datastructure to signify if this
701  * particular extent is an initialized extent or an uninitialized (i.e.
702  * preallocated).
703  * EXT_UNINIT_MAX_LEN is the maximum number of blocks we can have in an
704  * uninitialized extent.
705  * If ee_len is <= 0x8000, it is an initialized extent. Otherwise, it is an
706  * uninitialized one. In other words, if MSB of ee_len is set, it is an
707  * uninitialized extent with only one special scenario when ee_len = 0x8000.
708  * In this case we can not have an uninitialized extent of zero length and
709  * thus we make it as a special case of initialized extent with 0x8000 length.
710  * This way we get better extent-to-group alignment for initialized extents.
711  * Hence, the maximum number of blocks we can have in an *initialized*
712  * extent is 2^15 (32768) and in an *uninitialized* extent is 2^15-1 (32767).
713  */
714 #define EXT_INIT_MAX_LEN (1L << 15)
715 #define EXT_UNWRITTEN_MAX_LEN (EXT_INIT_MAX_LEN - 1)
716
717 #define EXT_EXTENT_SIZE sizeof(struct ext4_extent)
718 #define EXT_INDEX_SIZE sizeof(struct ext4_extent_idx)
719
720 #define EXT_FIRST_EXTENT(__hdr__)                                              \
721         ((struct ext4_extent *)(((char *)(__hdr__)) +                          \
722                                 sizeof(struct ext4_extent_header)))
723 #define EXT_FIRST_INDEX(__hdr__)                                               \
724         ((struct ext4_extent_index *)(((char *)(__hdr__)) +                    \
725                                     sizeof(struct ext4_extent_header)))
726 #define EXT_HAS_FREE_INDEX(__path__)                                           \
727         ((__path__)->header->entries_count < (__path__)->header->max_entries_count)
728 #define EXT_LAST_EXTENT(__hdr__)                                               \
729         (EXT_FIRST_EXTENT((__hdr__)) + (__hdr__)->entries_count - 1)
730 #define EXT_LAST_INDEX(__hdr__)                                                \
731         (EXT_FIRST_INDEX((__hdr__)) + (__hdr__)->entries_count - 1)
732 #define EXT_MAX_EXTENT(__hdr__)                                                \
733         (EXT_FIRST_EXTENT((__hdr__)) + (__hdr__)->max_entries_count - 1)
734 #define EXT_MAX_INDEX(__hdr__)                                                 \
735         (EXT_FIRST_INDEX((__hdr__)) + (__hdr__)->max_entries_count - 1)
736
737 #define EXT4_EXTENT_TAIL_OFFSET(hdr)                                           \
738         (sizeof(struct ext4_extent_header) +                                   \
739          (sizeof(struct ext4_extent) * (hdr)->max_entries_count))
740
741 /*
742  * ext4_ext_next_allocated_block:
743  * returns allocated block in subsequent extent or EXT_MAX_BLOCKS.
744  * NOTE: it considers block number from index entry as
745  * allocated block. Thus, index entries have to be consistent
746  * with leaves.
747  */
748 #define EXT_MAX_BLOCKS (ext4_lblk_t) (-1)
749
750 #define IN_RANGE(b, first, len) ((b) >= (first) && (b) <= (first) + (len) - 1)
751
752
753 /******************************************************************************/
754
755 /* EXT3 HTree directory indexing */
756 #define EXT2_HTREE_LEGACY 0
757 #define EXT2_HTREE_HALF_MD4 1
758 #define EXT2_HTREE_TEA 2
759 #define EXT2_HTREE_LEGACY_UNSIGNED 3
760 #define EXT2_HTREE_HALF_MD4_UNSIGNED 4
761 #define EXT2_HTREE_TEA_UNSIGNED 5
762
763 #define EXT2_HTREE_EOF 0x7FFFFFFFUL
764
765
766 /* Extended Attribute(EA) */
767
768 /* Magic value in attribute blocks */
769 #define EXT4_XATTR_MAGIC                0xEA020000
770
771 /* Maximum number of references to one attribute block */
772 #define EXT4_XATTR_REFCOUNT_MAX         1024
773
774 /* Name indexes */
775 #define EXT4_XATTR_INDEX_USER                   1
776 #define EXT4_XATTR_INDEX_POSIX_ACL_ACCESS       2
777 #define EXT4_XATTR_INDEX_POSIX_ACL_DEFAULT      3
778 #define EXT4_XATTR_INDEX_TRUSTED                4
779 #define EXT4_XATTR_INDEX_LUSTRE                 5
780 #define EXT4_XATTR_INDEX_SECURITY               6
781 #define EXT4_XATTR_INDEX_SYSTEM                 7
782 #define EXT4_XATTR_INDEX_RICHACL                8
783 #define EXT4_XATTR_INDEX_ENCRYPTION             9
784
785 #pragma pack(push, 1)
786
787 struct ext4_xattr_header {
788         uint32_t h_magic;       /* magic number for identification */
789         uint32_t h_refcount;    /* reference count */
790         uint32_t h_blocks;      /* number of disk blocks used */
791         uint32_t h_hash;                /* hash value of all attributes */
792         uint32_t h_checksum;    /* crc32c(uuid+id+xattrblock) */
793                                 /* id = inum if refcount=1, blknum otherwise */
794         uint32_t h_reserved[3]; /* zero right now */
795 };
796
797 struct ext4_xattr_ibody_header {
798         uint32_t h_magic;       /* magic number for identification */
799 };
800
801 struct ext4_xattr_entry {
802         uint8_t e_name_len;     /* length of name */
803         uint8_t e_name_index;   /* attribute name index */
804         uint16_t e_value_offs;  /* offset in disk block of value */
805         uint32_t e_value_block; /* disk block attribute is stored on (n/i) */
806         uint32_t e_value_size;  /* size of attribute value */
807         uint32_t e_hash;                /* hash value of name and value */
808 };
809
810 #pragma pack(pop)
811
812 #define EXT4_GOOD_OLD_INODE_SIZE        128
813
814 #define EXT4_XATTR_PAD_BITS             2
815 #define EXT4_XATTR_PAD          (1<<EXT4_XATTR_PAD_BITS)
816 #define EXT4_XATTR_ROUND                (EXT4_XATTR_PAD-1)
817 #define EXT4_XATTR_LEN(name_len) \
818         (((name_len) + EXT4_XATTR_ROUND + \
819         sizeof(struct ext4_xattr_entry)) & ~EXT4_XATTR_ROUND)
820 #define EXT4_XATTR_NEXT(entry) \
821         ((struct ext4_xattr_entry *)( \
822          (char *)(entry) + EXT4_XATTR_LEN((entry)->e_name_len)))
823 #define EXT4_XATTR_SIZE(size) \
824         (((size) + EXT4_XATTR_ROUND) & ~EXT4_XATTR_ROUND)
825 #define EXT4_XATTR_NAME(entry) \
826         ((char *)((entry) + 1))
827
828 #define EXT4_XATTR_IHDR(raw_inode) \
829         ((struct ext4_xattr_ibody_header *) \
830                 ((char *)raw_inode + \
831                 EXT4_GOOD_OLD_INODE_SIZE + \
832                 (raw_inode)->extra_isize))
833 #define EXT4_XATTR_IFIRST(hdr) \
834         ((struct ext4_xattr_entry *)((hdr)+1))
835
836 #define EXT4_XATTR_BHDR(block) \
837         ((struct ext4_xattr_header *)((block)->data))
838 #define EXT4_XATTR_ENTRY(ptr) \
839         ((struct ext4_xattr_entry *)(ptr))
840 #define EXT4_XATTR_BFIRST(block) \
841         EXT4_XATTR_ENTRY(EXT4_XATTR_BHDR(block)+1)
842 #define EXT4_XATTR_IS_LAST_ENTRY(entry) \
843         (*(uint32_t *)(entry) == 0)
844
845 #define EXT4_ZERO_XATTR_VALUE ((void *)-1)
846
847 /*****************************************************************************/
848
849 /*
850  * JBD stores integers in big endian.
851  */
852
853 #define JBD_MAGIC_NUMBER 0xc03b3998U /* The first 4 bytes of /dev/random! */
854
855 /*
856  * Descriptor block types:
857  */
858
859 #define JBD_DESCRIPTOR_BLOCK    1
860 #define JBD_COMMIT_BLOCK        2
861 #define JBD_SUPERBLOCK          3
862 #define JBD_SUPERBLOCK_V2       4
863 #define JBD_REVOKE_BLOCK        5
864
865 #pragma pack(push, 1)
866
867 /*
868  * Standard header for all descriptor blocks:
869  */
870 struct jbd_bhdr {
871         uint32_t                magic;
872         uint32_t                blocktype;
873         uint32_t                sequence;
874 };
875
876 #pragma pack(pop)
877
878 /*
879  * Checksum types.
880  */
881 #define JBD_CRC32_CHKSUM   1
882 #define JBD_MD5_CHKSUM     2
883 #define JBD_SHA1_CHKSUM    3
884 #define JBD_CRC32C_CHKSUM  4
885
886 #define JBD_CRC32_CHKSUM_SIZE 4
887
888 #define JBD_CHECKSUM_BYTES (32 / sizeof(uint32_t))
889
890 #pragma pack(push, 1)
891
892 /*
893  * Commit block header for storing transactional checksums:
894  *
895  * NOTE: If FEATURE_COMPAT_CHECKSUM (checksum v1) is set, the h_chksum*
896  * fields are used to store a checksum of the descriptor and data blocks.
897  *
898  * If FEATURE_INCOMPAT_CSUM_V2 (checksum v2) is set, then the h_chksum
899  * field is used to store crc32c(uuid+commit_block).  Each journal metadata
900  * block gets its own checksum, and data block checksums are stored in
901  * journal_block_tag (in the descriptor).  The other h_chksum* fields are
902  * not used.
903  *
904  * If FEATURE_INCOMPAT_CSUM_V3 is set, the descriptor block uses
905  * journal_block_tag3_t to store a full 32-bit checksum.  Everything else
906  * is the same as v2.
907  *
908  * Checksum v1, v2, and v3 are mutually exclusive features.
909  */
910
911 struct jbd_commit_header {
912         struct jbd_bhdr header;
913         uint8_t chksum_type;
914         uint8_t chksum_size;
915         uint8_t padding[2];
916         uint32_t                chksum[JBD_CHECKSUM_BYTES];
917         uint64_t                commit_sec;
918         uint32_t                commit_nsec;
919 };
920
921 /*
922  * The block tag: used to describe a single buffer in the journal
923  */
924 struct jbd_block_tag3 {
925         uint32_t                blocknr;        /* The on-disk block number */
926         uint32_t                flags;  /* See below */
927         uint32_t                blocknr_high; /* most-significant high 32bits. */
928         uint32_t                checksum;       /* crc32c(uuid+seq+block) */
929 };
930
931 struct jbd_block_tag {
932         uint32_t                blocknr;        /* The on-disk block number */
933         uint16_t                checksum;       /* truncated crc32c(uuid+seq+block) */
934         uint16_t                flags;  /* See below */
935         uint32_t                blocknr_high; /* most-significant high 32bits. */
936 };
937
938 #pragma pack(pop)
939
940 /* Definitions for the journal tag flags word: */
941 #define JBD_FLAG_ESCAPE         1       /* on-disk block is escaped */
942 #define JBD_FLAG_SAME_UUID      2       /* block has same uuid as previous */
943 #define JBD_FLAG_DELETED        4       /* block deleted by this transaction */
944 #define JBD_FLAG_LAST_TAG       8       /* last tag in this descriptor block */
945
946 #pragma pack(push, 1)
947
948 /* Tail of descriptor block, for checksumming */
949 struct jbd_block_tail {
950         uint32_t        checksum;
951 };
952
953 /*
954  * The revoke descriptor: used on disk to describe a series of blocks to
955  * be revoked from the log
956  */
957 struct jbd_revoke_header {
958         struct jbd_bhdr  header;
959         uint32_t         count; /* Count of bytes used in the block */
960 };
961
962 /* Tail of revoke block, for checksumming */
963 struct jbd_revoke_tail {
964         uint32_t                checksum;
965 };
966
967 #pragma pack(pop)
968
969 #define JBD_USERS_MAX 48
970 #define JBD_USERS_SIZE (UUID_SIZE * JBD_USERS_MAX)
971
972 #pragma pack(push, 1)
973
974 /*
975  * The journal superblock.  All fields are in big-endian byte order.
976  */
977 struct jbd_sb {
978 /* 0x0000 */
979         struct jbd_bhdr header;
980
981 /* 0x000C */
982         /* Static information describing the journal */
983         uint32_t        blocksize;              /* journal device blocksize */
984         uint32_t        maxlen;         /* total blocks in journal file */
985         uint32_t        first;          /* first block of log information */
986
987 /* 0x0018 */
988         /* Dynamic information describing the current state of the log */
989         uint32_t        sequence;               /* first commit ID expected in log */
990         uint32_t        start;          /* blocknr of start of log */
991
992 /* 0x0020 */
993         /* Error value, as set by journal_abort(). */
994         int32_t         error_val;
995
996 /* 0x0024 */
997         /* Remaining fields are only valid in a version-2 superblock */
998         uint32_t        feature_compat;         /* compatible feature set */
999         uint32_t        feature_incompat;       /* incompatible feature set */
1000         uint32_t        feature_ro_compat;      /* readonly-compatible feature set */
1001 /* 0x0030 */
1002         uint8_t         uuid[UUID_SIZE];                /* 128-bit uuid for journal */
1003
1004 /* 0x0040 */
1005         uint32_t        nr_users;               /* Nr of filesystems sharing log */
1006
1007         uint32_t        dynsuper;               /* Blocknr of dynamic superblock copy*/
1008
1009 /* 0x0048 */
1010         uint32_t        max_transaction;        /* Limit of journal blocks per trans.*/
1011         uint32_t        max_trandata;   /* Limit of data blocks per trans. */
1012
1013 /* 0x0050 */
1014         uint8_t         checksum_type;  /* checksum type */
1015         uint8_t         padding2[3];
1016         uint32_t        padding[42];
1017         uint32_t        checksum;               /* crc32c(superblock) */
1018
1019 /* 0x0100 */
1020         uint8_t         users[JBD_USERS_SIZE];          /* ids of all fs'es sharing the log */
1021
1022 /* 0x0400 */
1023 };
1024
1025 #pragma pack(pop)
1026
1027 #define JBD_SUPERBLOCK_SIZE sizeof(struct jbd_sb)
1028
1029 #define JBD_HAS_COMPAT_FEATURE(jsb,mask)                                        \
1030         ((jsb)->header.blocktype >= to_be32(2) &&                               \
1031          ((jsb)->feature_compat & to_be32((mask))))
1032 #define JBD_HAS_RO_COMPAT_FEATURE(jsb,mask)                             \
1033         ((jsb)->header.blocktype >= to_be32(2) &&                               \
1034          ((jsb)->feature_ro_compat & to_be32((mask))))
1035 #define JBD_HAS_INCOMPAT_FEATURE(jsb,mask)                              \
1036         ((jsb)->header.blocktype >= to_be32(2) &&                               \
1037          ((jsb)->feature_incompat & to_be32((mask))))
1038
1039 #define JBD_FEATURE_COMPAT_CHECKSUM     0x00000001
1040
1041 #define JBD_FEATURE_INCOMPAT_REVOKE             0x00000001
1042 #define JBD_FEATURE_INCOMPAT_64BIT              0x00000002
1043 #define JBD_FEATURE_INCOMPAT_ASYNC_COMMIT       0x00000004
1044 #define JBD_FEATURE_INCOMPAT_CSUM_V2            0x00000008
1045 #define JBD_FEATURE_INCOMPAT_CSUM_V3            0x00000010
1046
1047 /* Features known to this kernel version: */
1048 #define JBD_KNOWN_COMPAT_FEATURES       0
1049 #define JBD_KNOWN_ROCOMPAT_FEATURES     0
1050 #define JBD_KNOWN_INCOMPAT_FEATURES     (JBD_FEATURE_INCOMPAT_REVOKE|\
1051                                          JBD_FEATURE_INCOMPAT_ASYNC_COMMIT|\
1052                                          JBD_FEATURE_INCOMPAT_64BIT|\
1053                                          JBD_FEATURE_INCOMPAT_CSUM_V2|\
1054                                          JBD_FEATURE_INCOMPAT_CSUM_V3)
1055
1056 /*****************************************************************************/
1057
1058 #define EXT4_CRC32_INIT (0xFFFFFFFFUL)
1059
1060 /*****************************************************************************/
1061
1062 #ifdef __cplusplus
1063 }
1064 #endif
1065
1066 #endif /* EXT4_TYPES_H_ */
1067
1068 /**
1069  * @}
1070  */