Skip to content

Commit 921a58c

Browse files
committed
Worked on format support #13
1 parent 415206a commit 921a58c

29 files changed

+1286
-218
lines changed

.gitignore

+1
Original file line numberDiff line numberDiff line change
@@ -138,6 +138,7 @@ stamp-h[1-9]
138138
/tests/fsext_test_block_data_handle
139139
/tests/fsext_test_block_vector
140140
/tests/fsext_test_buffer_data_handle
141+
/tests/fsext_test_checksum
141142
/tests/fsext_test_directory
142143
/tests/fsext_test_directory_entry
143144
/tests/fsext_test_error

documentation/Extended File System (EXT).asciidoc

+37-13
Original file line numberDiff line numberDiff line change
@@ -372,7 +372,8 @@ Contains the upper 32-bit of the value
372372
| 368 | 4 | | [yellow-background]*Unknown (blocks on all data disks (N*stride))*
373373
| 372 | 1 | | Flex block group size +
374374
The size is stored as: 2 ^ value
375-
| 373 | 1 | | [yellow-background]*Unknown (metadata checksum method)*
375+
| 373 | 1 | | Checksum type +
376+
See section: <<checksum_types,checksum types>>
376377
| 374 | 1 | | [yellow-background]*Unknown (encryption level)*
377378
| 375 | 1 | | [yellow-background]*Unknown (padding)*
378379
| 376 | 8 | | [yellow-background]*Unknown (s_kbytes_written)*
@@ -413,13 +414,16 @@ The size is stored as: 2 ^ value
413414
| 618 | 2 | | [yellow-background]*Unknown (s_encoding_flags)*
414415
| 620 | 4 | | [yellow-background]*Unknown (s_orphan_file_inum)*
415416
| 624 | 94 x 4 | | [yellow-background]*Unknown (reserved)*
416-
| 1000 | 4 | | [yellow-background]*Unknown (s_checksum)*
417+
| 1000 | 4 | | Checksum
417418
|===
418419

419420
[NOTE]
420421
Some versions of mkfs.ext set the file system creation time even for ext2 and
421422
when EXT3_FEATURE_COMPAT_HAS_JOURNAL is not set.
422423

424+
The checksum, if checksum type is CRC-32C, contain a CRC-32 of data in the
425+
superblock before the checksum. The checksum is stored as 0xffffffff - CRC-32C.
426+
423427
[yellow-background]*Is the only way to determine the file system version the
424428
compatibility and equivalent flags?*
425429

@@ -514,7 +518,7 @@ and COMPAT_ can be used interchangeably.
514518
| 0x00001000 | EXT4_FEATURE_INCOMPAT_DIRDATA | Data in directory entry +
515519
[yellow-background]*Not yet supported, in development*
516520
| 0x00002000 | EXT4_FEATURE_INCOMPAT_CSUM_SEED +
517-
EXT4_FEATURE_INCOMPAT_BG_USE_META_CSUM | Metadata checksum seed is stored in the superblock
521+
EXT4_FEATURE_INCOMPAT_BG_USE_META_CSUM | Initial metadata checksum value (or seed) is stored in the superblock
518522
| 0x00004000 | EXT4_FEATURE_INCOMPAT_LARGEDIR | Large directory >2GB or 3-level hash tree (HTree).
519523
| 0x00008000 | EXT4_FEATURE_INCOMPAT_INLINE_DATA | Has data stored in inode.
520524
| 0x00010000 | EXT4_FEATURE_INCOMPAT_ENCRYPT | Has encrypted inodes.
@@ -547,11 +551,11 @@ The size of an inode can be larger than ext2 inode size.
547551
| 0x00000100 | EXT4_FEATURE_RO_COMPAT_QUOTA | Quota is handled transactionally with the journal.
548552
| 0x00000200 | EXT4_FEATURE_RO_COMPAT_BIGALLOC | Has big block allocation bitmaps. +
549553
Block allocation bitmaps are tracked in units of clusters (of blocks) instead of blocks.
550-
| 0x00000400 | EXT4_FEATURE_RO_COMPAT_METADATA_CSUM | Supports metadata checksum.
554+
| 0x00000400 | EXT4_FEATURE_RO_COMPAT_METADATA_CSUM | File system metadata has checksums.
551555
| 0x00000800 | EXT4_FEATURE_RO_COMPAT_REPLICA | Supports replicas.
552556
| 0x00001000 | EXT4_FEATURE_RO_COMPAT_READONLY | Read-only file system image.
553-
| 0x00002000 | EXT4_FEATURE_RO_COMPAT_PROJECT | Filesystem tracks project quotas.
554-
| 0x00004000 | EXT4_FEATURE_RO_COMPAT_SHARED_BLOCKS | Filesystem has (read-only) shared blocks.
557+
| 0x00002000 | EXT4_FEATURE_RO_COMPAT_PROJECT | File system tracks project quotas.
558+
| 0x00004000 | EXT4_FEATURE_RO_COMPAT_SHARED_BLOCKS | File system has (read-only) shared blocks.
555559
| 0x00008000 | EXT4_FEATURE_RO_COMPAT_VERITY | [yellow-background]*Unknown (Verity inodes may be present on the filesystem.)*
556560
| 0x00010000 | EXT4_FEATURE_RO_COMPAT_ORPHAN_PRESENT | Orphan file may be non-empty.
557561
|===
@@ -565,6 +569,14 @@ In some ext file systems used by ChromeOS it has been observed that the upper
565569
8-bits of the read-only compatible features flags are set as in 0xff000003.
566570
debugfs identifies these as FEATURE_R24 - FEATURE_R31.
567571

