diff options
author | Andreas Dilger <adilger@dilger.ca> | 2013-12-23 16:04:46 -0500 |
---|---|---|
committer | Theodore Ts'o <tytso@mit.edu> | 2013-12-24 22:50:19 -0500 |
commit | 2bc30417541deffca795db8ec4e7f7ccb616dc3f (patch) | |
tree | 70a09a5ab89dfe7e92f5383e4832ef78f8c908d2 /tests/f_desc_size_bad | |
parent | 11d1116a7c0b833af317249d12025413fecbcd70 (diff) | |
download | e2fsprogs-2bc30417541deffca795db8ec4e7f7ccb616dc3f.tar.gz |
debugfs, e2fsck: fix s_desc_size handling
The s_desc_size in the superblock specifies the group descriptor
size in bytes, but in various places the EXT4_FEATURE_INCOMPAT_64BIT
flag implies that the descriptor size is EXT2_MIN_DESC_SIZE_64BIT
(64 bytes) instead of checking the actual size. In other places,
the s_desc_size field is used without checking for INCOMPAT_64BIT.
In the case of ext2fs_group_desc() the s_desc_size was being ignored,
and assumed to be sizeof(struct ext4_group_desc), which would result
in garbage for any but the first group descriptor. Similarly, in
ext2fs_group_desc_csum() and print_csum() they assumed that the
maximum group descriptor size was sizeof(struct ext4_group_desc).
Fix these functions to use the actual superblock s_desc_size if
INCOMPAT_64BIT.
Conversely, in ext2fs_swap_group_desc2() s_desc_size was used
without checking for INCOMPAT_64BIT being set.
The e2fsprogs behaviour is different than that of the kernel,
which always checks INCOMPAT_64BIT, and only uses s_desc_size to
determine the offset of group descriptors and what range of bytes
to checksum.
Allow specifying the s_desc_size field at mke2fs time with the
"-E desc_size=NNN" option. Allow a power-of-two s_desc_size
value up to s_blocksize if INCOMPAT_64BIT is specified. This
is not expected to be used by regular users at this time, so it
is not currently documented in the mke2fs usage or man page.
Add m_desc_size_128, f_desc_size_128, and f_desc_bad test cases to
verify mke2fs and e2fsck handling of larger group descriptor sizes.
Signed-off-by: Andreas Dilger <adilger@dilger.ca>
Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
Diffstat (limited to 'tests/f_desc_size_bad')
-rw-r--r-- | tests/f_desc_size_bad/expect.1 | 11 | ||||
-rw-r--r-- | tests/f_desc_size_bad/expect.2 | 7 | ||||
-rw-r--r-- | tests/f_desc_size_bad/script | 17 |
3 files changed, 35 insertions, 0 deletions
diff --git a/tests/f_desc_size_bad/expect.1 b/tests/f_desc_size_bad/expect.1 new file mode 100644 index 00000000..009ee041 --- /dev/null +++ b/tests/f_desc_size_bad/expect.1 @@ -0,0 +1,11 @@ +ext2fs_check_desc: Block group descriptor size incorrect +../e2fsck/e2fsck: Group descriptors look bad... trying backup blocks... +Pass 1: Checking inodes, blocks, and sizes +Pass 2: Checking directory structure +Pass 3: Checking directory connectivity +Pass 4: Checking reference counts +Pass 5: Checking group summary information + +test_filesys: ***** FILE SYSTEM WAS MODIFIED ***** +test_filesys: 11/32 files (0.0% non-contiguous), 801/2048 blocks +Exit status is 1 diff --git a/tests/f_desc_size_bad/expect.2 b/tests/f_desc_size_bad/expect.2 new file mode 100644 index 00000000..d1429fdc --- /dev/null +++ b/tests/f_desc_size_bad/expect.2 @@ -0,0 +1,7 @@ +Pass 1: Checking inodes, blocks, and sizes +Pass 2: Checking directory structure +Pass 3: Checking directory connectivity +Pass 4: Checking reference counts +Pass 5: Checking group summary information +test_filesys: 11/32 files (0.0% non-contiguous), 801/2048 blocks +Exit status is 0 diff --git a/tests/f_desc_size_bad/script b/tests/f_desc_size_bad/script new file mode 100644 index 00000000..54403286 --- /dev/null +++ b/tests/f_desc_size_bad/script @@ -0,0 +1,17 @@ +if ! test -x $DEBUGFS_EXE; then + echo "$test_name: $test_description: skipped" + return 0 +fi + +DESCRIPTION="bad superblock s_desc_size" +SKIP_GUNZIP=true +touch $TMPFILE +$MKE2FS -F -o Linux -O 64bit,extents -N 32 -b 1024 -g 512 -E desc_size=128 $TMPFILE 2048 > $test_name.log 2>&1 +$DEBUGFS -R "ssv desc_size 129" -w $TMPFILE >> $test_name.log 2>&1 + +E2FSCK_TIME=200704102100 +export E2FSCK_TIME + +. $cmd_dir/run_e2fsck + +unset E2FSCK_TIME |