fsck.f2fs: add --{no-}kernel-check to bypass kernel version diff or not
authorJaegeuk Kim <jaegeuk@kernel.org>
Mon, 14 Oct 2019 17:10:31 +0000 (10:10 -0700)
committerJaegeuk Kim <jaegeuk@kernel.org>
Tue, 14 Jan 2020 15:42:02 +0000 (07:42 -0800)
Given this option, fsck.f2fs does not run fsck forcefully, even if kernel
is updated. Android devices will do --kernel-check by default, while others
will not.

Signed-off-by: Jaegeuk Kim <jaegeuk@kernel.org>
fsck/main.c
fsck/mount.c
include/f2fs_fs.h
lib/libf2fs.c

index 4a4b29a..822c0e4 100644 (file)
@@ -66,6 +66,8 @@ void fsck_usage()
        MSG(0, "  -y fix all the time\n");
        MSG(0, "  -V print the version number and exit\n");
        MSG(0, "  --dry-run do not really fix corruptions\n");
+       MSG(0, "  --no-kernel-check skips detecting kernel change\n");
+       MSG(0, "  --kernel-check checks kernel change\n");
        exit(1);
 }
 
@@ -192,6 +194,8 @@ void f2fs_parse_options(int argc, char *argv[])
                char *token;
                struct option long_opt[] = {
                        {"dry-run", no_argument, 0, 1},
+                       {"no-kernel-check", no_argument, 0, 2},
+                       {"kernel-check", no_argument, 0, 3},
                        {0, 0, 0, 0}
                };
 
@@ -203,6 +207,14 @@ void f2fs_parse_options(int argc, char *argv[])
                                c.dry_run = 1;
                                MSG(0, "Info: Dry run\n");
                                break;
+                       case 2:
+                               c.no_kernel_check = 1;
+                               MSG(0, "Info: No Kernel Check\n");
+                               break;
+                       case 3:
+                               c.no_kernel_check = 0;
+                               MSG(0, "Info: Do Kernel Check\n");
+                               break;
                        case 'a':
                                c.auto_fix = 1;
                                MSG(0, "Info: Fix the reported corruption.\n");
index 882f1ea..23b1d49 100644 (file)
@@ -872,7 +872,8 @@ int validate_super_block(struct f2fs_sb_info *sbi, enum SB_ADDR sb_addr)
                MSG(0, "Info: MKFS version\n  \"%s\"\n", c.init_version);
                MSG(0, "Info: FSCK version\n  from \"%s\"\n    to \"%s\"\n",
                                        c.sb_version, c.version);
-               if (memcmp(c.sb_version, c.version, VERSION_LEN)) {
+               if (!c.no_kernel_check &&
+                               memcmp(c.sb_version, c.version, VERSION_LEN)) {
                        memcpy(sbi->raw_super->version,
                                                c.version, VERSION_LEN);
                        update_superblock(sbi->raw_super, SB_MASK(sb_addr));
index a03227e..d146f2c 100644 (file)
@@ -375,6 +375,7 @@ struct f2fs_configuration {
        int func;
        void *private;
        int dry_run;
+       int no_kernel_check;
        int fix_on;
        int force;
        int defset;
index 83a578a..bc23068 100644 (file)
@@ -655,6 +655,9 @@ void f2fs_init_configuration(void)
        c.wanted_sector_size = -1;
 #ifndef WITH_ANDROID
        c.preserve_limits = 1;
+       c.no_kernel_check = 1;
+#else
+       c.no_kernel_check = 0;
 #endif
 
        for (i = 0; i < MAX_DEVICES; i++) {