OSDN Git Service

debugfs: optionally ignore bad checksums
authorDarrick J. Wong <djwong@us.ibm.com>
Mon, 30 Jul 2012 21:46:15 +0000 (17:46 -0400)
committerTheodore Ts'o <tytso@mit.edu>
Mon, 30 Jul 2012 21:46:15 +0000 (17:46 -0400)
If someone is debugging a badly damaged filesystem, it might be useful
to disable the checksum verifications that will otherwise prevent the
filesystem from loading.

Signed-off-by: Darrick J. Wong <djwong@us.ibm.com>
Signed-off-by: Theodore Ts'o <tytso@mit.edu>
debugfs/debugfs.8.in
debugfs/debugfs.c

index ea3375e..cc5742f 100644 (file)
@@ -8,7 +8,7 @@ debugfs \- ext2/ext3/ext4 file system debugger
 .SH SYNOPSIS
 .B debugfs
 [
-.B \-DVwci
+.B \-DVwcin
 ]
 [
 .B \-b
@@ -48,6 +48,11 @@ file system (e.g /dev/hdXX).
 Specifies that the file system should be opened in read-write mode.
 Without this option, the file system is opened in read-only mode.
 .TP
+.I \-n
+Disables metadata checksum verification.  This should only be used if
+you believe the metadata to be correct despite the complaints of
+e2fsprogs.
+.TP
 .I \-c
 Specifies that the file system should be opened in catastrophic mode, in
 which the inode and group bitmaps are not read initially.  This can be
index 0c27b1e..6748edf 100644 (file)
@@ -2307,9 +2307,9 @@ int main(int argc, char **argv)
        int             catastrophic = 0;
        char            *data_filename = 0;
 #ifdef READ_ONLY
-       const char      *opt_string = "icR:f:b:s:Vd:D";
+       const char      *opt_string = "nicR:f:b:s:Vd:D";
 #else
-       const char      *opt_string = "iwcR:f:b:s:Vd:D";
+       const char      *opt_string = "niwcR:f:b:s:Vd:D";
 #endif
 
        if (debug_prog_name == 0)
@@ -2336,6 +2336,9 @@ int main(int argc, char **argv)
                case 'i':
                        open_flags |= EXT2_FLAG_IMAGE_FILE;
                        break;
+               case 'n':
+                       open_flags |= EXT2_FLAG_IGNORE_CSUM_ERRORS;
+                       break;
 #ifndef READ_ONLY
                case 'w':
                        open_flags |= EXT2_FLAG_RW;