Skip to content

Commit 415206a

Browse files
committed
Worked on format support #13
1 parent 01965fa commit 415206a

File tree

7 files changed

+183
-71
lines changed

7 files changed

+183
-71
lines changed

ChangeLog

+1
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ TODO:
22
* fsextinfo output file system identifier
33

44
* add support for file name codepage
5+
* add support for orphan list and orphan file
56

67
* rename libfsext_block_stream to libfsext_data_stream
78
** refactor libfsext_block_stream_initialize_from_extents to have extents and size arguments

configure.ac

+1-1
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ AC_PREREQ([2.71])
22

33
AC_INIT(
44
[libfsext],
5-
[20240219],
5+
[20240301],
66
77

88
AC_CONFIG_SRCDIR(

documentation/Extended File System (EXT).asciidoc

+56-53
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ this type of file system.
3030
== License
3131

3232
....
33-
Copyright (C) 2010-2023, Joachim Metz <[email protected]>.
33+
Copyright (C) 2010-2024, Joachim Metz <[email protected]>.
3434
Permission is granted to copy, distribute and/or modify this document under the
3535
terms of the GNU Free Documentation License, Version 1.3 or any later version
3636
published by the Free Software Foundation; with no Invariant Sections, no
@@ -60,6 +60,7 @@ in the section entitled "GNU Free Documentation License".
6060
| 0.0.14 | J.B. Metz | May 2022 | Additional information about device number.
6161
| 0.0.15 | J.B. Metz | May 2023 | Additional information about extended attribute.
6262
| 0.0.16 | J.B. Metz | August 2023 | Additional information about meta block groups.
63+
| 0.0.17 | J.B. Metz | March 2024 | Additional information about orphan file feature.
6364
|===
6465

6566
:numbered:
@@ -225,11 +226,11 @@ _If major version is EXT2_DYNAMIC_REV_
225226
The inode size must be a power of 2 larger or equal to 128, the maximum supported by mke2fs is 1024
226227
| 90 | 2 | | Block group +
227228
Contains a block group number
228-
| 92 | 4 | | Compatible feature flags +
229+
| 92 | 4 | | Compatible features flags +
229230
See section: <<compatible_features_flags,Compatible features flags>>
230-
| 96 | 4 | | Incompatible feature flags +
231+
| 96 | 4 | | Incompatible features flags +
231232
See section: <<incompatible_features_flags,Incompatible features flags>>
232-
| 100 | 4 | | Read-only compatible feature flags +
233+
| 100 | 4 | | Read-only compatible features flags +
233234
See section: <<read_only_compatible_features_flags,Read-only compatible features flags>>
234235
| 104 | 16 | | File system identifier +
235236
Contains UUID that is stored in big-endian
@@ -317,11 +318,11 @@ _If major version is EXT2_DYNAMIC_REV_
317318
| 88 | 2 | | Inode size +
318319
The inode size must be a power of 2 larger or equal to 128, the maximum supported by mke2fs is 1024
319320
| 90 | 2 | | Block group
320-
| 92 | 4 | | Compatible feature flags +
321+
| 92 | 4 | | Compatible features flags +
321322
See section: <<compatible_features_flags,Compatible features flags>>
322-
| 96 | 4 | | Incompatible feature flags +
323+
| 96 | 4 | | Incompatible features flags +
323324
See section: <<incompatible_features_flags,Incompatible features flags>>
324-
| 100 | 4 | | Read-only compatible feature flags +
325+
| 100 | 4 | | Read-only compatible features flags +
325326
See section: <<read_only_compatible_features_flags,Read-only compatible features flags>>
326327
| 104 | 16 | | File system identifier +
327328
Contains UUID that is stored in big-endian
@@ -372,52 +373,49 @@ Contains the upper 32-bit of the value
372373
| 372 | 1 | | Flex block group size +
373374
The size is stored as: 2 ^ value
374375
| 373 | 1 | | [yellow-background]*Unknown (metadata checksum method)*
375-
| 374 | 2 | | [yellow-background]*Unknown (padding)*
376-
4+| _Defined in ext4 reserved in earlier versions_
377-
4+| _Common_ +
378-
| ... | ... | | [yellow-background]*Unknown (reserved)*
376+
| 374 | 1 | | [yellow-background]*Unknown (encryption level)*
377+
| 375 | 1 | | [yellow-background]*Unknown (padding)*
378+
| 376 | 8 | | [yellow-background]*Unknown (s_kbytes_written)*
379+
| 384 | 4 | | Inode number of active snapshot
380+
| 388 | 4 | | Identifier of active snapshot
381+
| 392 | 8 | | [yellow-background]*Unknown (reserved s_snapshot_r_blocks_count)*
382+
| 400 | 4 | | Inode number of snapshot list head
383+
| 404 | 4 | | [yellow-background]*Unknown (s_error_count)*
384+
| 408 | 4 | | [yellow-background]*Unknown (s_first_error_time)*
385+
| 412 | 4 | | [yellow-background]*Unknown (s_first_error_ino)*
386+
| 416 | 8 | | [yellow-background]*Unknown (s_first_error_block)*
387+
| 424 | 32 | | [yellow-background]*Unknown (s_first_error_func)*
388+
| 456 | 4 | | [yellow-background]*Unknown (s_first_error_line)*
389+
| 460 | 4 | | [yellow-background]*Unknown (s_last_error_time)*
390+
| 464 | 4 | | [yellow-background]*Unknown (s_last_error_ino)*
391+
| 468 | 4 | | [yellow-background]*Unknown (s_last_error_line)*
392+
| 472 | 8 | | [yellow-background]*Unknown (s_last_error_block)*
393+
| 480 | 32 | | [yellow-background]*Unknown (s_last_error_func)*
394+
| 512 | 64 | | [yellow-background]*Unknown (s_mount_opts)*
395+
| 576 | 4 | | [yellow-background]*Unknown (s_usr_quota_inum)*
396+
| 560 | 4 | | [yellow-background]*Unknown (s_grp_quota_inum)*
397+
| 564 | 4 | | [yellow-background]*Unknown (s_overhead_clusters)*
398+
| 568 | 2 x 4 | | [yellow-background]*Unknown (s_backup_bgs)*
399+
| 576 | 4 | | [yellow-background]*Unknown (s_encrypt_algos)*
400+
| 580 | 16 | | [yellow-background]*Unknown (s_encrypt_pw_salt)*
401+
| 596 | 4 | | [yellow-background]*Unknown (s_lpf_ino)*
402+
| 600 | 4 | | [yellow-background]*Unknown (s_prj_quota_inum)*
403+
| 604 | 4 | | [yellow-background]*Unknown (s_checksum_seed)*
404+
| 608 | 1 | | [yellow-background]*Unknown (s_wtime_hi)*
405+
| 609 | 1 | | [yellow-background]*Unknown (s_mtime_hi)*
406+
| 610 | 1 | | [yellow-background]*Unknown (s_mkfs_time_hi)*
407+
| 611 | 1 | | [yellow-background]*Unknown (s_lastcheck_hi)*
408+
| 612 | 1 | | [yellow-background]*Unknown (s_first_error_time_hi)*
409+
| 613 | 1 | | [yellow-background]*Unknown (s_last_error_time_hi)*
410+
| 614 | 1 | | [yellow-background]*Unknown (s_first_error_errcode)*
411+
| 615 | 1 | | [yellow-background]*Unknown (s_last_error_errcode)*
412+
| 616 | 2 | | [yellow-background]*Unknown (s_encoding)*
413+
| 618 | 2 | | [yellow-background]*Unknown (s_encoding_flags)*
414+
| 620 | 4 | | [yellow-background]*Unknown (s_orphan_file_inum)*
415+
| 624 | 94 x 4 | | [yellow-background]*Unknown (reserved)*
416+
| 1000 | 4 | | [yellow-background]*Unknown (s_checksum)*
379417
|===
380418

381-
....
382-
4+| _Defined in ext4 reserved in earlier versions_
383-
1146 __le64 s_kbytes_written; /* nr of lifetime kilobytes written */
384-
1147 __le32 s_snapshot_inum; /* Inode number of active snapshot */
385-
1148 __le32 s_snapshot_id; /* sequential ID of active snapshot */
386-
1149 __le64 s_snapshot_r_blocks_count; /* reserved blocks for active
387-
1150 snapshot's future use */
388-
1151 __le32 s_snapshot_list; /* inode number of the head of the
389-
1152 on-disk snapshot list */
390-
1153 #define EXT4_S_ERR_START offsetof(struct ext4_super_block, s_error_count)
391-
1154 __le32 s_error_count; /* number of fs errors */
392-
1155 __le32 s_first_error_time; /* first time an error happened */
393-
1156 __le32 s_first_error_ino; /* inode involved in first error */
394-
1157 __le64 s_first_error_block; /* block involved of first error */
395-
1158 __u8 s_first_error_func[32]; /* function where the error happened */
396-
1159 __le32 s_first_error_line; /* line number where error happened */
397-
1160 __le32 s_last_error_time; /* most recent time of an error */
398-
1161 __le32 s_last_error_ino; /* inode involved in last error */
399-
1162 __le32 s_last_error_line; /* line number where error happened */
400-
1163 __le64 s_last_error_block; /* block involved of last error */
401-
1164 __u8 s_last_error_func[32]; /* function where the error happened */
402-
1165 #define EXT4_S_ERR_END offsetof(struct ext4_super_block, s_mount_opts)
403-
1166 __u8 s_mount_opts[64];
404-
1167 __le32 s_usr_quota_inum; /* inode for tracking user quota */
405-
1168 __le32 s_grp_quota_inum; /* inode for tracking group quota */
406-
1169 __le32 s_overhead_clusters; /* overhead blocks/clusters in fs */
407-
1170 __le32 s_backup_bgs[2]; /* groups with sparse_super2 SBs */
408-
1171 __u8 s_encrypt_algos[4]; /* Encryption algorithms in use */
409-
1172 __le32 s_reserved[105]; /* Padding to the end of the block */
410-
1173 __le32 s_checksum; /* crc32c(superblock) */
411-
....
412-
413-
....
414-
__le16 s_desc_size; (replaces a reserved field)
415-
/* 64bit support valid if EXT4_FEATURE_INCOMPAT_64BIT */
416-
/*150*/ __le32 s_blocks_count_hi; /* Blocks count */
417-
__le32 s_r_blocks_count_hi; /* Reserved blocks count */
418-
__le32 s_free_blocks_count_hi; /* Free blocks count */
419-
....
420-
421419
[NOTE]
422420
Some versions of mkfs.ext set the file system creation time even for ext2 and
423421
when EXT3_FEATURE_COMPAT_HAS_JOURNAL is not set.
@@ -486,6 +484,9 @@ EXT2_FEATURE_COMPAT_RESIZE_INODE | Has reserved GDT blocks for file system expan
486484
| 0x00000100 | COMPAT_EXCLUDE_BITMAP | [yellow-background]*Unknown (Exclude inode)* +
487485
[yellow-background]*Not implemented, intended for file system snapshot feature?*
488486
| 0x00000200 | EXT4_FEATURE_COMPAT_SPARSE_SUPER2 | Has a version 2 sparse super block.
487+
| 0x00000400 | EXT4_FEATURE_COMPAT_FAST_COMMIT | [yellow-background]*TODO: add description*
488+
| 0x00000800 | EXT4_FEATURE_COMPAT_STABLE_INODES | [yellow-background]*TODO: add description*
489+
| 0x00001000 | EXT4_FEATURE_COMPAT_ORPHAN_FILE | Has orphan file.
489490
|===
490491

491492
[NOTE]
@@ -503,6 +504,7 @@ and COMPAT_ can be used interchangeably.
503504
| 0x00000004 | EXT3_FEATURE_INCOMPAT_RECOVER | Needs recovery
504505
| 0x00000008 | EXT3_FEATURE_INCOMPAT_JOURNAL_DEV | Has journal device
505506
| 0x00000010 | EXT2_FEATURE_INCOMPAT_META_BG | Has meta (or metadata) block groups
507+
| | |
506508
| 0x00000040 | EXT4_FEATURE_INCOMPAT_EXTENTS | Has extents
507509
| 0x00000080 | EXT4_FEATURE_INCOMPAT_64BIT | Has 64-bit support
508510
| 0x00000100 | EXT4_FEATURE_INCOMPAT_MMP | Multiple mount protection
@@ -511,8 +513,8 @@ and COMPAT_ can be used interchangeably.
511513
| | |
512514
| 0x00001000 | EXT4_FEATURE_INCOMPAT_DIRDATA | Data in directory entry +
513515
[yellow-background]*Not yet supported, in development*
514-
| 0x00002000 | EXT4_FEATURE_INCOMPAT_BG_USE_META_CSUM +
515-
EXT4_FEATURE_INCOMPAT_CSUM_SEED | Metadata checksum seed is stored in the superblock
516+
| 0x00002000 | EXT4_FEATURE_INCOMPAT_CSUM_SEED +
517+
EXT4_FEATURE_INCOMPAT_BG_USE_META_CSUM | Metadata checksum seed is stored in the superblock
516518
| 0x00004000 | EXT4_FEATURE_INCOMPAT_LARGEDIR | Large directory >2GB or 3-level hash tree (HTree).
517519
| 0x00008000 | EXT4_FEATURE_INCOMPAT_INLINE_DATA | Has data stored in inode.
518520
| 0x00010000 | EXT4_FEATURE_INCOMPAT_ENCRYPT | Has encrypted inodes.
@@ -551,6 +553,7 @@ Block allocation bitmaps are tracked in units of clusters (of blocks) instead of
551553
| 0x00002000 | EXT4_FEATURE_RO_COMPAT_PROJECT | Filesystem tracks project quotas.
552554
| 0x00004000 | EXT4_FEATURE_RO_COMPAT_SHARED_BLOCKS | Filesystem has (read-only) shared blocks.
553555
| 0x00008000 | EXT4_FEATURE_RO_COMPAT_VERITY | [yellow-background]*Unknown (Verity inodes may be present on the filesystem.)*
556+
| 0x00010000 | EXT4_FEATURE_RO_COMPAT_ORPHAN_PRESENT | Orphan file may be non-empty.
554557
|===
555558

556559
[NOTE]

fsexttools/info_handle.c

+31-4
Original file line numberDiff line numberDiff line change
@@ -1275,13 +1275,37 @@ void info_handle_compatible_features_flags_fprint(
12751275
notify_stream,
12761276
"\t\tUse directory hash index (EXT2_FEATURE_COMPAT_DIR_INDEX)\n" );
12771277
}
1278+
if( ( compatible_features_flags & 0x00000030UL ) != 0 )
1279+
{
1280+
fprintf(
1281+
notify_stream,
1282+
"\t\t(EXT2_FEATURE_COMPAT_DIR_INDEX)\n" );
1283+
}
12781284

12791285
if( ( compatible_features_flags & 0x00000200UL ) != 0 )
12801286
{
12811287
fprintf(
12821288
notify_stream,
12831289
"\t\t(EXT4_FEATURE_COMPAT_SPARSE_SUPER2)\n" );
12841290
}
1291+
if( ( compatible_features_flags & 0x00000400UL ) != 0 )
1292+
{
1293+
fprintf(
1294+
notify_stream,
1295+
"\t\t(EXT4_FEATURE_COMPAT_FAST_COMMIT)\n" );
1296+
}
1297+
if( ( compatible_features_flags & 0x00000800UL ) != 0 )
1298+
{
1299+
fprintf(
1300+
notify_stream,
1301+
"\t\t(EXT4_FEATURE_COMPAT_STABLE_INODES)\n" );
1302+
}
1303+
if( ( compatible_features_flags & 0x00001000UL ) != 0 )
1304+
{
1305+
fprintf(
1306+
notify_stream,
1307+
"\t\tHas orphan file (EXT4_FEATURE_COMPAT_ORPHAN_FILE)\n" );
1308+
}
12851309
fprintf(
12861310
notify_stream,
12871311
"\n" );
@@ -1365,7 +1389,7 @@ void info_handle_incompatible_features_flags_fprint(
13651389
{
13661390
fprintf(
13671391
notify_stream,
1368-
"\t\t(EXT4_FEATURE_INCOMPAT_BG_USE_META_CSUM)\n" );
1392+
"\t\t(EXT4_FEATURE_INCOMPAT_CSUM_SEED)\n" );
13691393
}
13701394
if( ( incompatible_features_flags & 0x00004000UL ) != 0 )
13711395
{
@@ -1426,7 +1450,6 @@ void info_handle_read_only_compatible_features_flags_fprint(
14261450
notify_stream,
14271451
"\t\t(EXT4_FEATURE_RO_COMPAT_HUGE_FILE)\n" );
14281452
}
1429-
14301453
if( ( read_only_compatible_features_flags & 0x00000010UL ) != 0 )
14311454
{
14321455
fprintf(
@@ -1451,7 +1474,6 @@ void info_handle_read_only_compatible_features_flags_fprint(
14511474
notify_stream,
14521475
"\t\t(RO_COMPAT_HAS_SNAPSHOT)\n" );
14531476
}
1454-
14551477
if( ( read_only_compatible_features_flags & 0x00000100UL ) != 0 )
14561478
{
14571479
fprintf(
@@ -1476,7 +1498,6 @@ void info_handle_read_only_compatible_features_flags_fprint(
14761498
notify_stream,
14771499
"\t\t(EXT4_FEATURE_RO_COMPAT_REPLICA)\n" );
14781500
}
1479-
14801501
if( ( read_only_compatible_features_flags & 0x00001000UL ) != 0 )
14811502
{
14821503
fprintf(
@@ -1501,6 +1522,12 @@ void info_handle_read_only_compatible_features_flags_fprint(
15011522
notify_stream,
15021523
"\t\t(EXT4_FEATURE_RO_COMPAT_VERITY)\n" );
15031524
}
1525+
if( ( read_only_compatible_features_flags & 0x00010000UL ) != 0 )
1526+
{
1527+
fprintf(
1528+
notify_stream,
1529+
"\t\tOrphan file may be non-empty (EXT4_FEATURE_RO_COMPAT_ORPHAN_PRESENT)\n" );
1530+
}
15041531
fprintf(
15051532
notify_stream,
15061533
"\n" );

libfsext/fsext_superblock.h

+22-2
Original file line numberDiff line numberDiff line change
@@ -733,10 +733,30 @@ struct fsext_superblock_ext4
733733
*/
734734
uint8_t checksum_seed[ 4 ];
735735

736+
/* Unknown
737+
* Consists of 8 bytes
738+
*/
739+
uint8_t unknown1[ 8 ];
740+
741+
/* Encoding
742+
* Consists of 2 bytes
743+
*/
744+
uint8_t encoding[ 2 ];
745+
746+
/* Encoding flags
747+
* Consists of 2 bytes
748+
*/
749+
uint8_t encoding_flags[ 2 ];
750+
751+
/* Orphan file inode number
752+
* Consists of 4 bytes
753+
*/
754+
uint8_t orphan_file_inode_number[ 4 ];
755+
736756
/* Padding3
737-
* Consists of 392 bytes
757+
* Consists of 376 bytes
738758
*/
739-
uint8_t padding3[ 392 ];
759+
uint8_t padding3[ 376 ];
740760

741761
/* Checksum
742762
* Consists of 4 bytes

0 commit comments

Comments
 (0)