From: Darrick J. Wong Date: Wed, 22 Jul 2015 04:06:43 +0000 (-0400) Subject: e2fsck: check htree leaf block checksums X-Git-Tag: v1.43-WIP-2016-03-15~57 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=95eca2e9228841496a5864605259bf908a5b2d0a;p=thirdparty%2Fe2fsprogs.git e2fsck: check htree leaf block checksums We weren't verifying the checksum of an htree leaf block due to a coding error that marked all htree blocks as not having checksums. While we're at it, fix the error message that gets displayed so that it doesn't print a meaningless block offset. Signed-off-by: Darrick J. Wong Signed-off-by: Theodore Ts'o --- diff --git a/e2fsck/pass2.c b/e2fsck/pass2.c index 2e9a90d48..4b81575f8 100644 --- a/e2fsck/pass2.c +++ b/e2fsck/pass2.c @@ -1092,7 +1092,7 @@ inline_read_fail: ((fs->blocksize - (8 + dx_csum_size)) / sizeof(struct ext2_dx_entry)))) dx_db->type = DX_DIRBLOCK_NODE; - is_leaf = 0; + is_leaf = (dx_db->type == DX_DIRBLOCK_LEAF); } out_htree: diff --git a/e2fsck/problem.c b/e2fsck/problem.c index 9ef689a20..f761ec98f 100644 --- a/e2fsck/problem.c +++ b/e2fsck/problem.c @@ -1600,7 +1600,7 @@ static struct e2fsck_problem problem_table[] = { /* leaf node passes checks but fails checksum */ { PR_2_LEAF_NODE_ONLY_CSUM_INVALID, - N_("@d @i %i, %B, offset %N: @d passes checks but fails checksum.\n"), + N_("@d @i %i, %B: @d passes checks but fails checksum.\n"), PROMPT_FIX, PR_PREEN_OK }, /* inline directory inode size must be a multiple of 4 */ diff --git a/tests/f_dir_bad_csum/expect.1 b/tests/f_dir_bad_csum/expect.1 index b2b2faeb4..94e72daab 100644 --- a/tests/f_dir_bad_csum/expect.1 +++ b/tests/f_dir_bad_csum/expect.1 @@ -1,6 +1,6 @@ Pass 1: Checking inodes, blocks, and sizes Pass 2: Checking directory structure -Directory inode 12, block #0, offset 12: directory passes checks but fails checksum. +Directory inode 12, block #0: directory passes checks but fails checksum. Fix? yes Directory inode 13, block #0, offset 0: directory has no checksum. diff --git a/tests/f_htree_leaf_csum/expect.1 b/tests/f_htree_leaf_csum/expect.1 new file mode 100644 index 000000000..d6b179ee9 --- /dev/null +++ b/tests/f_htree_leaf_csum/expect.1 @@ -0,0 +1,12 @@ +Pass 1: Checking inodes, blocks, and sizes +Pass 2: Checking directory structure +Directory inode 12, block #1: directory passes checks but fails checksum. +Fix? yes + +Pass 3: Checking directory connectivity +Pass 4: Checking reference counts +Pass 5: Checking group summary information + +test_filesys: ***** FILE SYSTEM WAS MODIFIED ***** +test_filesys: 430/512 files (0.2% non-contiguous), 45/512 blocks +Exit status is 1 diff --git a/tests/f_htree_leaf_csum/expect.2 b/tests/f_htree_leaf_csum/expect.2 new file mode 100644 index 000000000..1609785e3 --- /dev/null +++ b/tests/f_htree_leaf_csum/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: 430/512 files (0.2% non-contiguous), 45/512 blocks +Exit status is 0 diff --git a/tests/f_htree_leaf_csum/image.gz b/tests/f_htree_leaf_csum/image.gz new file mode 100644 index 000000000..f2e461990 Binary files /dev/null and b/tests/f_htree_leaf_csum/image.gz differ diff --git a/tests/f_htree_leaf_csum/name b/tests/f_htree_leaf_csum/name new file mode 100644 index 000000000..43c6ada03 --- /dev/null +++ b/tests/f_htree_leaf_csum/name @@ -0,0 +1 @@ +bad csum in htree leaf block