1 | /* $Id: ext.h 98103 2023-01-17 14:15:46Z vboxsync $ */
|
---|
2 | /** @file
|
---|
3 | * IPRT, Ext2/3/4 format.
|
---|
4 | */
|
---|
5 |
|
---|
6 | /*
|
---|
7 | * Copyright (C) 2012-2023 Oracle and/or its affiliates.
|
---|
8 | *
|
---|
9 | * This file is part of VirtualBox base platform packages, as
|
---|
10 | * available from https://www.virtualbox.org.
|
---|
11 | *
|
---|
12 | * This program is free software; you can redistribute it and/or
|
---|
13 | * modify it under the terms of the GNU General Public License
|
---|
14 | * as published by the Free Software Foundation, in version 3 of the
|
---|
15 | * License.
|
---|
16 | *
|
---|
17 | * This program is distributed in the hope that it will be useful, but
|
---|
18 | * WITHOUT ANY WARRANTY; without even the implied warranty of
|
---|
19 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
---|
20 | * General Public License for more details.
|
---|
21 | *
|
---|
22 | * You should have received a copy of the GNU General Public License
|
---|
23 | * along with this program; if not, see <https://www.gnu.org/licenses>.
|
---|
24 | *
|
---|
25 | * The contents of this file may alternatively be used under the terms
|
---|
26 | * of the Common Development and Distribution License Version 1.0
|
---|
27 | * (CDDL), a copy of it is provided in the "COPYING.CDDL" file included
|
---|
28 | * in the VirtualBox distribution, in which case the provisions of the
|
---|
29 | * CDDL are applicable instead of those of the GPL.
|
---|
30 | *
|
---|
31 | * You may elect to license modified versions of this file under the
|
---|
32 | * terms and conditions of either the GPL or the CDDL or both.
|
---|
33 | *
|
---|
34 | * SPDX-License-Identifier: GPL-3.0-only OR CDDL-1.0
|
---|
35 | */
|
---|
36 |
|
---|
37 | #ifndef IPRT_INCLUDED_formats_ext_h
|
---|
38 | #define IPRT_INCLUDED_formats_ext_h
|
---|
39 | #ifndef RT_WITHOUT_PRAGMA_ONCE
|
---|
40 | # pragma once
|
---|
41 | #endif
|
---|
42 |
|
---|
43 | #include <iprt/types.h>
|
---|
44 | #include <iprt/assertcompile.h>
|
---|
45 |
|
---|
46 |
|
---|
47 | /** @defgroup grp_rt_formats_ext Extended Filesystem (EXT2/3/4) structures and definitions
|
---|
48 | * @ingroup grp_rt_formats
|
---|
49 | * @{
|
---|
50 | */
|
---|
51 |
|
---|
52 | /*
|
---|
53 | * The filesystem structures were retrieved from:
|
---|
54 | * https://www.kernel.org/doc/html/latest/filesystems/ext4/index.html
|
---|
55 | */
|
---|
56 |
|
---|
57 | /** Offset where to find the first superblock on the disk, this is constant. */
|
---|
58 | #define EXT_SB_OFFSET 1024
|
---|
59 |
|
---|
60 | /** @name EXT_INODE_NR_XXX - Special inode numbers.
|
---|
61 | * @{ */
|
---|
62 | #define EXT_INODE_NR_DEF_BLOCKS 1 /**< List of defective blocks. */
|
---|
63 | #define EXT_INODE_NR_ROOT_DIR 2 /**< Root directory. */
|
---|
64 | #define EXT_INODE_NR_USER_QUOTA 3 /**< User quota. */
|
---|
65 | #define EXT_INODE_NR_GROUP_QUOTA 4 /**< Group quota. */
|
---|
66 | #define EXT_INODE_NR_BOOT_LOADER 5 /**< Boot loader. */
|
---|
67 | #define EXT_INODE_NR_UNDEL_DIR 6 /**< Undelete directory. */
|
---|
68 | #define EXT_INODE_NR_RESV_GRP_DESC 7 /**< Reserved group descriptors inode. */
|
---|
69 | #define EXT_INODE_NR_JOURNAL 8 /**< Journal. */
|
---|
70 | #define EXT_INODE_NR_EXCLUDE 9 /**< Exclude inode. */
|
---|
71 | #define EXT_INODE_NR_REPLICA 10 /**< Replica inode. */
|
---|
72 | /** @} */
|
---|
73 |
|
---|
74 | /**
|
---|
75 | * Ext superblock.
|
---|
76 | *
|
---|
77 | * Everything is stored little endian on the disk.
|
---|
78 | */
|
---|
79 | typedef struct EXTSUPERBLOCK
|
---|
80 | {
|
---|
81 | /** 0x00: Total number of inodes in the filesystem. */
|
---|
82 | uint32_t cInodesTotal;
|
---|
83 | /** 0x04: Total number of blocks in the filesystem (low 32bits). */
|
---|
84 | uint32_t cBlocksTotalLow;
|
---|
85 | /** 0x08: Number of blocks reserved for the super user (low 32bits). */
|
---|
86 | uint32_t cBlocksRsvdForSuperUserLow;
|
---|
87 | /** 0x0c: Total number of free blocks (low 32bits). */
|
---|
88 | uint32_t cBlocksFreeLow;
|
---|
89 | /** 0x10: Total number of free inodes. */
|
---|
90 | uint32_t cInodesFree;
|
---|
91 | /** 0x14: First data block. */
|
---|
92 | uint32_t iBlockOfSuperblock;
|
---|
93 | /** 0x18: Block size (calculated as 2^(10 + cBitsShiftLeftBlockSize)). */
|
---|
94 | uint32_t cLogBlockSize;
|
---|
95 | /** 0x1c: Cluster size (calculated as 2^cLogClusterSize). */
|
---|
96 | uint32_t cLogClusterSize;
|
---|
97 | /** 0x20: Number of blocks in each block group. */
|
---|
98 | uint32_t cBlocksPerGroup;
|
---|
99 | /** 0x24: Number of clusters in each block group. */
|
---|
100 | uint32_t cClustersPerBlockGroup;
|
---|
101 | /** 0x28: Number of inodes for each block group. */
|
---|
102 | uint32_t cInodesPerBlockGroup;
|
---|
103 | /** 0x2c: Last mount time in seconds since epoch. */
|
---|
104 | uint32_t u32LastMountTime;
|
---|
105 | /** 0x30: Last written time in seconds since epoch. */
|
---|
106 | uint32_t u32LastWrittenTime;
|
---|
107 | /** 0x34: Number of times the volume was mounted since the last check. */
|
---|
108 | uint16_t cMountsSinceLastCheck;
|
---|
109 | /** 0x36: Number of mounts allowed before a consistency check. */
|
---|
110 | uint16_t cMaxMountsUntilCheck;
|
---|
111 | /** 0x38: Signature to identify a ext2 volume (EXT_SIGNATURE). */
|
---|
112 | uint16_t u16Signature;
|
---|
113 | /** 0x3a: State of the filesystem (EXT_SB_STATE_XXX) */
|
---|
114 | uint16_t u16FilesystemState;
|
---|
115 | /** 0x3c: What to do on an error. */
|
---|
116 | uint16_t u16ActionOnError;
|
---|
117 | /** 0x3e: Minor revision level. */
|
---|
118 | uint16_t u16RevLvlMinor;
|
---|
119 | /** 0x40: Time of last check in seconds since epoch. */
|
---|
120 | uint32_t u32LastCheckTime;
|
---|
121 | /** 0x44: Interval between consistency checks in seconds. */
|
---|
122 | uint32_t u32CheckInterval;
|
---|
123 | /** 0x48: Operating system ID of the filesystem creator (EXT_SB_OS_ID_CREATOR_XXX). */
|
---|
124 | uint32_t u32OsIdCreator;
|
---|
125 | /** 0x4c: Revision level (EXT_SB_REV_XXX). */
|
---|
126 | uint32_t u32RevLvl;
|
---|
127 | /** 0x50: User ID that is allowed to use reserved blocks. */
|
---|
128 | uint16_t u16UidReservedBlocks;
|
---|
129 | /** 0x52: Group ID that is allowed to use reserved blocks. */
|
---|
130 | uint16_t u16GidReservedBlocks;
|
---|
131 | /** 0x54: First non reserved inode number. */
|
---|
132 | uint32_t iFirstInodeNonRsvd;
|
---|
133 | /** 0x58: Size of the inode structure in bytes. */
|
---|
134 | uint16_t cbInode;
|
---|
135 | /** 0x5a: Block group number of this super block. */
|
---|
136 | uint16_t iBlkGrpSb;
|
---|
137 | /** 0x5c: Compatible feature set flags (EXT_SB_FEAT_COMPAT_XXX). */
|
---|
138 | uint32_t fFeaturesCompat;
|
---|
139 | /** 0x60: Incompatible feature set (EXT_SB_FEAT_INCOMPAT_XXX). */
|
---|
140 | uint32_t fFeaturesIncompat;
|
---|
141 | /** 0x64: Readonly-compatible feature set (EXT_SB_FEAT_COMPAT_RO_XXX). */
|
---|
142 | uint32_t fFeaturesCompatRo;
|
---|
143 | /** 0x68: 128bit UUID for the volume. */
|
---|
144 | uint8_t au8Uuid[16];
|
---|
145 | /** 0x78: Volume name. */
|
---|
146 | char achVolumeName[16];
|
---|
147 | /** 0x88: Directory were the filesystem was mounted last. */
|
---|
148 | char achLastMounted[64];
|
---|
149 | /** 0xc8: Bitmap usage algorithm (used for compression). */
|
---|
150 | uint32_t u32AlgoUsageBitmap;
|
---|
151 | /** 0xcc: Number of blocks to try to preallocate for files(?). */
|
---|
152 | uint8_t cBlocksPrealloc;
|
---|
153 | /** 0xcd: Number of blocks to try to preallocate for directories. */
|
---|
154 | uint8_t cBlocksPreallocDirectory;
|
---|
155 | /** 0xce: Number of reserved group descriptor entries for future filesystem expansion. */
|
---|
156 | uint16_t cGdtEntriesRsvd;
|
---|
157 | /** 0xd0: 128bit UUID for the journal superblock. */
|
---|
158 | uint8_t au8JournalUuid[16];
|
---|
159 | /** 0xe0: Inode number of the journal file. */
|
---|
160 | uint32_t iJournalInode;
|
---|
161 | /** 0xe4: Device number of journal file (if the appropriate feature flag is set). */
|
---|
162 | uint32_t u32JournalDev;
|
---|
163 | /** 0xe8: Start of list of orpaned inodes to delete. */
|
---|
164 | uint32_t u32LastOrphan;
|
---|
165 | /** 0xec: HTREE hash seed. */
|
---|
166 | uint32_t au32HashSeedHtree[4];
|
---|
167 | /** 0xfc: Default hash algorithm to use for hashes (EXT_SB_HASH_VERSION_DEF_XXX). */
|
---|
168 | uint8_t u8HashVersionDef;
|
---|
169 | /** 0xfd: Journal backup type. */
|
---|
170 | uint8_t u8JnlBackupType;
|
---|
171 | /** 0xfe: Group descriptor size in bytes. */
|
---|
172 | uint16_t cbGroupDesc;
|
---|
173 | /** 0x100: Default mount options (EXT_SB_MNT_OPTS_DEF_XXX). */
|
---|
174 | uint32_t fMntOptsDef;
|
---|
175 | /** 0x104: First metablock block group (if feature is enabled). */
|
---|
176 | uint32_t iFirstMetaBg;
|
---|
177 | /** 0x108: Filesystem creation time in seconds since epoch. */
|
---|
178 | uint32_t u32TimeFsCreation;
|
---|
179 | /** 0x10c: Backup copy of journals inodes block array for the first elements. */
|
---|
180 | uint32_t au32JnlBlocks[17];
|
---|
181 | /** 0x150: Total number of blocks in the filesystem (high 32bits). */
|
---|
182 | uint32_t cBlocksTotalHigh;
|
---|
183 | /** 0x154: Number of blocks reserved for the super user (high 32bits). */
|
---|
184 | uint32_t cBlocksRsvdForSuperUserHigh;
|
---|
185 | /** 0x158: Total number of free blocks (high 32bits). */
|
---|
186 | uint32_t cBlocksFreeHigh;
|
---|
187 | /** 0x15c: All inodes have at least this number of bytes. */
|
---|
188 | uint16_t cbInodesExtraMin;
|
---|
189 | /** 0x15e: New inodes should reserve this number of bytes. */
|
---|
190 | uint16_t cbNewInodesRsv;
|
---|
191 | /** 0x160: Miscellaneous flags (EXT_SB_F_XXX). */
|
---|
192 | uint32_t fFlags;
|
---|
193 | /** 0x164: RAID stride, number of logical blocks read from or written to the disk
|
---|
194 | * before moving to the next disk. */
|
---|
195 | uint16_t cRaidStride;
|
---|
196 | /** 0x166: Number of seconds between multi-mount prevention checking. */
|
---|
197 | uint16_t cSecMmpInterval;
|
---|
198 | /** 0x168: Block number for the multi-mount protection data. */
|
---|
199 | uint64_t iMmpBlock;
|
---|
200 | /** 0x170: Raid stride width. */
|
---|
201 | uint32_t cRaidStrideWidth;
|
---|
202 | /** 0x174: Size of a flexible block group (calculated as 2^cLogGroupsPerFlex). */
|
---|
203 | uint8_t cLogGroupsPerFlex;
|
---|
204 | /** 0x175: Metadata checksum algorithm type, only 1 is valid (for CRC32c). */
|
---|
205 | uint8_t u8ChksumType;
|
---|
206 | /** 0x176: Padding. */
|
---|
207 | uint16_t u16Padding;
|
---|
208 | /** 0x178: Number of KiB written to the filesystem so far. */
|
---|
209 | uint64_t cKbWritten;
|
---|
210 | /** 0x180: Inode number of active snapshot. */
|
---|
211 | uint32_t iSnapshotInode;
|
---|
212 | /** 0x184: Sequential ID of active snapshot. */
|
---|
213 | uint32_t iSnapshotId;
|
---|
214 | /** 0x188: Number of blocks reserved for activ snapshot's future use. */
|
---|
215 | uint64_t cSnapshotRsvdBlocks;
|
---|
216 | /** 0x190: Inode number of the head of the on-disk snapshot list. */
|
---|
217 | uint32_t iSnapshotListInode;
|
---|
218 | /** 0x194: Number of errors seen so far. */
|
---|
219 | uint32_t cErrorsSeen;
|
---|
220 | /** 0x198: First time an error happened in seconds since epoch. */
|
---|
221 | uint32_t u32TimeFirstError;
|
---|
222 | /** 0x19c: Inode involved in the first error. */
|
---|
223 | uint32_t iInodeFirstError;
|
---|
224 | /** 0x1a0: Number of block involved of first error. */
|
---|
225 | uint64_t iBlkFirstError;
|
---|
226 | /** 0x1a8: Name of the function where the first error happened. */
|
---|
227 | char achFuncFirstError[32];
|
---|
228 | /** 0x1c8: Line number where the error happened. */
|
---|
229 | uint32_t iLineFirstError;
|
---|
230 | /** 0x1cc: Time of the most receent error in seconds since epoch. */
|
---|
231 | uint32_t u32TimeLastError;
|
---|
232 | /** 0x1d0: Inode involved in the most recent error. */
|
---|
233 | uint32_t iInodeLastError;
|
---|
234 | /** 0x1d4: Line number where the most recent error happened. */
|
---|
235 | uint32_t iLineLastError;
|
---|
236 | /** 0x1d8: Number of block involved of most recent error. */
|
---|
237 | uint64_t iBlkLastError;
|
---|
238 | /** 0x1e0: Name of the function where the most recent error happened. */
|
---|
239 | char achFuncLastError[32];
|
---|
240 | /** 0x200: ASCIIz string of mount options. */
|
---|
241 | char aszMntOpts[64];
|
---|
242 | /** 0x240: Inode number of user quota file. */
|
---|
243 | uint32_t iInodeUsrQuota;
|
---|
244 | /** 0x244: Inode number of group quota file. */
|
---|
245 | uint32_t iInodeGrpQuota;
|
---|
246 | /** 0x248: Overhead blocks/clusters in filesystem. */
|
---|
247 | uint32_t cOverheadBlocks;
|
---|
248 | /** 0x24c: Block groups containing superblock backups. */
|
---|
249 | uint32_t aiBlkGrpSbBackups[2];
|
---|
250 | /** 0x254: Encryption algorithms in use (EXT_SB_ENCRYPT_ALGO_XXX). */
|
---|
251 | uint8_t au8EncryptAlgo[4];
|
---|
252 | /** 0x258: Salt for the string2key algorithm for encryption. */
|
---|
253 | uint8_t abEncryptPwSalt[16];
|
---|
254 | /** 0x268: Inode number of lost+found. */
|
---|
255 | uint32_t iInodeLostFound;
|
---|
256 | /** 0x26c: Inode that tracks project quotas. */
|
---|
257 | uint32_t iInodeProjQuota;
|
---|
258 | /** 0x270: Checksum seed used for the metadata checksum calculations.
|
---|
259 | * Should be crc32c(~0, au8Uuid). */
|
---|
260 | uint32_t u32ChksumSeed;
|
---|
261 | /** 0x274: Upper 8bits of the u32LastWrittenTime field. */
|
---|
262 | uint8_t u32LastWrittenTimeHigh8Bits;
|
---|
263 | /** 0x275: Upper 8bits of the u32LastMountTime field. */
|
---|
264 | uint8_t u32LastMountTimeHigh8Bits;
|
---|
265 | /** 0x276: Upper 8bits of the u32TimeFsCreation field. */
|
---|
266 | uint8_t u32TimeFsCreationHigh8Bits;
|
---|
267 | /** 0x277: Upper 8bits of the u32LastCheckTime field. */
|
---|
268 | uint8_t u32LastCheckTimeHigh8Bits;
|
---|
269 | /** 0x278: Upper 8bits of the u32TimeFirstError field. */
|
---|
270 | uint8_t u32TimeFirstErrorHigh8Bits;
|
---|
271 | /** 0x279: Upper 8bits of the u32TimeLastError field. */
|
---|
272 | uint8_t u32TimeLastErrorHigh8Bits;
|
---|
273 | /** 0x27a: Zero padding. */
|
---|
274 | uint8_t au8Padding[2];
|
---|
275 | /** 0x27c: Padding to the end of the block. */
|
---|
276 | uint32_t au32Rsvd[96];
|
---|
277 | /** 0x3fc: Superblock checksum. */
|
---|
278 | uint32_t u32Chksum;
|
---|
279 | } EXTSUPERBLOCK;
|
---|
280 | AssertCompileMemberOffset(EXTSUPERBLOCK, u16UidReservedBlocks, 0x50);
|
---|
281 | AssertCompileMemberOffset(EXTSUPERBLOCK, u32AlgoUsageBitmap, 0xc8);
|
---|
282 | AssertCompileMemberOffset(EXTSUPERBLOCK, iJournalInode, 0xe0);
|
---|
283 | AssertCompileMemberOffset(EXTSUPERBLOCK, u8HashVersionDef, 0xfc);
|
---|
284 | AssertCompileMemberOffset(EXTSUPERBLOCK, fMntOptsDef, 0x100);
|
---|
285 | AssertCompileMemberOffset(EXTSUPERBLOCK, iBlkLastError, 0x1d8);
|
---|
286 | AssertCompileMemberOffset(EXTSUPERBLOCK, iInodeLostFound, 0x268);
|
---|
287 | AssertCompileSize(EXTSUPERBLOCK, 1024);
|
---|
288 | /** Pointer to an ext super block. */
|
---|
289 | typedef EXTSUPERBLOCK *PEXTSUPERBLOCK;
|
---|
290 | /** Pointer to a const ext super block. */
|
---|
291 | typedef EXTSUPERBLOCK const *PCEXTSUPERBLOCK;
|
---|
292 |
|
---|
293 | /** Ext signature. */
|
---|
294 | #define EXT_SB_SIGNATURE UINT16_C(0xef53)
|
---|
295 |
|
---|
296 | /** @name EXT_SB_STATE_XXX - Filesystem state
|
---|
297 | * @{ */
|
---|
298 | /** Clean filesystem state. */
|
---|
299 | #define EXT_SB_STATE_CLEAN UINT16_C(0x0001)
|
---|
300 | /** Error filesystem state. */
|
---|
301 | #define EXT_SB_STATE_ERRORS UINT16_C(0x0002)
|
---|
302 | /** Orphans being recovered state. */
|
---|
303 | #define EXT_SB_STATE_ORPHANS_RECOVERING UINT16_C(0x0004)
|
---|
304 | /** @} */
|
---|
305 |
|
---|
306 | /** @name EXT_SB_OS_ID_CREATOR_XXX - Filesystem creator
|
---|
307 | * @{ */
|
---|
308 | /** Linux. */
|
---|
309 | #define EXT_SB_OS_ID_CREATOR_LINUX 0
|
---|
310 | /** Hurd. */
|
---|
311 | #define EXT_SB_OS_ID_CREATOR_HURD 1
|
---|
312 | /** Masix. */
|
---|
313 | #define EXT_SB_OS_ID_CREATOR_MASIX 2
|
---|
314 | /** FreeBSD. */
|
---|
315 | #define EXT_SB_OS_ID_CREATOR_FREEBSD 3
|
---|
316 | /** Lites. */
|
---|
317 | #define EXT_SB_OS_ID_CREATOR_LITES 4
|
---|
318 | /** @} */
|
---|
319 |
|
---|
320 | /** @name EXT_SB_REV_XXX - Superblock revision
|
---|
321 | * @{ */
|
---|
322 | /** Original format (ext2). */
|
---|
323 | #define EXT_SB_REV_ORIG 0
|
---|
324 | /** Inodes have dynmic sizes. */
|
---|
325 | #define EXT_SB_REV_V2_DYN_INODE_SZ 1
|
---|
326 | /** @} */
|
---|
327 |
|
---|
328 | /** @name EXT_SB_FEAT_COMPAT_XXX - Compatible features which can be ignored when set
|
---|
329 | * and not being supported.
|
---|
330 | * @{ */
|
---|
331 | /** Directories can be preallocated. */
|
---|
332 | #define EXT_SB_FEAT_COMPAT_DIR_PREALLOC RT_BIT_32(0)
|
---|
333 | /** Some sort of "imagic" inodes. */
|
---|
334 | #define EXT_SB_FEAT_COMPAT_IMAGIC_INODES RT_BIT_32(1)
|
---|
335 | /** Filesystem has a journal. */
|
---|
336 | #define EXT_SB_FEAT_COMPAT_HAS_JOURNAL RT_BIT_32(2)
|
---|
337 | /** Filesystem supports extended attributes. */
|
---|
338 | #define EXT_SB_FEAT_COMPAT_EXT_ATTR RT_BIT_32(3)
|
---|
339 | /** Filesystem contains reserved group descriptor blocks for filesystem expansion. */
|
---|
340 | #define EXT_SB_FEAT_COMPAT_RESIZE_INODE RT_BIT_32(4)
|
---|
341 | /** Filesystem contains directory indices. */
|
---|
342 | #define EXT_SB_FEAT_COMPAT_DIR_INDEX RT_BIT_32(5)
|
---|
343 | /** Lazy block group - not used. */
|
---|
344 | #define EXT_SB_FEAT_COMPAT_LAZY_BG RT_BIT_32(6)
|
---|
345 | /** Exclude inode - not used. */
|
---|
346 | #define EXT_SB_FEAT_COMPAT_EXCLUDE_INODE RT_BIT_32(7)
|
---|
347 | /** Exclude bitmap - not used. */
|
---|
348 | #define EXT_SB_FEAT_COMPAT_EXCLUDE_BITMAP RT_BIT_32(8)
|
---|
349 | /** Sparse super blocks, super block contains pointers to block groups
|
---|
350 | * containing backups of the superblock. */
|
---|
351 | #define EXT_SB_FEAT_COMPAT_SPARSE_SUPER2 RT_BIT_32(9)
|
---|
352 | /** @} */
|
---|
353 |
|
---|
354 | /** @name EXT_SB_FEAT_INCOMPAT_XXX - Incompatible features which cause a mounting
|
---|
355 | * error when set and not being supported.
|
---|
356 | * @{ */
|
---|
357 | /** Filesystem contains compressed files. */
|
---|
358 | #define EXT_SB_FEAT_INCOMPAT_COMPRESSION RT_BIT_32(0)
|
---|
359 | /** Directory entries contain a file type. */
|
---|
360 | #define EXT_SB_FEAT_INCOMPAT_DIR_FILETYPE RT_BIT_32(1)
|
---|
361 | /** Filesystem needs recovery. */
|
---|
362 | #define EXT_SB_FEAT_INCOMPAT_RECOVER RT_BIT_32(2)
|
---|
363 | /** The journal is recorded on a separate device. */
|
---|
364 | #define EXT_SB_FEAT_INCOMPAT_JOURNAL_DEV RT_BIT_32(3)
|
---|
365 | /** Filesystem uses meta block groups. */
|
---|
366 | #define EXT_SB_FEAT_INCOMPAT_META_BG RT_BIT_32(4)
|
---|
367 | /** Files in the filesystem use extents. */
|
---|
368 | #define EXT_SB_FEAT_INCOMPAT_EXTENTS RT_BIT_32(6)
|
---|
369 | /** Filesystem uses 64bit offsets. */
|
---|
370 | #define EXT_SB_FEAT_INCOMPAT_64BIT RT_BIT_32(7)
|
---|
371 | /** Filesystem requires multiple mount preotection. */
|
---|
372 | #define EXT_SB_FEAT_INCOMPAT_MMP RT_BIT_32(8)
|
---|
373 | /** Filesystem uses flexible block groups. */
|
---|
374 | #define EXT_SB_FEAT_INCOMPAT_FLEX_BG RT_BIT_32(9)
|
---|
375 | /** Inodes can be used to store large extended attribute values. */
|
---|
376 | #define EXT_SB_FEAT_INCOMPAT_EXT_ATTR_INODE RT_BIT_32(10)
|
---|
377 | /** Data is contained in directory entries. */
|
---|
378 | #define EXT_SB_FEAT_INCOMPAT_DIRDATA RT_BIT_32(12)
|
---|
379 | /** Metadata checksum seed is stored in the super block. */
|
---|
380 | #define EXT_SB_FEAT_INCOMPAT_CSUM_SEED RT_BIT_32(13)
|
---|
381 | /** Directories can be larger than 2GiB or contain a 3-level HTree. */
|
---|
382 | #define EXT_SB_FEAT_INCOMPAT_LARGE_DIR RT_BIT_32(14)
|
---|
383 | /** Data is inlined in the inode. */
|
---|
384 | #define EXT_SB_FEAT_INCOMPAT_INLINE_DATA RT_BIT_32(15)
|
---|
385 | /** Encrypted inodes are present on the filesystem. */
|
---|
386 | #define EXT_SB_FEAT_INCOMPAT_ENCRYPT RT_BIT_32(16)
|
---|
387 | /** @} */
|
---|
388 |
|
---|
389 | /** @name EXT_SB_FEAT_COMPAT_RO_XXX - Backward compatible features when mounted readonly
|
---|
390 | * @{ */
|
---|
391 | /** Sparse superblocks. */
|
---|
392 | #define EXT_SB_FEAT_COMPAT_RO_SPARSE_SUPER RT_BIT_32(0)
|
---|
393 | /** There is at least one large file (> 2GiB). */
|
---|
394 | #define EXT_SB_FEAT_COMPAT_RO_LARGE_FILE RT_BIT_32(1)
|
---|
395 | /** Actually not used in the Linux kernel and e2fprogs. */
|
---|
396 | #define EXT_SB_FEAT_COMPAT_RO_BTREE_DIR RT_BIT_32(2)
|
---|
397 | /** Filesystem contains files which sizes are not represented as a multiple of 512 byte sectors
|
---|
398 | * but logical blocks instead. */
|
---|
399 | #define EXT_SB_FEAT_COMPAT_RO_HUGE_FILE RT_BIT_32(3)
|
---|
400 | /** Group descriptors have checksums embedded */
|
---|
401 | #define EXT_SB_FEAT_COMPAT_RO_GDT_CHSKUM RT_BIT_32(4)
|
---|
402 | /** Subdirectory limit of 32000 doesn't apply. The link count is set to 1 if beyond 64999. */
|
---|
403 | #define EXT_SB_FEAT_COMPAT_RO_DIR_NLINK RT_BIT_32(5)
|
---|
404 | /** Inodes can contain extra data. */
|
---|
405 | #define EXT_SB_FEAT_COMPAT_RO_EXTRA_INODE_SZ RT_BIT_32(6)
|
---|
406 | /** There is at least one snapshot on the filesystem. */
|
---|
407 | #define EXT_SB_FEAT_COMPAT_RO_HAS_SNAPSHOTS RT_BIT_32(7)
|
---|
408 | /** Quotas are enabled for this filesystem. */
|
---|
409 | #define EXT_SB_FEAT_COMPAT_RO_QUOTA RT_BIT_32(8)
|
---|
410 | /** The bigalloc feature is enabled, file extents are tracked in units of clusters
|
---|
411 | * instead of blocks. */
|
---|
412 | #define EXT_SB_FEAT_COMPAT_RO_BIGALLOC RT_BIT_32(9)
|
---|
413 | /** Metadata contains checksums. */
|
---|
414 | #define EXT_SB_FEAT_COMPAT_RO_METADATA_CHKSUM RT_BIT_32(10)
|
---|
415 | /** Filesystem supports replicas. */
|
---|
416 | #define EXT_SB_FEAT_COMPAT_RO_REPLICA RT_BIT_32(11)
|
---|
417 | /** Filesystem is readonly. */
|
---|
418 | #define EXT_SB_FEAT_COMPAT_RO_READONLY RT_BIT_32(12)
|
---|
419 | /** Filesystem tracks project quotas. */
|
---|
420 | #define EXT_SB_FEAT_COMPAT_RO_PROJECT RT_BIT_32(13)
|
---|
421 | /** @} */
|
---|
422 |
|
---|
423 | /** @name EXT_SB_HASH_VERSION_DEF_XXX - Default hash algorithm used
|
---|
424 | * @{ */
|
---|
425 | /** Legacy. */
|
---|
426 | #define EXT_SB_HASH_VERSION_DEF_LEGACY 0
|
---|
427 | /** Half MD4. */
|
---|
428 | #define EXT_SB_HASH_VERSION_DEF_HALF_MD4 1
|
---|
429 | /** Tea. */
|
---|
430 | #define EXT_SB_HASH_VERSION_DEF_TEA 2
|
---|
431 | /** Unsigned legacy. */
|
---|
432 | #define EXT_SB_HASH_VERSION_DEF_LEGACY_UNSIGNED 3
|
---|
433 | /** Unsigned half MD4. */
|
---|
434 | #define EXT_SB_HASH_VERSION_DEF_HALF_MD4_UNSIGNED 4
|
---|
435 | /** Unsigned tea. */
|
---|
436 | #define EXT_SB_HASH_VERSION_DEF_TEA_UNSIGNED 5
|
---|
437 | /** @} */
|
---|
438 |
|
---|
439 | /** @name EXT_SB_MNT_OPTS_DEF_XXX - Default mount options
|
---|
440 | * @{ */
|
---|
441 | /** Print debugging information on (re)mount. */
|
---|
442 | #define EXT_SB_MNT_OPTS_DEF_DEBUG RT_BIT_32(0)
|
---|
443 | /** Created files take the group ID ofthe containing directory. */
|
---|
444 | #define EXT_SB_MNT_OPTS_DEF_BSDGROUPS RT_BIT_32(1)
|
---|
445 | /** Support userspace extended attributes. */
|
---|
446 | #define EXT_SB_MNT_OPTS_DEF_XATTR_USER RT_BIT_32(2)
|
---|
447 | /** Support POSIX access control lists. */
|
---|
448 | #define EXT_SB_MNT_OPTS_DEF_ACL RT_BIT_32(3)
|
---|
449 | /** Do not support 32bit UIDs. */
|
---|
450 | #define EXT_SB_MNT_OPTS_DEF_UID16 RT_BIT_32(4)
|
---|
451 | /** All data and metadata are committed to the journal. */
|
---|
452 | #define EXT_SB_MNT_OPTS_DEF_JMODE_DATA RT_BIT_32(5)
|
---|
453 | /** All data are flushed to the disk before metadata are committed to the journal. */
|
---|
454 | #define EXT_SB_MNT_OPTS_DEF_JMODE_ORDERED RT_BIT_32(6)
|
---|
455 | /** Data ordering not preserved, data may be written after metadata has been written. */
|
---|
456 | #define EXT_SB_MNT_OPTS_DEF_JMODE_WBACK (EXT_SB_MNT_OPTS_DEF_JMODE_DATA | EXT_SB_MNT_OPTS_DEF_JMODE_ORDERED)
|
---|
457 | /** No write flushes. */
|
---|
458 | #define EXT_SB_MNT_OPTS_DEF_NOBARRIER RT_BIT_32(8)
|
---|
459 | /** Track metadata blocks on the filesystem not being used as data blocks. */
|
---|
460 | #define EXT_SB_MNT_OPTS_DEF_BLOCK_VALIDITY RT_BIT_32(9)
|
---|
461 | /** Enables TRIM/DISCARD support. */
|
---|
462 | #define EXT_SB_MNT_OPTS_DEF_DISCARD RT_BIT_32(10)
|
---|
463 | /** Disable delayed allocation. */
|
---|
464 | #define EXT_SB_MNT_OPTS_DEF_NODELALLOC RT_BIT_32(11)
|
---|
465 | /** @} */
|
---|
466 |
|
---|
467 | /** @name EXT_SB_F_XXX - Superblock flags
|
---|
468 | * @{ */
|
---|
469 | /** Signed directory hash used. */
|
---|
470 | #define EXT_SB_F_SIGNED_DIR_HASH RT_BIT_32(0)
|
---|
471 | /** Unsigned directory hash used. */
|
---|
472 | #define EXT_SB_F_UNSIGNED_DIR_HASH RT_BIT_32(1)
|
---|
473 | /** Only used to test development code. */
|
---|
474 | #define EXT_SB_F_DEV_CODE RT_BIT_32(3)
|
---|
475 | /** @} */
|
---|
476 |
|
---|
477 | /** @name EXT_SB_ENCRYPT_ALGO_XXX - Group descriptor flags
|
---|
478 | * @{ */
|
---|
479 | /** Invalid encryption algorithm. */
|
---|
480 | #define EXT_SB_ENCRYPT_ALGO_INVALID 0
|
---|
481 | /** 256-bit AES in XTS mode. */
|
---|
482 | #define EXT_SB_ENCRYPT_ALGO_256BIT_AES_XTS 1
|
---|
483 | /** 256-bit AES in GCM mode. */
|
---|
484 | #define EXT_SB_ENCRYPT_ALGO_256BIT_AES_GCM 2
|
---|
485 | /** 256-bit AES in CBC mode. */
|
---|
486 | #define EXT_SB_ENCRYPT_ALGO_256BIT_AES_CBC 3
|
---|
487 | /** @} */
|
---|
488 |
|
---|
489 |
|
---|
490 | /**
|
---|
491 | * Block group descriptor (32byte version).
|
---|
492 | */
|
---|
493 | typedef struct EXTBLOCKGROUPDESC32
|
---|
494 | {
|
---|
495 | /** 0x00: Block address of the block bitmap (low 32bits). */
|
---|
496 | uint32_t offBlockBitmapLow;
|
---|
497 | /** 0x04: Block address of the inode bitmap (low 32bits). */
|
---|
498 | uint32_t offInodeBitmapLow;
|
---|
499 | /** 0x08: Start block address of the inode table (low 32bits). */
|
---|
500 | uint32_t offInodeTableLow;
|
---|
501 | /** 0x0c: Number of unallocated blocks in group (low 16bits). */
|
---|
502 | uint16_t cBlocksFreeLow;
|
---|
503 | /** 0x0e: Number of unallocated inodes in group (low 16bits). */
|
---|
504 | uint16_t cInodesFreeLow;
|
---|
505 | /** 0x10: Number of directories in the group (low 16bits). */
|
---|
506 | uint16_t cDirectoriesLow;
|
---|
507 | /** 0x12: Flags (EXT_GROUP_DESC_F_XXX). */
|
---|
508 | uint16_t fFlags;
|
---|
509 | /** 0x14: Location of snapshot exclusion bitmap (lower 32bits) */
|
---|
510 | uint32_t offSnapshotExclBitmapLow;
|
---|
511 | /** 0x18: Block bitmap checksum (lower 16bits). */
|
---|
512 | uint16_t u16ChksumBlockBitmapLow;
|
---|
513 | /** 0x1a: Inode bitmap checksum (lower 16bits). */
|
---|
514 | uint16_t u16ChksumInodeBitmapLow;
|
---|
515 | /** 0x1c: Unused inode entry count in the groups inode table (lower 16bits).*/
|
---|
516 | uint16_t cInodeTblUnusedLow;
|
---|
517 | /** 0x1e: Group descriptor checksum. */
|
---|
518 | uint16_t u16Chksum;
|
---|
519 | } EXTBLOCKGROUPDESC32;
|
---|
520 | AssertCompileSize(EXTBLOCKGROUPDESC32, 32);
|
---|
521 | /** Pointer to an ext block group descriptor. */
|
---|
522 | typedef EXTBLOCKGROUPDESC32 *PEXTBLOCKGROUPDESC32;
|
---|
523 | /** Pointer to a const 32 byte block group descriptor. */
|
---|
524 | typedef const EXTBLOCKGROUPDESC32 *PCEXTBLOCKGROUPDESC32;
|
---|
525 |
|
---|
526 |
|
---|
527 | /**
|
---|
528 | * Block group descriptor (64byte version).
|
---|
529 | */
|
---|
530 | typedef struct EXTBLOCKGROUPDESC64
|
---|
531 | {
|
---|
532 | /** 0x00: Embedded 32 byte descriptor. */
|
---|
533 | EXTBLOCKGROUPDESC32 v32;
|
---|
534 | /** 0x20: Location of block bitmap (upper 32bits). */
|
---|
535 | uint32_t offBlockBitmapHigh;
|
---|
536 | /** 0x24: Location of inode bitmap (upper 32bits). */
|
---|
537 | uint32_t offInodeBitmapHigh;
|
---|
538 | /** 0x28: Location of inode table (upper 32bits). */
|
---|
539 | uint32_t offInodeTableHigh;
|
---|
540 | /** 0x2c: Number of unallocated blocks (upper 16bits). */
|
---|
541 | uint16_t cBlocksFreeHigh;
|
---|
542 | /** 0x2e: Number of unallocated inodes (upper 16bits). */
|
---|
543 | uint16_t cInodesFreeHigh;
|
---|
544 | /** 0x30: Number of directories in the group (upper 16bits). */
|
---|
545 | uint16_t cDirectoriesHigh;
|
---|
546 | /** 0x32: Unused inode entry count in the groups inode table (upper 16bits).*/
|
---|
547 | uint16_t cInodeTblUnusedHigh;
|
---|
548 | /** 0x34: Location of snapshot exclusion bitmap (upper 32bits) */
|
---|
549 | uint32_t offSnapshotExclBitmapHigh;
|
---|
550 | /** 0x38: Block bitmap checksum (upper 16bits). */
|
---|
551 | uint16_t u16ChksumBlockBitmapHigh;
|
---|
552 | /** 0x3a: Inode bitmap checksum (upper 16bits). */
|
---|
553 | uint16_t u16ChksumInodeBitmapHigh;
|
---|
554 | /** 0x3c: Padding to 64 bytes. */
|
---|
555 | uint32_t u64Padding;
|
---|
556 | } EXTBLOCKGROUPDESC64;
|
---|
557 | AssertCompileSize(EXTBLOCKGROUPDESC64, 64);
|
---|
558 | /** Pointer to an ext block group descriptor. */
|
---|
559 | typedef EXTBLOCKGROUPDESC64 *PEXTBLOCKGROUPDESC64;
|
---|
560 | /** Pointer to a const 64 byte block group descriptor. */
|
---|
561 | typedef const EXTBLOCKGROUPDESC64 *PCEXTBLOCKGROUPDESC64;
|
---|
562 |
|
---|
563 | /** @name EXT_GROUP_DESC_F_XXX - Group descriptor flags
|
---|
564 | * @{ */
|
---|
565 | /** Inode table and bitmaps are not initialized. */
|
---|
566 | #define EXT_GROUP_DESC_F_INODE_UNINIT RT_BIT(0)
|
---|
567 | /** Block bitmap is not initialized. */
|
---|
568 | #define EXT_GROUP_DESC_F_BLOCK_UNINIT RT_BIT(1)
|
---|
569 | /** Inode table is zeroed. */
|
---|
570 | #define EXT_GROUP_DESC_F_INODE_ZEROED RT_BIT(2)
|
---|
571 | /** @} */
|
---|
572 |
|
---|
573 |
|
---|
574 | /**
|
---|
575 | * Combiend view of the different block gorup descriptor versions.
|
---|
576 | */
|
---|
577 | typedef union EXTBLOCKGROUPDESC
|
---|
578 | {
|
---|
579 | /** 32 byte version. */
|
---|
580 | EXTBLOCKGROUPDESC32 v32;
|
---|
581 | /** 64 byte version. */
|
---|
582 | EXTBLOCKGROUPDESC64 v64;
|
---|
583 | /** Byte view. */
|
---|
584 | uint8_t au8[64];
|
---|
585 | } EXTBLOCKGROUPDESC;
|
---|
586 | /** Poiner to a unified block gorup descriptor view. */
|
---|
587 | typedef EXTBLOCKGROUPDESC *PEXTBLOCKGROUPDESC;
|
---|
588 | /** Poiner to a const unified block gorup descriptor view. */
|
---|
589 | typedef const EXTBLOCKGROUPDESC *PCEXTBLOCKGROUPDESC;
|
---|
590 |
|
---|
591 |
|
---|
592 | /** Number of block entries in the inodes block map. */
|
---|
593 | #define EXT_INODE_BLOCK_ENTRIES 15
|
---|
594 |
|
---|
595 | /**
|
---|
596 | * Inode table entry (standard 128 byte version).
|
---|
597 | */
|
---|
598 | typedef struct EXTINODE
|
---|
599 | {
|
---|
600 | /** 0x00: File mode (EXT_INODE_FILE_MODE_XXX). */
|
---|
601 | uint16_t fMode;
|
---|
602 | /** 0x02: Owner UID (lower 16bits). */
|
---|
603 | uint16_t uUidLow;
|
---|
604 | /** 0x04: Size in bytes (lower 32bits). */
|
---|
605 | uint32_t cbSizeLow;
|
---|
606 | /** 0x08: Last access time in seconds since epoch. */
|
---|
607 | uint32_t u32TimeLastAccess;
|
---|
608 | /** 0x0c: Last inode change time in seconds since epoch. */
|
---|
609 | uint32_t u32TimeLastChange;
|
---|
610 | /** 0x10: Last data modification time in seconds since epoch. */
|
---|
611 | uint32_t u32TimeLastModification;
|
---|
612 | /** 0x14: Deletion time in seconds since epoch. */
|
---|
613 | uint32_t u32TimeDeletion;
|
---|
614 | /** 0x18: Group ID (lower 16bits). */
|
---|
615 | uint16_t uGidLow;
|
---|
616 | /** 0x1a: Hard link count. */
|
---|
617 | uint16_t cHardLinks;
|
---|
618 | /** 0x1c: Block count (lower 32bits). */
|
---|
619 | uint32_t cBlocksLow;
|
---|
620 | /** 0x20: Inode flags. */
|
---|
621 | uint32_t fFlags;
|
---|
622 | /** 0x24: Operating system dependent data. */
|
---|
623 | union
|
---|
624 | {
|
---|
625 | /** Linux: Inode version. */
|
---|
626 | uint32_t u32LnxVersion;
|
---|
627 | } Osd1;
|
---|
628 | /** 0x28: Block map or extent tree. */
|
---|
629 | uint32_t au32Block[EXT_INODE_BLOCK_ENTRIES];
|
---|
630 | /** 0x64: File version. */
|
---|
631 | uint32_t u32Version;
|
---|
632 | /** 0x68: Extended attribute control block (lower 32bits). */
|
---|
633 | uint32_t offExtAttrLow;
|
---|
634 | /** 0x6c: File/directory size (upper 32bits). */
|
---|
635 | uint32_t cbSizeHigh;
|
---|
636 | /** 0x70: Fragment address (obsolete). */
|
---|
637 | uint32_t u32FragmentAddrObs;
|
---|
638 | /** 0x74: Operating system dependent data 2. */
|
---|
639 | union
|
---|
640 | {
|
---|
641 | /** Linux related data. */
|
---|
642 | struct
|
---|
643 | {
|
---|
644 | /** 0x00: Block count (upper 16bits). */
|
---|
645 | uint16_t cBlocksHigh;
|
---|
646 | /** 0x02: Extended attribute block location (upper 16bits). */
|
---|
647 | uint16_t offExtAttrHigh;
|
---|
648 | /** 0x04: Owner UID (upper 16bits). */
|
---|
649 | uint16_t uUidHigh;
|
---|
650 | /** 0x06: Group ID (upper 16bits). */
|
---|
651 | uint16_t uGidHigh;
|
---|
652 | /** 0x08: Inode checksum (lower 16bits). */
|
---|
653 | uint16_t u16ChksumLow;
|
---|
654 | /** 0x0a: Reserved */
|
---|
655 | uint16_t u16Rsvd;
|
---|
656 | } Lnx;
|
---|
657 | } Osd2;
|
---|
658 | } EXTINODE;
|
---|
659 | AssertCompileSize(EXTINODE, 128);
|
---|
660 | /** Pointer to an inode. */
|
---|
661 | typedef EXTINODE *PEXTINODE;
|
---|
662 | /** Pointer to a const inode. */
|
---|
663 | typedef const EXTINODE *PCEXTINODE;
|
---|
664 |
|
---|
665 |
|
---|
666 | /**
|
---|
667 | * Extra inode data (coming right behind the fixed inode data).
|
---|
668 | */
|
---|
669 | typedef struct EXTINODEEXTRA
|
---|
670 | {
|
---|
671 | /** 0x80: Size of the extra inode data in bytes. */
|
---|
672 | uint16_t cbInodeExtra;
|
---|
673 | /** 0x82: Inode checksum (upper 16bits.) */
|
---|
674 | uint16_t u16ChksumHigh;
|
---|
675 | /** 0x84: Last inode change time, extra time bits for sub-second precision. */
|
---|
676 | uint32_t u32ExtraTimeLastChange;
|
---|
677 | /** 0x88: Last data modification time, extra time bits for sub-second precision. */
|
---|
678 | uint32_t u32ExtraTimeLastModification;
|
---|
679 | /** 0x8c: Last access time, extra time bits for sub-second precision. */
|
---|
680 | uint32_t u32ExtraTimeLastAccess;
|
---|
681 | /** 0x90: File creation time in seconds since epoch. */
|
---|
682 | uint32_t u32TimeCreation;
|
---|
683 | /** 0x94: File creation time, extra time bits for sub-second precision. */
|
---|
684 | uint32_t u32ExtraTimeCreation;
|
---|
685 | /** 0x98: Version number (upper 32bits). */
|
---|
686 | uint32_t u32VersionHigh;
|
---|
687 | /** 0x9c: Project ID. */
|
---|
688 | uint32_t u32ProjectId;
|
---|
689 | } EXTINODEEXTRA;
|
---|
690 | /** Pointer to extra inode data. */
|
---|
691 | typedef EXTINODEEXTRA *PEXTINODEEXTRA;
|
---|
692 | /** Pointer to a const extra inode data. */
|
---|
693 | typedef const EXTINODEEXTRA *PCEXTINODEEXTRA;
|
---|
694 |
|
---|
695 |
|
---|
696 | /**
|
---|
697 | * Combined inode data.
|
---|
698 | */
|
---|
699 | typedef struct EXTINODECOMB
|
---|
700 | {
|
---|
701 | /** Core inode structure. */
|
---|
702 | EXTINODE Core;
|
---|
703 | /** Any extra inode data which might be present. */
|
---|
704 | EXTINODEEXTRA Extra;
|
---|
705 | } EXTINODECOMB;
|
---|
706 | /** Pointer to combined inode data. */
|
---|
707 | typedef EXTINODECOMB *PEXTINODECOMB;
|
---|
708 | /** Pointer to a const combined inode data. */
|
---|
709 | typedef const EXTINODECOMB *PCEXTINODECOMB;
|
---|
710 |
|
---|
711 |
|
---|
712 |
|
---|
713 | /** @name EXT_INODE_MODE_XXX - File mode
|
---|
714 | * @{ */
|
---|
715 | /** Others can execute the file. */
|
---|
716 | #define EXT_INODE_MODE_EXEC_OTHER RT_BIT(0)
|
---|
717 | /** Others can write to the file. */
|
---|
718 | #define EXT_INODE_MODE_WRITE_OTHER RT_BIT(1)
|
---|
719 | /** Others can read the file. */
|
---|
720 | #define EXT_INODE_MODE_READ_OTHER RT_BIT(2)
|
---|
721 | /** Members of the same group can execute the file. */
|
---|
722 | #define EXT_INODE_MODE_EXEC_GROUP RT_BIT(3)
|
---|
723 | /** Members of the same group can write to the file. */
|
---|
724 | #define EXT_INODE_MODE_WRITE_GROUP RT_BIT(4)
|
---|
725 | /** Members of the same group can read the file. */
|
---|
726 | #define EXT_INODE_MODE_READ_GROUP RT_BIT(5)
|
---|
727 | /** Owner can execute the file. */
|
---|
728 | #define EXT_INODE_MODE_EXEC_OWNER RT_BIT(6)
|
---|
729 | /** Owner can write to the file. */
|
---|
730 | #define EXT_INODE_MODE_WRITE_OWNER RT_BIT(7)
|
---|
731 | /** Owner can read the file. */
|
---|
732 | #define EXT_INODE_MODE_READ_OWNER RT_BIT(8)
|
---|
733 | /** Sticky file mode. */
|
---|
734 | #define EXT_INODE_MODE_STICKY RT_BIT(9)
|
---|
735 | /** File is set GID. */
|
---|
736 | #define EXT_INODE_MODE_SET_GROUP_ID RT_BIT(10)
|
---|
737 | /** File is set UID. */
|
---|
738 | #define EXT_INODE_MODE_SET_USER_ID RT_BIT(11)
|
---|
739 | /** @} */
|
---|
740 |
|
---|
741 | /** @name EXT_INODE_MODE_TYPE_XXX - File type
|
---|
742 | * @{ */
|
---|
743 | /** Inode represents a FIFO. */
|
---|
744 | #define EXT_INODE_MODE_TYPE_FIFO UINT16_C(0x1000)
|
---|
745 | /** Inode represents a character device. */
|
---|
746 | #define EXT_INODE_MODE_TYPE_CHAR UINT16_C(0x2000)
|
---|
747 | /** Inode represents a directory. */
|
---|
748 | #define EXT_INODE_MODE_TYPE_DIR UINT16_C(0x4000)
|
---|
749 | /** Inode represents a block device. */
|
---|
750 | #define EXT_INODE_MODE_TYPE_BLOCK UINT16_C(0x6000)
|
---|
751 | /** Inode represents a regular file. */
|
---|
752 | #define EXT_INODE_MODE_TYPE_REGULAR UINT16_C(0x8000)
|
---|
753 | /** Inode represents a symlink. */
|
---|
754 | #define EXT_INODE_MODE_TYPE_SYMLINK UINT16_C(0xa000)
|
---|
755 | /** Inode represents a socket. */
|
---|
756 | #define EXT_INODE_MODE_TYPE_SOCKET UINT16_C(0xc000)
|
---|
757 | /** Returns the inode type from the combined mode field. */
|
---|
758 | #define EXT_INODE_MODE_TYPE_GET_TYPE(a_Mode) ((a_Mode) & 0xf000)
|
---|
759 | /** @} */
|
---|
760 |
|
---|
761 | /** @name EXT_INODE_F_XXX - Inode flags
|
---|
762 | * @{ */
|
---|
763 | /** Inode requires secure erase on deletion. */
|
---|
764 | #define EXT_INODE_F_SECURE_ERASE RT_BIT_32(0)
|
---|
765 | /** Inode should be preserved for undeletion during deletion. */
|
---|
766 | #define EXT_INODE_F_UNDELETE RT_BIT_32(1)
|
---|
767 | /** Inode contains compressed data. */
|
---|
768 | #define EXT_INODE_F_COMPRESSED RT_BIT_32(2)
|
---|
769 | /** All writes to this inode must be synchronous. */
|
---|
770 | #define EXT_INODE_F_SYNCHRONOUS RT_BIT_32(3)
|
---|
771 | /** Inode is immutable. */
|
---|
772 | #define EXT_INODE_F_IMMUTABLE RT_BIT_32(4)
|
---|
773 | /** Inode is append only. */
|
---|
774 | #define EXT_INODE_F_APPEND_ONLY RT_BIT_32(5)
|
---|
775 | /** Inode should not be dumped via dump(1). */
|
---|
776 | #define EXT_INODE_F_NO_DUMP RT_BIT_32(6)
|
---|
777 | /** Access time is not updated. */
|
---|
778 | #define EXT_INODE_F_NO_ACCESS_TIME RT_BIT_32(7)
|
---|
779 | /** Dirty compressed file. */
|
---|
780 | #define EXT_INODE_F_DIRTY_COMPRESSED RT_BIT_32(8)
|
---|
781 | /** Inode has one or more compressed clusters. */
|
---|
782 | #define EXT_INODE_F_COMPRESSED_BLOCK RT_BIT_32(9)
|
---|
783 | /** Inode should not be compressed. */
|
---|
784 | #define EXT_INODE_F_NO_COMPRESSION RT_BIT_32(10)
|
---|
785 | /** Inode is encrypted. */
|
---|
786 | #define EXT_INODE_F_ENCRYPTED RT_BIT_32(11)
|
---|
787 | /** Directory has hashed indexes. */
|
---|
788 | #define EXT_INODE_F_DIR_HASHED_INDEX RT_BIT_32(12)
|
---|
789 | /** AFS magic directory. */
|
---|
790 | #define EXT_INODE_F_IMAGIC RT_BIT_32(13)
|
---|
791 | /** Data must always be written through the journal. */
|
---|
792 | #define EXT_INODE_F_JOURNAL_DATA RT_BIT_32(14)
|
---|
793 | /** File tail should not be merged. */
|
---|
794 | #define EXT_INODE_F_NOTAIL RT_BIT_32(15)
|
---|
795 | /** All directory entry data should be written synchronously. */
|
---|
796 | #define EXT_INODE_F_DIR_SYNCHRONOUS RT_BIT_32(16)
|
---|
797 | /** Top of directory hierarchy. */
|
---|
798 | #define EXT_INODE_F_TOP_DIRECTORY RT_BIT_32(17)
|
---|
799 | /** Inode is a huge file. */
|
---|
800 | #define EXT_INODE_F_HUGE_FILE RT_BIT_32(18)
|
---|
801 | /** Inode uses extents. */
|
---|
802 | #define EXT_INODE_F_EXTENTS RT_BIT_32(19)
|
---|
803 | /** Inode stores a large extended attribute value in its data blocks. */
|
---|
804 | #define EXT_INODE_F_EXT_ATTR_INODE RT_BIT_32(20)
|
---|
805 | /** File has blocks allocated past end of file. */
|
---|
806 | #define EXT_INODE_F_ALLOC_BLOCKS_EOF RT_BIT_32(21)
|
---|
807 | /** Inode is a snapshot. */
|
---|
808 | #define EXT_INODE_F_SNAPSHOT RT_BIT_32(22)
|
---|
809 | /** Snapshot is being deleted. */
|
---|
810 | #define EXT_INODE_F_SNAPSHOT_DELETED RT_BIT_32(23)
|
---|
811 | /** Snapshot shrink has completed. */
|
---|
812 | #define EXT_INODE_F_SNAPSHOT_SHRUNK RT_BIT_32(24)
|
---|
813 | /** Inode contains inline data. */
|
---|
814 | #define EXT_INODE_F_INLINE_DATA RT_BIT_32(25)
|
---|
815 | /** Children are created with the same project ID. */
|
---|
816 | #define EXT_INODE_F_PROJECT_ID_INHERIT RT_BIT_32(26)
|
---|
817 | /** Reserved for ext4 library. */
|
---|
818 | #define EXT_INODE_F_RESERVED_LIBRARY RT_BIT_32(27)
|
---|
819 | /** @} */
|
---|
820 |
|
---|
821 |
|
---|
822 | /**
|
---|
823 | * Extent tree header.
|
---|
824 | */
|
---|
825 | typedef struct EXTEXTENTHDR
|
---|
826 | {
|
---|
827 | /** 0x00: Magic number for identification. */
|
---|
828 | uint16_t u16Magic;
|
---|
829 | /** 0x02: Number of valid entries following. */
|
---|
830 | uint16_t cEntries;
|
---|
831 | /** 0x04: Maxmimum number of entries that could follow. */
|
---|
832 | uint16_t cMax;
|
---|
833 | /** 0x06: Depth of this extent node in the tree. */
|
---|
834 | uint16_t uDepth;
|
---|
835 | /** 0x08: Generation of the tree (not used by standard ext4). */
|
---|
836 | uint32_t cGeneration;
|
---|
837 | } EXTEXTENTHDR;
|
---|
838 | AssertCompileSize(EXTEXTENTHDR, 12);
|
---|
839 | /** Pointer to a extent tree header. */
|
---|
840 | typedef EXTEXTENTHDR *PEXTEXTENTHDR;
|
---|
841 | /** Pointer to a const extent tree header. */
|
---|
842 | typedef const EXTEXTENTHDR *PCEXTEXTENTHDR;
|
---|
843 |
|
---|
844 | /** Magic number identifying an extent header. */
|
---|
845 | #define EXT_EXTENT_HDR_MAGIC UINT16_C(0xf30a)
|
---|
846 | /** Maximum depth an extent header can have. */
|
---|
847 | #define EXT_EXTENT_HDR_DEPTH_MAX UINT16_C(5)
|
---|
848 |
|
---|
849 |
|
---|
850 | /**
|
---|
851 | * Extent tree index node.
|
---|
852 | */
|
---|
853 | typedef struct EXTEXTENTIDX
|
---|
854 | {
|
---|
855 | /** 0x00: Start file block this node covers. */
|
---|
856 | uint32_t iBlock;
|
---|
857 | /** 0x04: Block number of child extent node (lower 32bits). */
|
---|
858 | uint32_t offChildLow;
|
---|
859 | /** 0x08: Block number of child extent node (upper 16bits). */
|
---|
860 | uint16_t offChildHigh;
|
---|
861 | /** 0x0a: Reserved. */
|
---|
862 | uint16_t u16Rsvd;
|
---|
863 | } EXTEXTENTIDX;
|
---|
864 | AssertCompileSize(EXTEXTENTIDX, 12);
|
---|
865 | /** Pointer to an extent tree index node. */
|
---|
866 | typedef EXTEXTENTIDX *PEXTEXTENTIDX;
|
---|
867 | /** Pointer to a const extent tree index node. */
|
---|
868 | typedef const EXTEXTENTIDX *PCEXTEXTENTIDX;
|
---|
869 |
|
---|
870 |
|
---|
871 | /**
|
---|
872 | * Extent tree leaf node.
|
---|
873 | */
|
---|
874 | typedef struct EXTEXTENT
|
---|
875 | {
|
---|
876 | /** 0x00: First file block number this extent covers. */
|
---|
877 | uint32_t iBlock;
|
---|
878 | /** 0x04: Number of blocks covered by this extent. */
|
---|
879 | uint16_t cBlocks;
|
---|
880 | /** 0x06: Block number this extent points to (upper 32bits). */
|
---|
881 | uint16_t offStartHigh;
|
---|
882 | /** 0x08: Block number this extent points to (lower 32bits). */
|
---|
883 | uint32_t offStartLow;
|
---|
884 | } EXTEXTENT;
|
---|
885 | AssertCompileSize(EXTEXTENT, 12);
|
---|
886 | /** Pointer to a leaf node. */
|
---|
887 | typedef EXTEXTENT *PEXTEXTENT;
|
---|
888 | /** Pointer to a const leaf node. */
|
---|
889 | typedef const EXTEXTENT *PCEXTEXTENT;
|
---|
890 |
|
---|
891 | /** Length field limit for a populated extent, fields greater than that limit indicate a sparse extent. */
|
---|
892 | #define EXT_EXTENT_LENGTH_LIMIT UINT16_C(32768)
|
---|
893 |
|
---|
894 |
|
---|
895 | /**
|
---|
896 | * Directory entry.
|
---|
897 | */
|
---|
898 | typedef struct EXTDIRENTRY
|
---|
899 | {
|
---|
900 | /** 0x00: Inode number being referenced by this entry. */
|
---|
901 | uint32_t iInodeRef;
|
---|
902 | /** 0x04: Record length of this directory entry in bytes (multiple of 4). */
|
---|
903 | uint16_t cbRecord;
|
---|
904 | /** 0x06: Version dependent data. */
|
---|
905 | union
|
---|
906 | {
|
---|
907 | /** Original. */
|
---|
908 | struct
|
---|
909 | {
|
---|
910 | /** Name length in bytes (maximum 255). */
|
---|
911 | uint16_t cbName;
|
---|
912 | } v1;
|
---|
913 | /** Version 2. */
|
---|
914 | struct
|
---|
915 | {
|
---|
916 | /** Name length in bytes (maximum 255). */
|
---|
917 | uint8_t cbName;
|
---|
918 | /** File type (EXT_DIRENTRY_TYPE_XXX). */
|
---|
919 | uint8_t uType;
|
---|
920 | } v2;
|
---|
921 | } u;
|
---|
922 | /** 0x08: File name - variable in size. */
|
---|
923 | char achName[1];
|
---|
924 | } EXTDIRENTRY;
|
---|
925 | /** Pointer to a directory entry. */
|
---|
926 | typedef EXTDIRENTRY *PEXTDIRENTRY;
|
---|
927 | /** Poiner to a const directory entry. */
|
---|
928 | typedef const EXTDIRENTRY *PCEXTDIRENTRY;
|
---|
929 |
|
---|
930 |
|
---|
931 | /**
|
---|
932 | * Extended directory entry with the maximum size (263 bytes).
|
---|
933 | */
|
---|
934 | #pragma pack(1)
|
---|
935 | typedef union EXTDIRENTRYEX
|
---|
936 | {
|
---|
937 | /** The directory entry. */
|
---|
938 | EXTDIRENTRY Core;
|
---|
939 | /** The byte view. */
|
---|
940 | uint8_t au8[263];
|
---|
941 | } EXTDIRENTRYEX;
|
---|
942 | #pragma pack()
|
---|
943 | AssertCompileSize(EXTDIRENTRYEX, 263);
|
---|
944 | /** Pointer to an extended directory entry. */
|
---|
945 | typedef EXTDIRENTRYEX *PEXTDIRENTRYEX;
|
---|
946 | /** Pointer to a const extended directory entry. */
|
---|
947 | typedef const EXTDIRENTRYEX *PCEXTDIRENTRYEX;
|
---|
948 |
|
---|
949 |
|
---|
950 | /** @name EXT_DIRENTRY_TYPE_XXX - file type
|
---|
951 | * @{ */
|
---|
952 | /** Entry is of unknown file type. */
|
---|
953 | #define EXT_DIRENTRY_TYPE_UNKNOWN 0
|
---|
954 | /** Entry is regular file. */
|
---|
955 | #define EXT_DIRENTRY_TYPE_REGULAR 1
|
---|
956 | /** Entry is another directory. */
|
---|
957 | #define EXT_DIRENTRY_TYPE_DIRECTORY 2
|
---|
958 | /** Entry is a character device. */
|
---|
959 | #define EXT_DIRENTRY_TYPE_CHAR 3
|
---|
960 | /** Entry is a block device. */
|
---|
961 | #define EXT_DIRENTRY_TYPE_BLOCK 4
|
---|
962 | /** Entry is a FIFO. */
|
---|
963 | #define EXT_DIRENTRY_TYPE_FIFO 5
|
---|
964 | /** Entry is a socket. */
|
---|
965 | #define EXT_DIRENTRY_TYPE_SOCKET 6
|
---|
966 | /** Entry is a symlink. */
|
---|
967 | #define EXT_DIRENTRY_TYPE_SYMLINK 7
|
---|
968 | /** Entry is a checksum and uses EXTDIRENTRYCHKSUM. */
|
---|
969 | #define EXT_DIRENTRY_TYPE_CHKSUM 0xde
|
---|
970 | /** @} */
|
---|
971 |
|
---|
972 |
|
---|
973 | /**
|
---|
974 | * Tail directory entry (for checksumming).
|
---|
975 | */
|
---|
976 | typedef struct EXTDIRENTRYCHKSUM
|
---|
977 | {
|
---|
978 | /** 0x00: Reserved, must be 0 (overlays with EXTDIRENTRY::iNodeRef). */
|
---|
979 | uint32_t u32Rsvd;
|
---|
980 | /** 0x04: Record length (must be 12). */
|
---|
981 | uint16_t cbRecord;
|
---|
982 | /** 0x06: Reserved (overlays with EXTDIRENTRY::u::v1::cbName). */
|
---|
983 | uint8_t u8Rsvd;
|
---|
984 | /** 0x07: File type (must be 0xde). */
|
---|
985 | uint8_t uType;
|
---|
986 | /** 0x08: Checksum. */
|
---|
987 | uint32_t u32Chksum;
|
---|
988 | } EXTDIRENTRYCHKSUM;
|
---|
989 | /** Pointer to a tail directory entry. */
|
---|
990 | typedef EXTDIRENTRYCHKSUM *PEXTDIRENTRYCHKSUM;
|
---|
991 | /** Pointer to const tail directory entry. */
|
---|
992 | typedef const EXTDIRENTRYCHKSUM *PCEXTDIRENTRYCHKSUM;
|
---|
993 |
|
---|
994 |
|
---|
995 | /** @} */
|
---|
996 |
|
---|
997 | #endif /* !IPRT_INCLUDED_formats_ext_h */
|
---|
998 |
|
---|