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