572+
=== [[checksum_types]]Checksum types
573+
574+
[cols="1,1,5",options="header"]
575+
|===
576+
| Value | Identifier | Description
577+
| 1 | EXT4_CRC32C_CHKSUM | CRC-32C (or CRC32-C), which uses the Castagnoli polynomial (0x1edc6f41)
578+
|===
579+
568580
== The group descriptor table
569581

570582
The group descriptor table is stored in the block following the super block.
@@ -623,10 +635,10 @@ Value contains the block number relative from the start of the volume +
623635
[yellow-background]*The excluded bitmap is used for snapshots*
624636
| 24 | 2 | | Block bitmap checksum +
625637
Contains the lower 16-bit of the value if 64-bit support (EXT4_FEATURE_INCOMPAT_64BIT) is enabled +
626-
The checksum is a CRC-32 [yellow-background]*TODO: crc32c(s_uuid+grp_num+bbitmap)*
638+
The checksum is a CRC-32C [yellow-background]*TODO: crc32c(s_uuid+grp_num+bbitmap)*
627639
| 26 | 2 | | Inode bitmap checksum +
628640
Contains the lower 16-bit of the value if 64-bit support (EXT4_FEATURE_INCOMPAT_64BIT) is enabled +
629-
The checksum is a CRC-32 [yellow-background]*TODO: crc32c(s_uuid+grp_num+ibitmap)*
641+
The checksum is a CRC-32C [yellow-background]*TODO: crc32c(s_uuid+grp_num+ibitmap)*
630642
| 28 | 2 | | Number of unused inodes +
631643
Contains the lower 16-bit of the value if 64-bit support (EXT4_FEATURE_INCOMPAT_64BIT) is enabled +
632644
| 30 | 2 | | Checksum +
@@ -655,10 +667,10 @@ Value contains the block number relative from the start of the volume +
655667
[yellow-background]*The excluded bitmap is used for snapshots*
656668
| 56 | 2 | | Block bitmap checksum +
657669
Contains the upper 16-bit of the value +
658-
The checksum is a CRC-32 [yellow-background]*TODO: crc32c(s_uuid+grp_num+bbitmap)*
670+
The checksum is a CRC-32C [yellow-background]*TODO: crc32c(s_uuid+grp_num+bbitmap)*
659671
| 60 | 2 | | Inode bitmap checksum +
660672
Contains the upper 16-bit of the value +
661-
The checksum is a CRC-32 [yellow-background]*TODO: crc32c(s_uuid+grp_num+ibitmap)*
673+
The checksum is a CRC-32C [yellow-background]*TODO: crc32c(s_uuid+grp_num+ibitmap)*
662674
| 64 | 4 | | [yellow-background]*Unknown (reserved)*
663675
|===
664676

@@ -886,7 +898,7 @@ block numbers contain the minor and major device number respectively.
886898

887899
=== The ext4 inode
888900

889-
The ext4 inode is 156 bytes of size and consists of:
901+
The ext4 inode is 160 bytes of size and consists of:
890902

