]> code.delx.au - refind/blob - filesystems/fsw_ext4_disk.h
Added rudimentary debconf support for Debian package.
[refind] / filesystems / fsw_ext4_disk.h
1 /**
2 * \file fsw_ext4_disk.h
3 * ext4 file system on-disk structures.
4 */
5
6 /*-
7 * Copyright (c) 2012 Stefan Agner
8 * Portions Copyright (c) 2006 Christoph Pfisterer
9 * Portions Copyright (c) 1991-2012 by various Linux kernel contributors
10 *
11 * This program is free software; you can redistribute it and/or
12 * modify it under the terms of the GNU General Public License
13 * as published by the Free Software Foundation; either version 2
14 * of the License, or (at your option) any later version.
15 *
16 * This program is distributed in the hope that it will be useful,
17 * but WITHOUT ANY WARRANTY; without even the implied warranty of
18 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
19 * GNU General Public License for more details.
20 *
21 * You should have received a copy of the GNU General Public License
22 * along with this program; if not, write to the Free Software
23 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
24 */
25
26 #ifndef _FSW_EXT4_DISK_H_
27 #define _FSW_EXT4_DISK_H_
28
29 // types
30
31 typedef fsw_s8 __s8;
32 typedef fsw_u8 __u8;
33 typedef fsw_s16 __s16;
34 typedef fsw_u16 __u16;
35 typedef fsw_s32 __s32;
36 typedef fsw_u32 __u32;
37 typedef fsw_s64 __s64;
38 typedef fsw_u64 __u64;
39
40 typedef __u16 __le16;
41 typedef __u32 __le32;
42 typedef __u64 __le64;
43
44 //
45 // from Linux kernel, fs/ext4/ext4.h
46 //
47
48 /*
49 * Special inode numbers
50 */
51 #define EXT4_BAD_INO 1 /* Bad blocks inode */
52 #define EXT4_ROOT_INO 2 /* Root inode */
53 #define EXT4_USR_QUOTA_INO 3 /* User quota inode */
54 #define EXT4_GRP_QUOTA_INO 4 /* Group quota inode */
55 #define EXT4_BOOT_LOADER_INO 5 /* Boot loader inode */
56 #define EXT4_UNDEL_DIR_INO 6 /* Undelete directory inode */
57 #define EXT4_RESIZE_INO 7 /* Reserved group descriptors inode */
58 #define EXT4_JOURNAL_INO 8 /* Journal inode */
59
60 /*
61 * The second extended file system magic number
62 */
63 #define EXT4_SUPER_MAGIC 0xEF53
64
65 /*
66 * Macro-instructions used to manage several block sizes
67 */
68 #define EXT4_MIN_BLOCK_SIZE 1024
69 #define EXT4_MAX_BLOCK_SIZE 4096
70 #define EXT4_MIN_BLOCK_LOG_SIZE 10
71 #define EXT4_BLOCK_SIZE(s) (EXT4_MIN_BLOCK_SIZE << (s)->s_log_block_size)
72 #define EXT4_ADDR_PER_BLOCK(s) (EXT4_BLOCK_SIZE(s) / sizeof (__u32))
73 #define EXT4_BLOCK_SIZE_BITS(s) ((s)->s_log_block_size + 10)
74 #define EXT4_INODE_SIZE(s) (((s)->s_rev_level == EXT4_GOOD_OLD_REV) ? \
75 EXT4_GOOD_OLD_INODE_SIZE : \
76 (s)->s_inode_size)
77
78 /*
79 * Structure of a blocks group descriptor
80 */
81 struct ext4_group_desc
82 {
83 __le32 bg_block_bitmap_lo; /* Blocks bitmap block */
84 __le32 bg_inode_bitmap_lo; /* Inodes bitmap block */
85 __le32 bg_inode_table_lo; /* Inodes table block */
86 __le16 bg_free_blocks_count_lo;/* Free blocks count */
87 __le16 bg_free_inodes_count_lo;/* Free inodes count */
88 __le16 bg_used_dirs_count_lo; /* Directories count */
89 __le16 bg_flags; /* EXT4_BG_flags (INODE_UNINIT, etc) */
90 __le32 bg_exclude_bitmap_lo; /* Exclude bitmap for snapshots */
91 __le16 bg_block_bitmap_csum_lo;/* crc32c(s_uuid+grp_num+bbitmap) LE */
92 __le16 bg_inode_bitmap_csum_lo;/* crc32c(s_uuid+grp_num+ibitmap) LE */
93 __le16 bg_itable_unused_lo; /* Unused inodes count */
94 __le16 bg_checksum; /* crc16(sb_uuid+group+desc) */
95 __le32 bg_block_bitmap_hi; /* Blocks bitmap block MSB */
96 __le32 bg_inode_bitmap_hi; /* Inodes bitmap block MSB */
97 __le32 bg_inode_table_hi; /* Inodes table block MSB */
98 __le16 bg_free_blocks_count_hi;/* Free blocks count MSB */
99 __le16 bg_free_inodes_count_hi;/* Free inodes count MSB */
100 __le16 bg_used_dirs_count_hi; /* Directories count MSB */
101 __le16 bg_itable_unused_hi; /* Unused inodes count MSB */
102 __le32 bg_exclude_bitmap_hi; /* Exclude bitmap block MSB */
103 __le16 bg_block_bitmap_csum_hi;/* crc32c(s_uuid+grp_num+bbitmap) BE */
104 __le16 bg_inode_bitmap_csum_hi;/* crc32c(s_uuid+grp_num+ibitmap) BE */
105 __u32 bg_reserved;
106 };
107
108
109 /*
110 * Macro-instructions used to manage group descriptors
111 */
112 #define EXT4_MIN_DESC_SIZE 32
113 #define EXT4_MIN_DESC_SIZE_64BIT 64
114 #define EXT4_MAX_DESC_SIZE EXT4_MIN_BLOCK_SIZE
115 #define EXT4_DESC_SIZE(s) ((s)->s_desc_size)
116 #define EXT4_BLOCKS_PER_GROUP(s) ((s)->s_blocks_per_group)
117 #define EXT4_DESC_PER_BLOCK(s) (EXT4_BLOCK_SIZE(s) / EXT4_DESC_SIZE(s))
118 #define EXT4_INODES_PER_GROUP(s) ((s)->s_inodes_per_group)
119
120 /*
121 * Constants relative to the data blocks
122 */
123 #define EXT4_NDIR_BLOCKS 12
124 #define EXT4_IND_BLOCK EXT4_NDIR_BLOCKS
125 #define EXT4_DIND_BLOCK (EXT4_IND_BLOCK + 1)
126 #define EXT4_TIND_BLOCK (EXT4_DIND_BLOCK + 1)
127 #define EXT4_N_BLOCKS (EXT4_TIND_BLOCK + 1)
128
129 /*
130 * Inode flags
131 */
132 #define EXT4_SECRM_FL 0x00000001 /* Secure deletion */
133 #define EXT4_UNRM_FL 0x00000002 /* Undelete */
134 #define EXT4_COMPR_FL 0x00000004 /* Compress file */
135 #define EXT4_SYNC_FL 0x00000008 /* Synchronous updates */
136 #define EXT4_IMMUTABLE_FL 0x00000010 /* Immutable file */
137 #define EXT4_APPEND_FL 0x00000020 /* writes to file may only append */
138 #define EXT4_NODUMP_FL 0x00000040 /* do not dump file */
139 #define EXT4_NOATIME_FL 0x00000080 /* do not update atime */
140 /* Reserved for compression usage... */
141 #define EXT4_DIRTY_FL 0x00000100
142 #define EXT4_COMPRBLK_FL 0x00000200 /* One or more compressed clusters */
143 #define EXT4_NOCOMP_FL 0x00000400 /* Don't compress */
144 #define EXT4_ECOMPR_FL 0x00000800 /* Compression error */
145 /* End compression flags --- maybe not all used */
146 #define EXT4_INDEX_FL 0x00001000 /* hash-indexed directory */
147 #define EXT4_IMAGIC_FL 0x00002000 /* AFS directory */
148 #define EXT4_JOURNAL_DATA_FL 0x00004000 /* Reserved for ext3 */
149 #define EXT4_NOTAIL_FL 0x00008000 /* file tail should not be merged */
150 #define EXT4_DIRSYNC_FL 0x00010000 /* dirsync behaviour (directories only) */
151 #define EXT4_TOPDIR_FL 0x00020000 /* Top of directory hierarchies*/
152 #define EXT4_HUGE_FILE_FL 0x00040000 /* Set to each huge file */
153 #define EXT4_EXTENTS_FL 0x00080000 /* Inode uses extents */
154 #define EXT4_EA_INODE_FL 0x00200000 /* Inode used for large EA */
155 #define EXT4_EOFBLOCKS_FL 0x00400000 /* Blocks allocated beyond EOF */
156 #define EXT4_RESERVED_FL 0x80000000 /* reserved for ext4 lib */
157
158 #define EXT4_FL_USER_VISIBLE 0x004BDFFF /* User visible flags */
159 #define EXT4_FL_USER_MODIFIABLE 0x004B80FF /* User modifiable flags */
160
161
162 /*
163 * Structure of an inode on the disk
164 */
165 struct ext4_inode {
166 __le16 i_mode; /* File mode */
167 __le16 i_uid; /* Low 16 bits of Owner Uid */
168 __le32 i_size_lo; /* Size in bytes */
169 __le32 i_atime; /* Access time */
170 __le32 i_ctime; /* Inode Change time */
171 __le32 i_mtime; /* Modification time */
172 __le32 i_dtime; /* Deletion Time */
173 __le16 i_gid; /* Low 16 bits of Group Id */
174 __le16 i_links_count; /* Links count */
175 __le32 i_blocks_lo; /* Blocks count */
176 __le32 i_flags; /* File flags */
177 union {
178 struct {
179 __le32 l_i_version;
180 } linux1;
181 struct {
182 __u32 h_i_translator;
183 } hurd1;
184 struct {
185 __u32 m_i_reserved1;
186 } masix1;
187 } osd1; /* OS dependent 1 */
188 __le32 i_block[EXT4_N_BLOCKS];/* Pointers to blocks */
189 __le32 i_generation; /* File version (for NFS) */
190 __le32 i_file_acl_lo; /* File ACL */
191 __le32 i_size_high;
192 __le32 i_obso_faddr; /* Obsoleted fragment address */
193 union {
194 struct {
195 __le16 l_i_blocks_high; /* were l_i_reserved1 */
196 __le16 l_i_file_acl_high;
197 __le16 l_i_uid_high; /* these 2 fields */
198 __le16 l_i_gid_high; /* were reserved2[0] */
199 __le16 l_i_checksum_lo;/* crc32c(uuid+inum+inode) LE */
200 __le16 l_i_reserved;
201 } linux2;
202 struct {
203 __le16 h_i_reserved1; /* Obsoleted fragment number/size which are removed in ext4 */
204 __u16 h_i_mode_high;
205 __u16 h_i_uid_high;
206 __u16 h_i_gid_high;
207 __u32 h_i_author;
208 } hurd2;
209 struct {
210 __le16 h_i_reserved1; /* Obsoleted fragment number/size which are removed in ext4 */
211 __le16 m_i_file_acl_high;
212 __u32 m_i_reserved2[2];
213 } masix2;
214 } osd2; /* OS dependent 2 */
215 __le16 i_extra_isize;
216 __le16 i_checksum_hi; /* crc32c(uuid+inum+inode) BE */
217 __le32 i_ctime_extra; /* extra Change time (nsec << 2 | epoch) */
218 __le32 i_mtime_extra; /* extra Modification time(nsec << 2 | epoch) */
219 __le32 i_atime_extra; /* extra Access time (nsec << 2 | epoch) */
220 __le32 i_crtime; /* File Creation time */
221 __le32 i_crtime_extra; /* extra FileCreationtime (nsec << 2 | epoch) */
222 __le32 i_version_hi; /* high 32 bits for 64-bit version */
223 };
224
225
226 /*
227 * Inode flags used for atomic set/get
228 */
229 enum {
230 EXT4_INODE_SECRM = 0, /* Secure deletion */
231 EXT4_INODE_UNRM = 1, /* Undelete */
232 EXT4_INODE_COMPR = 2, /* Compress file */
233 EXT4_INODE_SYNC = 3, /* Synchronous updates */
234 EXT4_INODE_IMMUTABLE = 4, /* Immutable file */
235 EXT4_INODE_APPEND = 5, /* writes to file may only append */
236 EXT4_INODE_NODUMP = 6, /* do not dump file */
237 EXT4_INODE_NOATIME = 7, /* do not update atime */
238 /* Reserved for compression usage... */
239 EXT4_INODE_DIRTY = 8,
240 EXT4_INODE_COMPRBLK = 9, /* One or more compressed clusters */
241 EXT4_INODE_NOCOMPR = 10, /* Don't compress */
242 EXT4_INODE_ECOMPR = 11, /* Compression error */
243 /* End compression flags --- maybe not all used */
244 EXT4_INODE_INDEX = 12, /* hash-indexed directory */
245 EXT4_INODE_IMAGIC = 13, /* AFS directory */
246 EXT4_INODE_JOURNAL_DATA = 14, /* file data should be journaled */
247 EXT4_INODE_NOTAIL = 15, /* file tail should not be merged */
248 EXT4_INODE_DIRSYNC = 16, /* dirsync behaviour (directories only) */
249 EXT4_INODE_TOPDIR = 17, /* Top of directory hierarchies*/
250 EXT4_INODE_HUGE_FILE = 18, /* Set to each huge file */
251 EXT4_INODE_EXTENTS = 19, /* Inode uses extents */
252 EXT4_INODE_EA_INODE = 21, /* Inode used for large EA */
253 EXT4_INODE_EOFBLOCKS = 22, /* Blocks allocated beyond EOF */
254 EXT4_INODE_RESERVED = 31, /* reserved for ext4 lib */
255 };
256
257 /*
258 * Structure of the super block
259 */
260 struct ext4_super_block {
261 /*00*/ __le32 s_inodes_count; /* Inodes count */
262 __le32 s_blocks_count_lo; /* Blocks count */
263 __le32 s_r_blocks_count_lo; /* Reserved blocks count */
264 __le32 s_free_blocks_count_lo; /* Free blocks count */
265 /*10*/ __le32 s_free_inodes_count; /* Free inodes count */
266 __le32 s_first_data_block; /* First Data Block */
267 __le32 s_log_block_size; /* Block size */
268 __le32 s_log_cluster_size; /* Allocation cluster size */
269 /*20*/ __le32 s_blocks_per_group; /* # Blocks per group */
270 __le32 s_clusters_per_group; /* # Clusters per group */
271 __le32 s_inodes_per_group; /* # Inodes per group */
272 __le32 s_mtime; /* Mount time */
273 /*30*/ __le32 s_wtime; /* Write time */
274 __le16 s_mnt_count; /* Mount count */
275 __le16 s_max_mnt_count; /* Maximal mount count */
276 __le16 s_magic; /* Magic signature */
277 __le16 s_state; /* File system state */
278 __le16 s_errors; /* Behaviour when detecting errors */
279 __le16 s_minor_rev_level; /* minor revision level */
280 /*40*/ __le32 s_lastcheck; /* time of last check */
281 __le32 s_checkinterval; /* max. time between checks */
282 __le32 s_creator_os; /* OS */
283 __le32 s_rev_level; /* Revision level */
284 /*50*/ __le16 s_def_resuid; /* Default uid for reserved blocks */
285 __le16 s_def_resgid; /* Default gid for reserved blocks */
286 /*
287 * These fields are for EXT4_DYNAMIC_REV superblocks only.
288 *
289 * Note: the difference between the compatible feature set and
290 * the incompatible feature set is that if there is a bit set
291 * in the incompatible feature set that the kernel doesn't
292 * know about, it should refuse to mount the filesystem.
293 *
294 * e2fsck's requirements are more strict; if it doesn't know
295 * about a feature in either the compatible or incompatible
296 * feature set, it must abort and not try to meddle with
297 * things it doesn't understand...
298 */
299 __le32 s_first_ino; /* First non-reserved inode */
300 __le16 s_inode_size; /* size of inode structure */
301 __le16 s_block_group_nr; /* block group # of this superblock */
302 __le32 s_feature_compat; /* compatible feature set */
303 /*60*/ __le32 s_feature_incompat; /* incompatible feature set */
304 __le32 s_feature_ro_compat; /* readonly-compatible feature set */
305 /*68*/ __u8 s_uuid[16]; /* 128-bit uuid for volume */
306 /*78*/ char s_volume_name[16]; /* volume name */
307 /*88*/ char s_last_mounted[64]; /* directory where last mounted */
308 /*C8*/ __le32 s_algorithm_usage_bitmap; /* For compression */
309 /*
310 * Performance hints. Directory preallocation should only
311 * happen if the EXT4_FEATURE_COMPAT_DIR_PREALLOC flag is on.
312 */
313 __u8 s_prealloc_blocks; /* Nr of blocks to try to preallocate*/
314 __u8 s_prealloc_dir_blocks; /* Nr to preallocate for dirs */
315 __le16 s_reserved_gdt_blocks; /* Per group desc for online growth */
316 /*
317 * Journaling support valid if EXT4_FEATURE_COMPAT_HAS_JOURNAL set.
318 */
319 /*D0*/ __u8 s_journal_uuid[16]; /* uuid of journal superblock */
320 /*E0*/ __le32 s_journal_inum; /* inode number of journal file */
321 __le32 s_journal_dev; /* device number of journal file */
322 __le32 s_last_orphan; /* start of list of inodes to delete */
323 __le32 s_hash_seed[4]; /* HTREE hash seed */
324 __u8 s_def_hash_version; /* Default hash version to use */
325 __u8 s_jnl_backup_type;
326 __le16 s_desc_size; /* size of group descriptor */
327 /*100*/ __le32 s_default_mount_opts;
328 __le32 s_first_meta_bg; /* First metablock block group */
329 __le32 s_mkfs_time; /* When the filesystem was created */
330 __le32 s_jnl_blocks[17]; /* Backup of the journal inode */
331 /* 64bit support valid if EXT4_FEATURE_COMPAT_64BIT */
332 /*150*/ __le32 s_blocks_count_hi; /* Blocks count */
333 __le32 s_r_blocks_count_hi; /* Reserved blocks count */
334 __le32 s_free_blocks_count_hi; /* Free blocks count */
335 __le16 s_min_extra_isize; /* All inodes have at least # bytes */
336 __le16 s_want_extra_isize; /* New inodes should reserve # bytes */
337 __le32 s_flags; /* Miscellaneous flags */
338 __le16 s_raid_stride; /* RAID stride */
339 __le16 s_mmp_update_interval; /* # seconds to wait in MMP checking */
340 __le64 s_mmp_block; /* Block for multi-mount protection */
341 __le32 s_raid_stripe_width; /* blocks on all data disks (N*stride)*/
342 __u8 s_log_groups_per_flex; /* FLEX_BG group size */
343 __u8 s_checksum_type; /* metadata checksum algorithm used */
344 __le16 s_reserved_pad;
345 __le64 s_kbytes_written; /* nr of lifetime kilobytes written */
346 __le32 s_snapshot_inum; /* Inode number of active snapshot */
347 __le32 s_snapshot_id; /* sequential ID of active snapshot */
348 __le64 s_snapshot_r_blocks_count; /* reserved blocks for active
349 snapshot's future use */
350 __le32 s_snapshot_list; /* inode number of the head of the
351 on-disk snapshot list */
352 #define EXT4_S_ERR_START offsetof(struct ext4_super_block, s_error_count)
353 __le32 s_error_count; /* number of fs errors */
354 __le32 s_first_error_time; /* first time an error happened */
355 __le32 s_first_error_ino; /* inode involved in first error */
356 __le64 s_first_error_block; /* block involved of first error */
357 __u8 s_first_error_func[32]; /* function where the error happened */
358 __le32 s_first_error_line; /* line number where error happened */
359 __le32 s_last_error_time; /* most recent time of an error */
360 __le32 s_last_error_ino; /* inode involved in last error */
361 __le32 s_last_error_line; /* line number where error happened */
362 __le64 s_last_error_block; /* block involved of last error */
363 __u8 s_last_error_func[32]; /* function where the error happened */
364 #define EXT4_S_ERR_END offsetof(struct ext4_super_block, s_mount_opts)
365 __u8 s_mount_opts[64];
366 __le32 s_usr_quota_inum; /* inode for tracking user quota */
367 __le32 s_grp_quota_inum; /* inode for tracking group quota */
368 __le32 s_overhead_clusters; /* overhead blocks/clusters in fs */
369 __le32 s_reserved[108]; /* Padding to the end of the block */
370 __le32 s_checksum; /* crc32c(superblock) */
371 };
372
373 /*
374 * Revision levels
375 */
376 #define EXT4_GOOD_OLD_REV 0 /* The good old (original) format */
377 #define EXT4_DYNAMIC_REV 1 /* V2 format w/ dynamic inode sizes */
378
379 #define EXT4_CURRENT_REV EXT4_GOOD_OLD_REV
380 #define EXT4_MAX_SUPP_REV EXT4_DYNAMIC_REV
381
382 #define EXT4_GOOD_OLD_INODE_SIZE 128
383
384 /*
385 * Feature set definitions (only the once we need for read support)
386 */
387 #define EXT4_FEATURE_RO_COMPAT_SPARSE_SUPER 0x0001
388
389 #define EXT4_FEATURE_INCOMPAT_COMPRESSION 0x0001
390 #define EXT4_FEATURE_INCOMPAT_FILETYPE 0x0002
391 #define EXT4_FEATURE_INCOMPAT_RECOVER 0x0004 /* Needs recovery */
392 #define EXT4_FEATURE_INCOMPAT_JOURNAL_DEV 0x0008 /* Journal device */
393 #define EXT4_FEATURE_INCOMPAT_META_BG 0x0010
394 #define EXT4_FEATURE_INCOMPAT_EXTENTS 0x0040 /* extents support */
395 #define EXT4_FEATURE_INCOMPAT_64BIT 0x0080
396 #define EXT4_FEATURE_INCOMPAT_MMP 0x0100
397 #define EXT4_FEATURE_INCOMPAT_FLEX_BG 0x0200
398 #define EXT4_FEATURE_INCOMPAT_EA_INODE 0x0400 /* EA in inode */
399 #define EXT4_FEATURE_INCOMPAT_DIRDATA 0x1000 /* data in dirent */
400 #define EXT4_FEATURE_INCOMPAT_BG_USE_META_CSUM 0x2000 /* use crc32c for bg */
401 #define EXT4_FEATURE_INCOMPAT_LARGEDIR 0x4000 /* >2GB or 3-lvl htree */
402 #define EXT4_FEATURE_INCOMPAT_INLINEDATA 0x8000 /* data in inode */
403
404 #define EXT4_FEATURE_INCOMPAT_SUPP (EXT4_FEATURE_INCOMPAT_FILETYPE| \
405 EXT4_FEATURE_INCOMPAT_RECOVER| \
406 EXT4_FEATURE_INCOMPAT_META_BG| \
407 EXT4_FEATURE_INCOMPAT_EXTENTS| \
408 EXT4_FEATURE_INCOMPAT_64BIT| \
409 EXT4_FEATURE_INCOMPAT_FLEX_BG| \
410 EXT4_FEATURE_INCOMPAT_MMP)
411
412 /*
413 * Structure of a directory entry
414 */
415 #define EXT4_NAME_LEN 255
416
417 struct ext4_dir_entry {
418 __le32 inode; /* Inode number */
419 __le16 rec_len; /* Directory entry length */
420 __u8 name_len; /* Name length */
421 __u8 file_type;
422 char name[EXT4_NAME_LEN]; /* File name */
423 };
424 // NOTE: The original Linux kernel header defines ext4_dir_entry with the original
425 // layout and ext4_dir_entry_2 with the revised layout. We simply use the revised one.
426
427 /*
428 * Ext2 directory file types. Only the low 3 bits are used. The
429 * other bits are reserved for now.
430 */
431 enum {
432 EXT4_FT_UNKNOWN,
433 EXT4_FT_REG_FILE,
434 EXT4_FT_DIR,
435 EXT4_FT_CHRDEV,
436 EXT4_FT_BLKDEV,
437 EXT4_FT_FIFO,
438 EXT4_FT_SOCK,
439 EXT4_FT_SYMLINK,
440 EXT4_FT_MAX
441 };
442
443 /*
444 * ext4_inode has i_block array (60 bytes total).
445 * The first 12 bytes store ext4_extent_header;
446 * the remainder stores an array of ext4_extent.
447 * For non-inode extent blocks, ext4_extent_tail
448 * follows the array.
449 */
450
451 /*
452 * This is the extent tail on-disk structure.
453 * All other extent structures are 12 bytes long. It turns out that
454 * block_size % 12 >= 4 for at least all powers of 2 greater than 512, which
455 * covers all valid ext4 block sizes. Therefore, this tail structure can be
456 * crammed into the end of the block without having to rebalance the tree.
457 */
458 struct ext4_extent_tail {
459 __le32 et_checksum; /* crc32c(uuid+inum+extent_block) */
460 };
461
462 /*
463 * This is the extent on-disk structure.
464 * It's used at the bottom of the tree.
465 */
466 struct ext4_extent {
467 __le32 ee_block; /* first logical block extent covers */
468 __le16 ee_len; /* number of blocks covered by extent */
469 __le16 ee_start_hi; /* high 16 bits of physical block */
470 __le32 ee_start_lo; /* low 32 bits of physical block */
471 };
472
473 /*
474 * This is index on-disk structure.
475 * It's used at all the levels except the bottom.
476 */
477 struct ext4_extent_idx {
478 __le32 ei_block; /* index covers logical blocks from 'block' */
479 __le32 ei_leaf_lo; /* pointer to the physical block of the next *
480 * level. leaf or next index could be there */
481 __le16 ei_leaf_hi; /* high 16 bits of physical block */
482 __u16 ei_unused;
483 };
484
485
486 /*
487 * Each block (leaves and indexes), even inode-stored has header.
488 */
489 struct ext4_extent_header {
490 __le16 eh_magic; /* probably will support different formats */
491 __le16 eh_entries; /* number of valid entries */
492 __le16 eh_max; /* capacity of store in entries */
493 __le16 eh_depth; /* has tree real underlying blocks? */
494 __le32 eh_generation; /* generation of the tree */
495 };
496
497 #define EXT4_EXT_MAGIC (0xf30a)
498
499
500 #endif