Whamcloud - gitweb
e2image: ignore checksum errors
authorDarrick J. Wong <darrick.wong@oracle.com>
Tue, 19 Apr 2016 19:20:30 +0000 (12:20 -0700)
committerTheodore Ts'o <tytso@mit.edu>
Mon, 25 Apr 2016 15:03:09 +0000 (11:03 -0400)
Since e2image is used to capture broken fs images for debugging,
ignore checksum errors when creating the image.

Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com>
Signed-off-by: Theodore Ts'o <tytso@mit.edu>
misc/e2image.c
tests/filter.sed
tests/m_corrupt_e2image/expect [new file with mode: 0644]
tests/m_corrupt_e2image/image.gz [new file with mode: 0644]
tests/m_corrupt_e2image/name [new file with mode: 0644]
tests/m_corrupt_e2image/script [new file with mode: 0644]

index 690ad2c..e0c3188 100644 (file)
@@ -1374,7 +1374,8 @@ static void install_image(char *device, char *image_fn, int type)
 {
        errcode_t retval;
        ext2_filsys fs;
-       int open_flag = EXT2_FLAG_IMAGE_FILE | EXT2_FLAG_64BITS;
+       int open_flag = EXT2_FLAG_IMAGE_FILE | EXT2_FLAG_64BITS |
+                       EXT2_FLAG_IGNORE_CSUM_ERRORS;
        int fd = 0;
        io_manager      io_ptr;
        io_channel      io;
@@ -1451,7 +1452,7 @@ int main (int argc, char ** argv)
        ext2_filsys fs;
        char *image_fn, offset_opt[64];
        struct ext2_qcow2_hdr *header = NULL;
-       int open_flag = EXT2_FLAG_64BITS;
+       int open_flag = EXT2_FLAG_64BITS | EXT2_FLAG_IGNORE_CSUM_ERRORS;
        int img_type = 0;
        int flags = 0;
        int mount_flags = 0;
index 4a630bf..bec899c 100644 (file)
@@ -4,6 +4,7 @@
 /^mke2fs [1-9]\.[0-9]*[.-][^ ]* ([0-9]*-[A-Za-z]*-[0-9]*)/d
 /^resize2fs [1-9]\.[0-9]*[.-][^ ]* ([0-9]*-[A-Za-z]*-[0-9]*)/d
 /^tune2fs [1-9]\.[0-9]*[.-][^ ]* ([0-9]*-[A-Za-z]*-[0-9]*)/d
+/^e2image [1-9]\.[0-9]*[.-][^ ]* ([0-9]*-[A-Za-z]*-[0-9]*)/d
 s/\\015//g
 /automatically checked/d
 /^Directory Hash Seed:/d
diff --git a/tests/m_corrupt_e2image/expect b/tests/m_corrupt_e2image/expect
new file mode 100644 (file)
index 0000000..eeb967f
--- /dev/null
@@ -0,0 +1,11 @@
+Pass 1: Checking inodes, blocks, and sizes
+Inode 12 passes checks, but checksum does not match inode.  Fix? no
+
+Pass 2: Checking directory structure
+Pass 3: Checking directory connectivity
+Pass 4: Checking reference counts
+Pass 5: Checking group summary information
+
+test_filesys.bin: ********** WARNING: Filesystem still has errors **********
+
+test_filesys.bin: 12/128 files (0.0% non-contiguous), 19/512 blocks
diff --git a/tests/m_corrupt_e2image/image.gz b/tests/m_corrupt_e2image/image.gz
new file mode 100644 (file)
index 0000000..e17e921
Binary files /dev/null and b/tests/m_corrupt_e2image/image.gz differ
diff --git a/tests/m_corrupt_e2image/name b/tests/m_corrupt_e2image/name
new file mode 100644 (file)
index 0000000..1da3935
--- /dev/null
@@ -0,0 +1 @@
+e2image corrupt fs
diff --git a/tests/m_corrupt_e2image/script b/tests/m_corrupt_e2image/script
new file mode 100644 (file)
index 0000000..4c38cf4
--- /dev/null
@@ -0,0 +1,26 @@
+test_description="e2image corrupt fs"
+
+IMAGE=$test_dir/image.gz
+OUT=$test_name.log
+EXP=$test_dir/expect
+
+gzip -d < $IMAGE > $TMPFILE
+$E2IMAGE -r $TMPFILE $TMPFILE.bin >> $OUT 2>&1
+$FSCK -fn $TMPFILE.bin >> $OUT 2>&1
+
+sed -f $cmd_dir/filter.sed -e "s;$TMPFILE;test_filesys;" $OUT > $OUT.new
+mv $OUT.new $OUT
+
+cmp -s $OUT $EXP
+status=$?
+if [ "$status" = 0 ] ; then
+        echo "$test_name: $test_description: ok"
+        touch $test_name.ok
+else
+        echo "$test_name: $test_description: failed"
+        diff $DIFF_OPTS $EXP $OUT > $test_name.failed
+        rm -f $test_name.tmp
+fi
+
+rm -rf $OUT $TMPFILE $TMPFILE.bin $TMPFILE.test
+unset IMAGE FSCK_OPT OUT EXP