891903
[cols="1,1,1,5",options="header"]
892904
|===
@@ -944,22 +956,34 @@ Also see: <<ext4_extent,The ext4 extent>> or <<ext4_extent_index,The ext4 extent
944956
| 118 | 2 | | Upper part of file ACL (or extended attributes) block number
945957
| 120 | 2 | | Upper part of owner (or user) identifier (UID)
946958
| 122 | 2 | | Upper part of group identifier (GID)
947-
| 124 | 2 | | Lower part of checksum
959+
| 124 | 2 | | Lower part of checksum +
960+
Contains the lower 16-bit of the checksum value
948961
| 126 | 2 | | [yellow-background]*Unknown (reserved)*
949962
| 128 | 2 | | Extended inode size
950-
| 130 | 2 | | Upper part of checksum
963+
| 130 | 2 | | Upper part of checksum +
964+
Contains the upper 16-bit of the checksum value
951965
| 132 | 4 | | (last) inode change time extra precision
952966
| 136 | 4 | | (last) modification time extra precision
953967
| 140 | 4 | | (last) access time extra precision
954968
| 144 | 4 | | Creation time
955969
| 148 | 4 | | Creation time extra precision
956970
| 152 | 4 | | [yellow-background]*Unknown (upper part of version)*
971+
| 156 | 4 | | [yellow-background]*Unknown (i_projid)*
957972
|===
958973

959974
[NOTE]
960975
For a character and block device the first 2 bytes of the array of direct
961976
block numbers contain the minor and major device number respectively.
962977

978+
The checksum, if checksum type is CRC-32C, contain a CRC-32 of:
979+
980+
* file system identifier in the superblock
981+
* inode number
982+
* NFS generation number in the inode
983+
* data of the inode with the lower and upper part of the checksum set to 0-byte values.
984+
985+
The checksum is stored as 0xffffffff - CRC-32C.
986+
963987
[yellow-background]*TODO describe extra precision*
964988

965989
==== Notes

fsexttools/info_handle.c

+2-2
Original file line numberDiff line numberDiff line change
@@ -1389,7 +1389,7 @@ void info_handle_incompatible_features_flags_fprint(
13891389
{
13901390
fprintf(
13911391
notify_stream,
1392-
"\t\t(EXT4_FEATURE_INCOMPAT_CSUM_SEED)\n" );
1392+
"\t\tHas metadata checksum seed (EXT4_FEATURE_INCOMPAT_CSUM_SEED)\n" );
13931393
}
13941394
if( ( incompatible_features_flags & 0x00004000UL ) != 0 )
13951395
{
@@ -1490,7 +1490,7 @@ void info_handle_read_only_compatible_features_flags_fprint(
14901490
{
14911491
fprintf(
14921492
notify_stream,
1493-
"\t\t(EXT4_FEATURE_RO_COMPAT_METADATA_CSUM)\n" );
1493+
"\t\tHas metadata checksums (EXT4_FEATURE_RO_COMPAT_METADATA_CSUM)\n" );
14941494
}
14951495
if( ( read_only_compatible_features_flags & 0x00000800UL ) != 0 )
14961496
{

libfsext/Makefile.am

+1
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,7 @@ libfsext_la_SOURCES = \
3636
libfsext_block_stream.c libfsext_block_stream.h \
3737
libfsext_block_vector.c libfsext_block_vector.h \
3838
libfsext_buffer_data_handle.c libfsext_buffer_data_handle.h \
39+
libfsext_checksum.c libfsext_checksum.h \
3940
libfsext_data_blocks.c libfsext_data_blocks.h \
4041
libfsext_debug.c libfsext_debug.h \
4142
libfsext_definitions.h \

libfsext/fsext_inode.h

+6-1
Original file line numberDiff line numberDiff line change
@@ -439,10 +439,15 @@ struct fsext_inode_ext4
439439
*/
440440
uint8_t creation_time_extra[ 4 ];
441441

442-
/* Unknown (version (upper 32_bit))
442+
/* Version (upper 32_bit)
443443
* Consists of 4 bytes
444444
*/
445445
uint8_t version_upper[ 4 ];
446+
447+
/* Project identifier
448+
* Consists of 4 bytes
449+
*/
450+
uint8_t project_identifier[ 4 ];
446451
};
447452

448453
#if defined( __cplusplus )

libfsext/fsext_superblock.h

+2-2
Original file line numberDiff line numberDiff line change
@@ -728,10 +728,10 @@ struct fsext_superblock_ext4
728728
*/
729729
uint8_t project_quota_inode_number[ 4 ];
730730

731-
/* Checksum seed
731+
/* The initial metdata checksum value (or seed)
732732
* Consists of 4 bytes
733733
*/
734-
uint8_t checksum_seed[ 4 ];
734+
uint8_t metadata_checksum_seed[ 4 ];
735735

736736
/* Unknown
737737
* Consists of 8 bytes

0 commit comments

Comments
 (0)