2 * Copyright (c) 2013 Grzegorz Kostka (kostka.grzegorz@gmail.com)
6 * Copyright (c) 2012 Martin Sucha
7 * Copyright (c) 2012 Frantisek Princ
10 * Redistribution and use in source and binary forms, with or without
11 * modification, are permitted provided that the following conditions
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.
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.
34 /** @addtogroup lwext4
39 * @brief Ext4 data structure definitions.
49 #include "ext4_config.h"
50 #include "ext4_blockdev.h"
51 #include "misc/tree.h"
56 #define EXT4_CHECKSUM_CRC32C 1
61 * Structure of the super block
64 uint32_t inodes_count; /* I-nodes count */
65 uint32_t blocks_count_lo; /* Blocks count */
66 uint32_t reserved_blocks_count_lo; /* Reserved blocks count */
67 uint32_t free_blocks_count_lo; /* Free blocks count */
68 uint32_t free_inodes_count; /* Free inodes count */
69 uint32_t first_data_block; /* First Data Block */
70 uint32_t log_block_size; /* Block size */
71 uint32_t log_cluster_size; /* Obsoleted fragment size */
72 uint32_t blocks_per_group; /* Number of blocks per group */
73 uint32_t frags_per_group; /* Obsoleted fragments per group */
74 uint32_t inodes_per_group; /* Number of inodes per group */
75 uint32_t mount_time; /* Mount time */
76 uint32_t write_time; /* Write time */
77 uint16_t mount_count; /* Mount count */
78 uint16_t max_mount_count; /* Maximal mount count */
79 uint16_t magic; /* Magic signature */
80 uint16_t state; /* File system state */
81 uint16_t errors; /* Behavior when detecting errors */
82 uint16_t minor_rev_level; /* Minor revision level */
83 uint32_t last_check_time; /* Time of last check */
84 uint32_t check_interval; /* Maximum time between checks */
85 uint32_t creator_os; /* Creator OS */
86 uint32_t rev_level; /* Revision level */
87 uint16_t def_resuid; /* Default uid for reserved blocks */
88 uint16_t def_resgid; /* Default gid for reserved blocks */
90 /* Fields for EXT4_DYNAMIC_REV superblocks only. */
91 uint32_t first_inode; /* First non-reserved inode */
92 uint16_t inode_size; /* Size of inode structure */
93 uint16_t block_group_index; /* Block group index of this superblock */
94 uint32_t features_compatible; /* Compatible feature set */
95 uint32_t features_incompatible; /* Incompatible feature set */
96 uint32_t features_read_only; /* Readonly-compatible feature set */
97 uint8_t uuid[UUID_SIZE]; /* 128-bit uuid for volume */
98 char volume_name[16]; /* Volume name */
99 char last_mounted[64]; /* Directory where last mounted */
100 uint32_t algorithm_usage_bitmap; /* For compression */
103 * Performance hints. Directory preallocation should only
104 * happen if the EXT4_FEATURE_COMPAT_DIR_PREALLOC flag is on.
106 uint8_t s_prealloc_blocks; /* Number of blocks to try to preallocate */
107 uint8_t s_prealloc_dir_blocks; /* Number to preallocate for dirs */
108 uint16_t s_reserved_gdt_blocks; /* Per group desc for online growth */
111 * Journaling support valid if EXT4_FEATURE_COMPAT_HAS_JOURNAL set.
113 uint8_t journal_uuid[UUID_SIZE]; /* UUID of journal superblock */
114 uint32_t journal_inode_number; /* Inode number of journal file */
115 uint32_t journal_dev; /* Device number of journal file */
116 uint32_t last_orphan; /* Head of list of inodes to delete */
117 uint32_t hash_seed[4]; /* HTREE hash seed */
118 uint8_t default_hash_version; /* Default hash version to use */
119 uint8_t journal_backup_type;
120 uint16_t desc_size; /* Size of group descriptor */
121 uint32_t default_mount_opts; /* Default mount options */
122 uint32_t first_meta_bg; /* First metablock block group */
123 uint32_t mkfs_time; /* When the filesystem was created */
124 uint32_t journal_blocks[17]; /* Backup of the journal inode */
126 /* 64bit support valid if EXT4_FEATURE_COMPAT_64BIT */
127 uint32_t blocks_count_hi; /* Blocks count */
128 uint32_t reserved_blocks_count_hi; /* Reserved blocks count */
129 uint32_t free_blocks_count_hi; /* Free blocks count */
130 uint16_t min_extra_isize; /* All inodes have at least # bytes */
131 uint16_t want_extra_isize; /* New inodes should reserve # bytes */
132 uint32_t flags; /* Miscellaneous flags */
133 uint16_t raid_stride; /* RAID stride */
134 uint16_t mmp_interval; /* # seconds to wait in MMP checking */
135 uint64_t mmp_block; /* Block for multi-mount protection */
136 uint32_t raid_stripe_width; /* Blocks on all data disks (N * stride) */
137 uint8_t log_groups_per_flex; /* FLEX_BG group size */
138 uint8_t checksum_type;
139 uint16_t reserved_pad;
140 uint64_t kbytes_written; /* Number of lifetime kilobytes written */
141 uint32_t snapshot_inum; /* I-node number of active snapshot */
142 uint32_t snapshot_id; /* Sequential ID of active snapshot */
144 snapshot_r_blocks_count; /* Reserved blocks for active snapshot's
147 snapshot_list; /* I-node number of the head of the on-disk snapshot
149 uint32_t error_count; /* Number of file system errors */
150 uint32_t first_error_time; /* First time an error happened */
151 uint32_t first_error_ino; /* I-node involved in first error */
152 uint64_t first_error_block; /* Block involved of first error */
153 uint8_t first_error_func[32]; /* Function where the error happened */
154 uint32_t first_error_line; /* Line number where error happened */
155 uint32_t last_error_time; /* Most recent time of an error */
156 uint32_t last_error_ino; /* I-node involved in last error */
157 uint32_t last_error_line; /* Line number where error happened */
158 uint64_t last_error_block; /* Block involved of last error */
159 uint8_t last_error_func[32]; /* Function where the error happened */
160 uint8_t mount_opts[64];
161 uint32_t usr_quota_inum; /* inode for tracking user quota */
162 uint32_t grp_quota_inum; /* inode for tracking group quota */
163 uint32_t overhead_clusters; /* overhead blocks/clusters in fs */
164 uint32_t backup_bgs[2]; /* groups with sparse_super2 SBs */
165 uint8_t encrypt_algos[4]; /* Encryption algorithms in use */
166 uint8_t encrypt_pw_salt[16]; /* Salt used for string2key algorithm */
167 uint32_t lpf_ino; /* Location of the lost+found inode */
168 uint32_t padding[100]; /* Padding to the end of the block */
169 uint32_t checksum; /* crc32c(superblock) */
170 } __attribute__((packed));
172 #define EXT4_SUPERBLOCK_MAGIC 0xEF53
173 #define EXT4_SUPERBLOCK_SIZE 1024
174 #define EXT4_SUPERBLOCK_OFFSET 1024
176 #define EXT4_SUPERBLOCK_OS_LINUX 0
177 #define EXT4_SUPERBLOCK_OS_HURD 1
180 * Misc. filesystem flags
182 #define EXT4_SUPERBLOCK_FLAGS_SIGNED_HASH 0x0001
183 #define EXT4_SUPERBLOCK_FLAGS_UNSIGNED_HASH 0x0002
184 #define EXT4_SUPERBLOCK_FLAGS_TEST_FILESYS 0x0004
188 #define EXT4_SUPERBLOCK_STATE_VALID_FS 0x0001 /* Unmounted cleanly */
189 #define EXT4_SUPERBLOCK_STATE_ERROR_FS 0x0002 /* Errors detected */
190 #define EXT4_SUPERBLOCK_STATE_ORPHAN_FS 0x0004 /* Orphans being recovered */
193 * Behaviour when errors detected
195 #define EXT4_SUPERBLOCK_ERRORS_CONTINUE 1 /* Continue execution */
196 #define EXT4_SUPERBLOCK_ERRORS_RO 2 /* Remount fs read-only */
197 #define EXT4_SUPERBLOCK_ERRORS_PANIC 3 /* Panic */
198 #define EXT4_SUPERBLOCK_ERRORS_DEFAULT EXT4_ERRORS_CONTINUE
201 * Compatible features
203 #define EXT4_FCOM_DIR_PREALLOC 0x0001
204 #define EXT4_FCOM_IMAGIC_INODES 0x0002
205 #define EXT4_FCOM_HAS_JOURNAL 0x0004
206 #define EXT4_FCOM_EXT_ATTR 0x0008
207 #define EXT4_FCOM_RESIZE_INODE 0x0010
208 #define EXT4_FCOM_DIR_INDEX 0x0020
211 * Read-only compatible features
213 #define EXT4_FRO_COM_SPARSE_SUPER 0x0001
214 #define EXT4_FRO_COM_LARGE_FILE 0x0002
215 #define EXT4_FRO_COM_BTREE_DIR 0x0004
216 #define EXT4_FRO_COM_HUGE_FILE 0x0008
217 #define EXT4_FRO_COM_GDT_CSUM 0x0010
218 #define EXT4_FRO_COM_DIR_NLINK 0x0020
219 #define EXT4_FRO_COM_EXTRA_ISIZE 0x0040
220 #define EXT4_FRO_COM_QUOTA 0x0100
221 #define EXT4_FRO_COM_BIGALLOC 0x0200
222 #define EXT4_FRO_COM_METADATA_CSUM 0x0400
225 * Incompatible features
227 #define EXT4_FINCOM_COMPRESSION 0x0001
228 #define EXT4_FINCOM_FILETYPE 0x0002
229 #define EXT4_FINCOM_RECOVER 0x0004 /* Needs recovery */
230 #define EXT4_FINCOM_JOURNAL_DEV 0x0008 /* Journal device */
231 #define EXT4_FINCOM_META_BG 0x0010
232 #define EXT4_FINCOM_EXTENTS 0x0040 /* extents support */
233 #define EXT4_FINCOM_64BIT 0x0080
234 #define EXT4_FINCOM_MMP 0x0100
235 #define EXT4_FINCOM_FLEX_BG 0x0200
236 #define EXT4_FINCOM_EA_INODE 0x0400 /* EA in inode */
237 #define EXT4_FINCOM_DIRDATA 0x1000 /* data in dirent */
238 #define EXT4_FINCOM_BG_USE_META_CSUM 0x2000 /* use crc32c for bg */
239 #define EXT4_FINCOM_LARGEDIR 0x4000 /* >2GB or 3-lvl htree */
240 #define EXT4_FINCOM_INLINE_DATA 0x8000 /* data in inode */
243 * EXT2 supported feature set
245 #define EXT2_SUPPORTED_FCOM 0x0000
247 #define EXT2_SUPPORTED_FINCOM \
248 (EXT4_FINCOM_FILETYPE | EXT4_FINCOM_META_BG)
250 #define EXT2_SUPPORTED_FRO_COM \
251 (EXT4_FRO_COM_SPARSE_SUPER | \
252 EXT4_FRO_COM_LARGE_FILE)
255 * EXT3 supported feature set
257 #define EXT3_SUPPORTED_FCOM (EXT4_FCOM_DIR_INDEX)
259 #define EXT3_SUPPORTED_FINCOM \
260 (EXT4_FINCOM_FILETYPE | EXT4_FINCOM_META_BG)
262 #define EXT3_SUPPORTED_FRO_COM \
263 (EXT4_FRO_COM_SPARSE_SUPER | EXT4_FRO_COM_LARGE_FILE)
266 * EXT4 supported feature set
268 #define EXT4_SUPPORTED_FCOM (EXT4_FCOM_DIR_INDEX)
270 #define EXT4_SUPPORTED_FINCOM \
271 (EXT4_FINCOM_FILETYPE | EXT4_FINCOM_META_BG | \
272 EXT4_FINCOM_EXTENTS | EXT4_FINCOM_FLEX_BG | \
275 #define EXT4_SUPPORTED_FRO_COM \
276 (EXT4_FRO_COM_SPARSE_SUPER | \
277 EXT4_FRO_COM_METADATA_CSUM | \
278 EXT4_FRO_COM_LARGE_FILE | EXT4_FRO_COM_GDT_CSUM | \
279 EXT4_FRO_COM_DIR_NLINK | \
280 EXT4_FRO_COM_EXTRA_ISIZE | EXT4_FRO_COM_HUGE_FILE)
283 * RECOVER - journaling in lwext4 is not supported
284 * (probably won't be ever...)
285 * MMP - multi-mout protection (impossible scenario)
287 #define EXT_FINCOM_IGNORED \
288 EXT4_FINCOM_RECOVER | EXT4_FINCOM_MMP
291 /*TODO: Features incompatible to implement*/
292 #define EXT4_SUPPORTED_FINCOM
293 (EXT4_FINCOM_INLINE_DATA)
295 /*TODO: Features read only to implement*/
296 #define EXT4_SUPPORTED_FRO_COM
297 EXT4_FRO_COM_BIGALLOC |\
302 struct ext4_blockdev *bdev;
303 struct ext4_sblock sb;
305 uint64_t inode_block_limits[4];
306 uint64_t inode_blocks_per_level[4];
308 uint32_t last_inode_bg_id;
310 struct jbd_fs *jbd_fs;
311 struct jbd_journal *jbd_journal;
312 struct jbd_trans *curr_trans;
315 /* Inode table/bitmap not in use */
316 #define EXT4_BLOCK_GROUP_INODE_UNINIT 0x0001
317 /* Block bitmap not in use */
318 #define EXT4_BLOCK_GROUP_BLOCK_UNINIT 0x0002
319 /* On-disk itable initialized to zero */
320 #define EXT4_BLOCK_GROUP_ITABLE_ZEROED 0x0004
323 * Structure of a blocks group descriptor
326 uint32_t block_bitmap_lo; /* Blocks bitmap block */
327 uint32_t inode_bitmap_lo; /* Inodes bitmap block */
328 uint32_t inode_table_first_block_lo; /* Inodes table block */
329 uint16_t free_blocks_count_lo; /* Free blocks count */
330 uint16_t free_inodes_count_lo; /* Free inodes count */
331 uint16_t used_dirs_count_lo; /* Directories count */
332 uint16_t flags; /* EXT4_BG_flags (INODE_UNINIT, etc) */
333 uint32_t exclude_bitmap_lo; /* Exclude bitmap for snapshots */
334 uint16_t block_bitmap_csum_lo; /* crc32c(s_uuid+grp_num+bbitmap) LE */
335 uint16_t inode_bitmap_csum_lo; /* crc32c(s_uuid+grp_num+ibitmap) LE */
336 uint16_t itable_unused_lo; /* Unused inodes count */
337 uint16_t checksum; /* crc16(sb_uuid+group+desc) */
339 uint32_t block_bitmap_hi; /* Blocks bitmap block MSB */
340 uint32_t inode_bitmap_hi; /* I-nodes bitmap block MSB */
341 uint32_t inode_table_first_block_hi; /* I-nodes table block MSB */
342 uint16_t free_blocks_count_hi; /* Free blocks count MSB */
343 uint16_t free_inodes_count_hi; /* Free i-nodes count MSB */
344 uint16_t used_dirs_count_hi; /* Directories count MSB */
345 uint16_t itable_unused_hi; /* Unused inodes count MSB */
346 uint32_t exclude_bitmap_hi; /* Exclude bitmap block MSB */
347 uint16_t block_bitmap_csum_hi; /* crc32c(s_uuid+grp_num+bbitmap) BE */
348 uint16_t inode_bitmap_csum_hi; /* crc32c(s_uuid+grp_num+ibitmap) BE */
349 uint32_t reserved; /* Padding */
352 struct ext4_block_group_ref {
353 struct ext4_block block;
354 struct ext4_bgroup *block_group;
360 #define EXT4_MIN_BLOCK_GROUP_DESCRIPTOR_SIZE 32
361 #define EXT4_MAX_BLOCK_GROUP_DESCRIPTOR_SIZE 64
363 #define EXT4_MIN_BLOCK_SIZE 1024 /* 1 KiB */
364 #define EXT4_MAX_BLOCK_SIZE 65536 /* 64 KiB */
365 #define EXT4_REV0_INODE_SIZE 128
367 #define EXT4_INODE_BLOCK_SIZE 512
369 #define EXT4_INODE_DIRECT_BLOCK_COUNT 12
370 #define EXT4_INODE_INDIRECT_BLOCK EXT4_INODE_DIRECT_BLOCK_COUNT
371 #define EXT4_INODE_DOUBLE_INDIRECT_BLOCK (EXT4_INODE_INDIRECT_BLOCK + 1)
372 #define EXT4_INODE_TRIPPLE_INDIRECT_BLOCK (EXT4_INODE_DOUBLE_INDIRECT_BLOCK + 1)
373 #define EXT4_INODE_BLOCKS (EXT4_INODE_TRIPPLE_INDIRECT_BLOCK + 1)
374 #define EXT4_INODE_INDIRECT_BLOCK_COUNT \
375 (EXT4_INODE_BLOCKS - EXT4_INODE_DIRECT_BLOCK_COUNT)
378 * Structure of an inode on the disk
381 uint16_t mode; /* File mode */
382 uint16_t uid; /* Low 16 bits of owner uid */
383 uint32_t size_lo; /* Size in bytes */
384 uint32_t access_time; /* Access time */
385 uint32_t change_inode_time; /* I-node change time */
386 uint32_t modification_time; /* Modification time */
387 uint32_t deletion_time; /* Deletion time */
388 uint16_t gid; /* Low 16 bits of group id */
389 uint16_t links_count; /* Links count */
390 uint32_t blocks_count_lo; /* Blocks count */
391 uint32_t flags; /* File flags */
392 uint32_t unused_osd1; /* OS dependent - not used in HelenOS */
393 uint32_t blocks[EXT4_INODE_BLOCKS]; /* Pointers to blocks */
394 uint32_t generation; /* File version (for NFS) */
395 uint32_t file_acl_lo; /* File ACL */
397 uint32_t obso_faddr; /* Obsoleted fragment address */
401 uint16_t blocks_high;
402 uint16_t file_acl_high;
405 uint16_t checksum_lo; /* crc32c(uuid+inum+inode) LE */
415 } __attribute__((packed)) osd2;
417 uint16_t extra_isize;
418 uint16_t checksum_hi; /* crc32c(uuid+inum+inode) BE */
419 uint32_t ctime_extra; /* Extra change time (nsec << 2 | epoch) */
420 uint32_t mtime_extra; /* Extra Modification time (nsec << 2 | epoch) */
421 uint32_t atime_extra; /* Extra Access time (nsec << 2 | epoch) */
422 uint32_t crtime; /* File creation time */
424 crtime_extra; /* Extra file creation time (nsec << 2 | epoch) */
425 uint32_t version_hi; /* High 32 bits for 64-bit version */
426 } __attribute__((packed));
428 #define EXT4_INODE_MODE_FIFO 0x1000
429 #define EXT4_INODE_MODE_CHARDEV 0x2000
430 #define EXT4_INODE_MODE_DIRECTORY 0x4000
431 #define EXT4_INODE_MODE_BLOCKDEV 0x6000
432 #define EXT4_INODE_MODE_FILE 0x8000
433 #define EXT4_INODE_MODE_SOFTLINK 0xA000
434 #define EXT4_INODE_MODE_SOCKET 0xC000
435 #define EXT4_INODE_MODE_TYPE_MASK 0xF000
440 #define EXT4_INODE_FLAG_SECRM 0x00000001 /* Secure deletion */
441 #define EXT4_INODE_FLAG_UNRM 0x00000002 /* Undelete */
442 #define EXT4_INODE_FLAG_COMPR 0x00000004 /* Compress file */
443 #define EXT4_INODE_FLAG_SYNC 0x00000008 /* Synchronous updates */
444 #define EXT4_INODE_FLAG_IMMUTABLE 0x00000010 /* Immutable file */
445 #define EXT4_INODE_FLAG_APPEND 0x00000020 /* writes to file may only append */
446 #define EXT4_INODE_FLAG_NODUMP 0x00000040 /* do not dump file */
447 #define EXT4_INODE_FLAG_NOATIME 0x00000080 /* do not update atime */
449 /* Compression flags */
450 #define EXT4_INODE_FLAG_DIRTY 0x00000100
451 #define EXT4_INODE_FLAG_COMPRBLK \
452 0x00000200 /* One or more compressed clusters */
453 #define EXT4_INODE_FLAG_NOCOMPR 0x00000400 /* Don't compress */
454 #define EXT4_INODE_FLAG_ECOMPR 0x00000800 /* Compression error */
456 #define EXT4_INODE_FLAG_INDEX 0x00001000 /* hash-indexed directory */
457 #define EXT4_INODE_FLAG_IMAGIC 0x00002000 /* AFS directory */
458 #define EXT4_INODE_FLAG_JOURNAL_DATA \
459 0x00004000 /* File data should be journaled */
460 #define EXT4_INODE_FLAG_NOTAIL 0x00008000 /* File tail should not be merged */
461 #define EXT4_INODE_FLAG_DIRSYNC \
462 0x00010000 /* Dirsync behaviour (directories only) */
463 #define EXT4_INODE_FLAG_TOPDIR 0x00020000 /* Top of directory hierarchies */
464 #define EXT4_INODE_FLAG_HUGE_FILE 0x00040000 /* Set to each huge file */
465 #define EXT4_INODE_FLAG_EXTENTS 0x00080000 /* Inode uses extents */
466 #define EXT4_INODE_FLAG_EA_INODE 0x00200000 /* Inode used for large EA */
467 #define EXT4_INODE_FLAG_EOFBLOCKS 0x00400000 /* Blocks allocated beyond EOF */
468 #define EXT4_INODE_FLAG_RESERVED 0x80000000 /* reserved for ext4 lib */
470 #define EXT4_INODE_ROOT_INDEX 2
472 struct ext4_inode_ref {
473 struct ext4_block block;
474 struct ext4_inode *inode;
480 #define EXT4_DIRECTORY_FILENAME_LEN 255
482 /**@brief Directory entry types. */
483 enum { EXT4_DE_UNKNOWN = 0,
492 #define EXT4_DIRENTRY_DIR_CSUM 0xDE
494 union ext4_dir_en_internal {
495 uint8_t name_length_high; /* Higher 8 bits of name length */
496 uint8_t inode_type; /* Type of referenced inode (in rev >= 0.5) */
497 } __attribute__((packed));
500 * Linked list directory entry structure
503 uint32_t inode; /* I-node for the entry */
504 uint16_t entry_len; /* Distance to the next directory entry */
505 uint8_t name_len; /* Lower 8 bits of name length */
507 union ext4_dir_en_internal in;
509 uint8_t name[EXT4_DIRECTORY_FILENAME_LEN]; /* Entry name */
510 } __attribute__((packed));
512 struct ext4_dir_iter {
513 struct ext4_inode_ref *inode_ref;
514 struct ext4_block curr_blk;
516 struct ext4_dir_en *curr;
519 struct ext4_dir_search_result {
520 struct ext4_block block;
521 struct ext4_dir_en *dentry;
524 /* Structures for indexed directory */
526 struct ext4_dir_idx_climit {
531 struct ext4_dir_idx_dot_en {
533 uint16_t entry_length;
539 struct ext4_dir_idx_rinfo {
540 uint32_t reserved_zero;
541 uint8_t hash_version;
543 uint8_t indirect_levels;
544 uint8_t unused_flags;
547 struct ext4_dir_idx_entry {
552 struct ext4_dir_idx_root {
553 struct ext4_dir_idx_dot_en dots[2];
554 struct ext4_dir_idx_rinfo info;
555 struct ext4_dir_idx_entry en[];
558 struct ext4_fake_dir_entry {
560 uint16_t entry_length;
565 struct ext4_dir_idx_node {
566 struct ext4_fake_dir_entry fake;
567 struct ext4_dir_idx_entry entries[];
570 struct ext4_dir_idx_block {
572 struct ext4_dir_idx_entry *entries;
573 struct ext4_dir_idx_entry *position;
577 * This goes at the end of each htree block.
579 struct ext4_dir_idx_tail {
581 uint32_t checksum; /* crc32c(uuid+inum+dirblock) */
585 * This is a bogus directory entry at the end of each leaf block that
588 struct ext4_dir_entry_tail {
589 uint32_t reserved_zero1; /* Pretend to be unused */
590 uint16_t rec_len; /* 12 */
591 uint8_t reserved_zero2; /* Zero name length */
592 uint8_t reserved_ft; /* 0xDE, fake file type */
593 uint32_t checksum; /* crc32c(uuid+inum+dirblock) */
596 #define EXT4_DIRENT_TAIL(block, blocksize) \
597 ((struct ext4_dir_entry_tail *)(((char *)(block)) + ((blocksize) - \
598 sizeof(struct ext4_dir_entry_tail))))
600 #define EXT4_ERR_BAD_DX_DIR (-25000)
602 #define EXT4_LINK_MAX 65000
604 #define EXT4_BAD_INO 1
605 #define EXT4_ROOT_INO 2
606 #define EXT4_BOOT_LOADER_INO 5
607 #define EXT4_UNDEL_DIR_INO 6
608 #define EXT4_RESIZE_INO 7
609 #define EXT4_JOURNAL_INO 8
611 #define EXT4_GOOD_OLD_FIRST_INO 11
613 #define EXT4_EXT_UNWRITTEN_MASK (1L << 15)
615 #define EXT4_EXT_MAX_LEN_WRITTEN (1L << 15)
616 #define EXT4_EXT_MAX_LEN_UNWRITTEN \
617 (EXT4_EXT_MAX_LEN_WRITTEN - 1)
619 #define EXT4_EXT_GET_LEN(ex) to_le16((ex)->block_count)
620 #define EXT4_EXT_GET_LEN_UNWRITTEN(ex) \
621 (EXT4_EXT_GET_LEN(ex) &= ~(EXT4_EXT_UNWRITTEN_MASK))
622 #define EXT4_EXT_SET_LEN(ex, count) \
623 ((ex)->block_count = to_le16(count))
625 #define EXT4_EXT_IS_UNWRITTEN(ex) \
626 (EXT4_EXT_GET_LEN(ex) > EXT4_EXT_MAX_LEN_WRITTEN)
627 #define EXT4_EXT_SET_UNWRITTEN(ex) \
628 ((ex)->block_count |= to_le16(EXT4_EXT_UNWRITTEN_MASK))
629 #define EXT4_EXT_SET_WRITTEN(ex) \
630 ((ex)->block_count &= ~(to_le16(EXT4_EXT_UNWRITTEN_MASK)))
632 * This is the extent tail on-disk structure.
633 * All other extent structures are 12 bytes long. It turns out that
634 * block_size % 12 >= 4 for at least all powers of 2 greater than 512, which
635 * covers all valid ext4 block sizes. Therefore, this tail structure can be
636 * crammed into the end of the block without having to rebalance the tree.
638 struct ext4_extent_tail
640 uint32_t et_checksum; /* crc32c(uuid+inum+extent_block) */
644 * This is the extent on-disk structure.
645 * It's used at the bottom of the tree.
648 uint32_t first_block; /* First logical block extent covers */
649 uint16_t block_count; /* Number of blocks covered by extent */
650 uint16_t start_hi; /* High 16 bits of physical block */
651 uint32_t start_lo; /* Low 32 bits of physical block */
655 * This is index on-disk structure.
656 * It's used at all the levels except the bottom.
658 struct ext4_extent_index {
659 uint32_t first_block; /* Index covers logical blocks from 'block' */
662 * Pointer to the physical block of the next
663 * level. leaf or next index could be there
664 * high 16 bits of physical block
672 * Each block (leaves and indexes), even inode-stored has header.
674 struct ext4_extent_header {
676 uint16_t entries_count; /* Number of valid entries */
677 uint16_t max_entries_count; /* Capacity of store in entries */
678 uint16_t depth; /* Has tree real underlying blocks? */
679 uint32_t generation; /* generation of the tree */
686 typedef uint32_t ext4_lblk_t;
687 typedef uint64_t ext4_fsblk_t;
690 * Array of ext4_ext_path contains path to some extent.
691 * Creation/lookup routines use it for traversal/splitting/etc.
692 * Truncate uses it to simulate recursive walking.
694 struct ext4_extent_path {
695 ext4_fsblk_t p_block;
696 struct ext4_block block;
699 struct ext4_extent_header *header;
700 struct ext4_extent_index *index;
701 struct ext4_extent *extent;
706 #define EXT4_EXTENT_MAGIC 0xF30A
708 #define EXT4_EXTENT_FIRST(header) \
709 ((struct ext4_extent *)(((char *)(header)) + \
710 sizeof(struct ext4_extent_header)))
712 #define EXT4_EXTENT_FIRST_INDEX(header) \
713 ((struct ext4_extent_index *)(((char *)(header)) + \
714 sizeof(struct ext4_extent_header)))
717 * EXT_INIT_MAX_LEN is the maximum number of blocks we can have in an
718 * initialized extent. This is 2^15 and not (2^16 - 1), since we use the
719 * MSB of ee_len field in the extent datastructure to signify if this
720 * particular extent is an initialized extent or an uninitialized (i.e.
722 * EXT_UNINIT_MAX_LEN is the maximum number of blocks we can have in an
723 * uninitialized extent.
724 * If ee_len is <= 0x8000, it is an initialized extent. Otherwise, it is an
725 * uninitialized one. In other words, if MSB of ee_len is set, it is an
726 * uninitialized extent with only one special scenario when ee_len = 0x8000.
727 * In this case we can not have an uninitialized extent of zero length and
728 * thus we make it as a special case of initialized extent with 0x8000 length.
729 * This way we get better extent-to-group alignment for initialized extents.
730 * Hence, the maximum number of blocks we can have in an *initialized*
731 * extent is 2^15 (32768) and in an *uninitialized* extent is 2^15-1 (32767).
733 #define EXT_INIT_MAX_LEN (1L << 15)
734 #define EXT_UNWRITTEN_MAX_LEN (EXT_INIT_MAX_LEN - 1)
736 #define EXT_EXTENT_SIZE sizeof(struct ext4_extent)
737 #define EXT_INDEX_SIZE sizeof(struct ext4_extent_idx)
739 #define EXT_FIRST_EXTENT(__hdr__) \
740 ((struct ext4_extent *)(((char *)(__hdr__)) + \
741 sizeof(struct ext4_extent_header)))
742 #define EXT_FIRST_INDEX(__hdr__) \
743 ((struct ext4_extent_index *)(((char *)(__hdr__)) + \
744 sizeof(struct ext4_extent_header)))
745 #define EXT_HAS_FREE_INDEX(__path__) \
746 ((__path__)->header->entries_count < (__path__)->header->max_entries_count)
747 #define EXT_LAST_EXTENT(__hdr__) \
748 (EXT_FIRST_EXTENT((__hdr__)) + (__hdr__)->entries_count - 1)
749 #define EXT_LAST_INDEX(__hdr__) \
750 (EXT_FIRST_INDEX((__hdr__)) + (__hdr__)->entries_count - 1)
751 #define EXT_MAX_EXTENT(__hdr__) \
752 (EXT_FIRST_EXTENT((__hdr__)) + (__hdr__)->max_entries_count - 1)
753 #define EXT_MAX_INDEX(__hdr__) \
754 (EXT_FIRST_INDEX((__hdr__)) + (__hdr__)->max_entries_count - 1)
756 #define EXT4_EXTENT_TAIL_OFFSET(hdr) \
757 (sizeof(struct ext4_extent_header) + \
758 (sizeof(struct ext4_extent) * (hdr)->max_entries_count))
761 * ext4_ext_next_allocated_block:
762 * returns allocated block in subsequent extent or EXT_MAX_BLOCKS.
763 * NOTE: it considers block number from index entry as
764 * allocated block. Thus, index entries have to be consistent
767 #define EXT_MAX_BLOCKS (ext4_lblk_t) (-1)
769 #define IN_RANGE(b, first, len) ((b) >= (first) && (b) <= (first) + (len) - 1)
772 /******************************************************************************/
774 /* EXT3 HTree directory indexing */
775 #define EXT2_HTREE_LEGACY 0
776 #define EXT2_HTREE_HALF_MD4 1
777 #define EXT2_HTREE_TEA 2
778 #define EXT2_HTREE_LEGACY_UNSIGNED 3
779 #define EXT2_HTREE_HALF_MD4_UNSIGNED 4
780 #define EXT2_HTREE_TEA_UNSIGNED 5
782 #define EXT2_HTREE_EOF 0x7FFFFFFFUL
784 struct ext4_hash_info {
787 uint32_t hash_version;
788 const uint32_t *seed;
791 /* Extended Attribute(EA) */
793 /* Magic value in attribute blocks */
794 #define EXT4_XATTR_MAGIC 0xEA020000
796 /* Maximum number of references to one attribute block */
797 #define EXT4_XATTR_REFCOUNT_MAX 1024
800 #define EXT4_XATTR_INDEX_USER 1
801 #define EXT4_XATTR_INDEX_POSIX_ACL_ACCESS 2
802 #define EXT4_XATTR_INDEX_POSIX_ACL_DEFAULT 3
803 #define EXT4_XATTR_INDEX_TRUSTED 4
804 #define EXT4_XATTR_INDEX_LUSTRE 5
805 #define EXT4_XATTR_INDEX_SECURITY 6
806 #define EXT4_XATTR_INDEX_SYSTEM 7
807 #define EXT4_XATTR_INDEX_RICHACL 8
808 #define EXT4_XATTR_INDEX_ENCRYPTION 9
810 struct ext4_xattr_header {
811 uint32_t h_magic; /* magic number for identification */
812 uint32_t h_refcount; /* reference count */
813 uint32_t h_blocks; /* number of disk blocks used */
814 uint32_t h_hash; /* hash value of all attributes */
815 uint32_t h_checksum; /* crc32c(uuid+id+xattrblock) */
816 /* id = inum if refcount=1, blknum otherwise */
817 uint32_t h_reserved[3]; /* zero right now */
818 } __attribute__((packed));
820 struct ext4_xattr_ibody_header {
821 uint32_t h_magic; /* magic number for identification */
822 } __attribute__((packed));
824 struct ext4_xattr_entry {
825 uint8_t e_name_len; /* length of name */
826 uint8_t e_name_index; /* attribute name index */
827 uint16_t e_value_offs; /* offset in disk block of value */
828 uint32_t e_value_block; /* disk block attribute is stored on (n/i) */
829 uint32_t e_value_size; /* size of attribute value */
830 uint32_t e_hash; /* hash value of name and value */
831 } __attribute__((packed));
833 struct ext4_xattr_item {
834 /* This attribute should be stored in inode body */
843 RB_ENTRY(ext4_xattr_item) node;
846 struct ext4_xattr_ref {
848 struct ext4_block block;
849 struct ext4_inode_ref *inode_ref;
855 struct ext4_xattr_item *iter_from;
857 RB_HEAD(ext4_xattr_tree,
858 ext4_xattr_item) root;
861 #define EXT4_XATTR_ITERATE_CONT 0
862 #define EXT4_XATTR_ITERATE_STOP 1
863 #define EXT4_XATTR_ITERATE_PAUSE 2
865 #define EXT4_GOOD_OLD_INODE_SIZE 128
867 #define EXT4_XATTR_PAD_BITS 2
868 #define EXT4_XATTR_PAD (1<<EXT4_XATTR_PAD_BITS)
869 #define EXT4_XATTR_ROUND (EXT4_XATTR_PAD-1)
870 #define EXT4_XATTR_LEN(name_len) \
871 (((name_len) + EXT4_XATTR_ROUND + \
872 sizeof(struct ext4_xattr_entry)) & ~EXT4_XATTR_ROUND)
873 #define EXT4_XATTR_NEXT(entry) \
874 ((struct ext4_xattr_entry *)( \
875 (char *)(entry) + EXT4_XATTR_LEN((entry)->e_name_len)))
876 #define EXT4_XATTR_SIZE(size) \
877 (((size) + EXT4_XATTR_ROUND) & ~EXT4_XATTR_ROUND)
878 #define EXT4_XATTR_NAME(entry) \
879 ((char *)((entry) + 1))
881 #define EXT4_XATTR_IHDR(raw_inode) \
882 ((struct ext4_xattr_ibody_header *) \
883 ((char *)raw_inode + \
884 EXT4_GOOD_OLD_INODE_SIZE + \
885 (raw_inode)->extra_isize))
886 #define EXT4_XATTR_IFIRST(hdr) \
887 ((struct ext4_xattr_entry *)((hdr)+1))
889 #define EXT4_XATTR_BHDR(block) \
890 ((struct ext4_xattr_header *)((block)->data))
891 #define EXT4_XATTR_ENTRY(ptr) \
892 ((struct ext4_xattr_entry *)(ptr))
893 #define EXT4_XATTR_BFIRST(block) \
894 EXT4_XATTR_ENTRY(EXT4_XATTR_BHDR(block)+1)
895 #define EXT4_XATTR_IS_LAST_ENTRY(entry) \
896 (*(uint32_t *)(entry) == 0)
898 #define EXT4_ZERO_XATTR_VALUE ((void *)-1)
900 /*****************************************************************************/
903 * JBD stores integers in big endian.
906 #define JBD_MAGIC_NUMBER 0xc03b3998U /* The first 4 bytes of /dev/random! */
909 * Descriptor block types:
912 #define JBD_DESCRIPTOR_BLOCK 1
913 #define JBD_COMMIT_BLOCK 2
914 #define JBD_SUPERBLOCK 3
915 #define JBD_SUPERBLOCK_V2 4
916 #define JBD_REVOKE_BLOCK 5
919 * Standard header for all descriptor blocks:
930 #define JBD_CRC32_CHKSUM 1
931 #define JBD_MD5_CHKSUM 2
932 #define JBD_SHA1_CHKSUM 3
933 #define JBD_CRC32C_CHKSUM 4
935 #define JBD_CRC32_CHKSUM_SIZE 4
937 #define JBD_CHECKSUM_BYTES (32 / sizeof(uint32_t))
939 * Commit block header for storing transactional checksums:
941 * NOTE: If FEATURE_COMPAT_CHECKSUM (checksum v1) is set, the h_chksum*
942 * fields are used to store a checksum of the descriptor and data blocks.
944 * If FEATURE_INCOMPAT_CSUM_V2 (checksum v2) is set, then the h_chksum
945 * field is used to store crc32c(uuid+commit_block). Each journal metadata
946 * block gets its own checksum, and data block checksums are stored in
947 * journal_block_tag (in the descriptor). The other h_chksum* fields are
950 * If FEATURE_INCOMPAT_CSUM_V3 is set, the descriptor block uses
951 * journal_block_tag3_t to store a full 32-bit checksum. Everything else
954 * Checksum v1, v2, and v3 are mutually exclusive features.
956 struct jbd_commit_header {
957 struct jbd_bhdr header;
961 uint32_t chksum[JBD_CHECKSUM_BYTES];
963 uint32_t commit_nsec;
967 * The block tag: used to describe a single buffer in the journal
969 struct jbd_block_tag3 {
970 uint32_t blocknr; /* The on-disk block number */
971 uint32_t flags; /* See below */
972 uint32_t blocknr_high; /* most-significant high 32bits. */
973 uint32_t checksum; /* crc32c(uuid+seq+block) */
976 struct jbd_block_tag {
977 uint32_t blocknr; /* The on-disk block number */
978 uint16_t checksum; /* truncated crc32c(uuid+seq+block) */
979 uint16_t flags; /* See below */
980 uint32_t blocknr_high; /* most-significant high 32bits. */
983 /* Definitions for the journal tag flags word: */
984 #define JBD_FLAG_ESCAPE 1 /* on-disk block is escaped */
985 #define JBD_FLAG_SAME_UUID 2 /* block has same uuid as previous */
986 #define JBD_FLAG_DELETED 4 /* block deleted by this transaction */
987 #define JBD_FLAG_LAST_TAG 8 /* last tag in this descriptor block */
989 /* Tail of descriptor block, for checksumming */
990 struct jbd_block_tail {
995 * The revoke descriptor: used on disk to describe a series of blocks to
996 * be revoked from the log
998 struct jbd_revoke_header {
999 struct jbd_bhdr header;
1000 uint32_t count; /* Count of bytes used in the block */
1003 /* Tail of revoke block, for checksumming */
1004 struct jbd_revoke_tail {
1008 #define JBD_USERS_MAX 48
1009 #define JBD_USERS_SIZE (UUID_SIZE * JBD_USERS_MAX)
1012 * The journal superblock. All fields are in big-endian byte order.
1016 struct jbd_bhdr header;
1019 /* Static information describing the journal */
1020 uint32_t blocksize; /* journal device blocksize */
1021 uint32_t maxlen; /* total blocks in journal file */
1022 uint32_t first; /* first block of log information */
1025 /* Dynamic information describing the current state of the log */
1026 uint32_t sequence; /* first commit ID expected in log */
1027 uint32_t start; /* blocknr of start of log */
1030 /* Error value, as set by journal_abort(). */
1034 /* Remaining fields are only valid in a version-2 superblock */
1035 uint32_t feature_compat; /* compatible feature set */
1036 uint32_t feature_incompat; /* incompatible feature set */
1037 uint32_t feature_ro_compat; /* readonly-compatible feature set */
1039 uint8_t uuid[UUID_SIZE]; /* 128-bit uuid for journal */
1042 uint32_t nr_users; /* Nr of filesystems sharing log */
1044 uint32_t dynsuper; /* Blocknr of dynamic superblock copy*/
1047 uint32_t max_transaction; /* Limit of journal blocks per trans.*/
1048 uint32_t max_trandata; /* Limit of data blocks per trans. */
1051 uint8_t checksum_type; /* checksum type */
1052 uint8_t padding2[3];
1053 uint32_t padding[42];
1054 uint32_t checksum; /* crc32c(superblock) */
1057 uint8_t users[JBD_USERS_SIZE]; /* ids of all fs'es sharing the log */
1062 #define JBD_SUPERBLOCK_SIZE sizeof(struct jbd_sb)
1064 #define JBD_HAS_COMPAT_FEATURE(jsb,mask) \
1065 ((jsb)->header.blocktype >= to_be32(2) && \
1066 ((jsb)->feature_compat & to_be32((mask))))
1067 #define JBD_HAS_RO_COMPAT_FEATURE(jsb,mask) \
1068 ((jsb)->header.blocktype >= to_be32(2) && \
1069 ((jsb)->feature_ro_compat & to_be32((mask))))
1070 #define JBD_HAS_INCOMPAT_FEATURE(jsb,mask) \
1071 ((jsb)->header.blocktype >= to_be32(2) && \
1072 ((jsb)->feature_incompat & to_be32((mask))))
1074 #define JBD_FEATURE_COMPAT_CHECKSUM 0x00000001
1076 #define JBD_FEATURE_INCOMPAT_REVOKE 0x00000001
1077 #define JBD_FEATURE_INCOMPAT_64BIT 0x00000002
1078 #define JBD_FEATURE_INCOMPAT_ASYNC_COMMIT 0x00000004
1079 #define JBD_FEATURE_INCOMPAT_CSUM_V2 0x00000008
1080 #define JBD_FEATURE_INCOMPAT_CSUM_V3 0x00000010
1082 /* Features known to this kernel version: */
1083 #define JBD_KNOWN_COMPAT_FEATURES 0
1084 #define JBD_KNOWN_ROCOMPAT_FEATURES 0
1085 #define JBD_KNOWN_INCOMPAT_FEATURES (JBD_FEATURE_INCOMPAT_REVOKE|\
1086 JBD_FEATURE_INCOMPAT_ASYNC_COMMIT|\
1087 JBD_FEATURE_INCOMPAT_64BIT|\
1088 JBD_FEATURE_INCOMPAT_CSUM_V2|\
1089 JBD_FEATURE_INCOMPAT_CSUM_V3)
1092 /* If journal block device is used, bdev will be non-null */
1093 struct ext4_blockdev *bdev;
1094 struct ext4_inode_ref inode_ref;
1101 struct ext4_block block;
1102 struct jbd_trans *trans;
1103 struct jbd_block_rec *block_rec;
1104 TAILQ_ENTRY(jbd_buf) buf_node;
1107 struct jbd_revoke_rec {
1109 LIST_ENTRY(jbd_revoke_rec) revoke_node;
1112 struct jbd_block_rec {
1114 struct ext4_buf *buf;
1115 struct jbd_trans *trans;
1116 RB_ENTRY(jbd_block_rec) block_rec_node;
1117 LIST_ENTRY(jbd_block_rec) tbrec_node;
1123 uint32_t start_iblock;
1130 struct jbd_journal *journal;
1132 TAILQ_HEAD(jbd_trans_buf, jbd_buf) buf_queue;
1133 LIST_HEAD(jbd_revoke_list, jbd_revoke_rec) revoke_list;
1134 LIST_HEAD(jbd_trans_block_rec, jbd_block_rec) tbrec_list;
1135 TAILQ_ENTRY(jbd_trans) trans_node;
1138 struct jbd_journal {
1143 uint32_t alloc_trans_id;
1145 uint32_t block_size;
1147 TAILQ_HEAD(jbd_trans_queue, jbd_trans) trans_queue;
1148 TAILQ_HEAD(jbd_cp_queue, jbd_trans) cp_queue;
1149 RB_HEAD(jbd_block, jbd_block_rec) block_rec_root;
1151 struct jbd_fs *jbd_fs;
1154 /*****************************************************************************/
1156 #define EXT4_CRC32_INIT (0xFFFFFFFFUL)
1158 /*****************************************************************************/
1160 static inline uint64_t reorder64(uint64_t n)
1162 return ((n & 0xff) << 56) |
1163 ((n & 0xff00) << 40) |
1164 ((n & 0xff0000) << 24) |
1165 ((n & 0xff000000LL) << 8) |
1166 ((n & 0xff00000000LL) >> 8) |
1167 ((n & 0xff0000000000LL) >> 24) |
1168 ((n & 0xff000000000000LL) >> 40) |
1169 ((n & 0xff00000000000000LL) >> 56);
1172 static inline uint32_t reorder32(uint32_t n)
1174 return ((n & 0xff) << 24) |
1175 ((n & 0xff00) << 8) |
1176 ((n & 0xff0000) >> 8) |
1177 ((n & 0xff000000) >> 24);
1180 static inline uint16_t reorder16(uint16_t n)
1182 return ((n & 0xff) << 8) |
1183 ((n & 0xff00) >> 8);
1186 #ifdef CONFIG_BIG_ENDIAN
1187 #define to_le64(_n) reorder64(_n)
1188 #define to_le32(_n) reorder32(_n)
1189 #define to_le16(_n) reorder16(_n)
1191 #define to_be64(_n) _n
1192 #define to_be32(_n) _n
1193 #define to_be16(_n) _n
1196 #define to_le64(_n) _n
1197 #define to_le32(_n) _n
1198 #define to_le16(_n) _n
1200 #define to_be64(_n) reorder64(_n)
1201 #define to_be32(_n) reorder32(_n)
1202 #define to_be16(_n) reorder16(_n)
1205 /****************************Access macros to ext4 structures*****************/
1207 #define ext4_get32(s, f) to_le32((s)->f)
1208 #define ext4_get16(s, f) to_le16((s)->f)
1209 #define ext4_get8(s, f) (s)->f
1211 #define ext4_set32(s, f, v) \
1213 (s)->f = to_le32(v); \
1215 #define ext4_set16(s, f, v) \
1217 (s)->f = to_le16(v); \
1220 (s, f, v) do { (s)->f = (v); } \
1223 /****************************Access macros to jbd2 structures*****************/
1225 #define jbd_get32(s, f) to_be32((s)->f)
1226 #define jbd_get16(s, f) to_be16((s)->f)
1227 #define jbd_get8(s, f) (s)->f
1229 #define jbd_set32(s, f, v) \
1231 (s)->f = to_be32(v); \
1233 #define jbd_set16(s, f, v) \
1235 (s)->f = to_be16(v); \
1238 (s, f, v) do { (s)->f = (v); } \
1243 #define __unused __attribute__ ((__unused__))
1248 #define offsetof(type, field) \
1249 ((size_t)(&(((type *)0)->field)))
1256 #endif /* EXT4_TYPES_H_ */