]> git.ipfire.org Git - thirdparty/e2fsprogs.git/commitdiff
e2fsck: check htree leaf block checksums
authorDarrick J. Wong <darrick.wong@oracle.com>
Wed, 22 Jul 2015 04:06:43 +0000 (00:06 -0400)
committerTheodore Ts'o <tytso@mit.edu>
Wed, 22 Jul 2015 04:06:43 +0000 (00:06 -0400)
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 <darrick.wong@oracle.com>
Signed-off-by: Theodore Ts'o <tytso@mit.edu>
e2fsck/pass2.c
e2fsck/problem.c
tests/f_dir_bad_csum/expect.1
tests/f_htree_leaf_csum/expect.1 [new file with mode: 0644]
tests/f_htree_leaf_csum/expect.2 [new file with mode: 0644]
tests/f_htree_leaf_csum/image.gz [new file with mode: 0644]
tests/f_htree_leaf_csum/name [new file with mode: 0644]

index 2e9a90d48bcac62d42e45dd1f743e77b4f727143..4b81575f8dcf4af378d1fa18c521e7cf17b0b69f 100644 (file)
@@ -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:
 
index 9ef689a20b58fa06058664ad051ead0c36f037e9..f761ec98f237a7b5917227987a21d12961f84316 100644 (file)
@@ -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 */
index b2b2faeb42f0614ef1e40451745b19b7f99b34f7..94e72daab05c4397f41e13cbf3d306537d368895 100644 (file)
@@ -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 (file)
index 0000000..d6b179e
--- /dev/null
@@ -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 (file)
index 0000000..1609785
--- /dev/null
@@ -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 (file)
index 0000000..f2e4619
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 (file)
index 0000000..43c6ada
--- /dev/null
@@ -0,0 +1 @@
+bad csum in htree leaf block