aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJaegeuk Kim <jaegeuk@kernel.org>2019-10-14 10:10:31 -0700
committerJaegeuk Kim <jaegeuk@kernel.org>2020-01-14 07:42:02 -0800
commit1126e38155bf53c3a73a826c0d48d906b08774d0 (patch)
tree6f9cdc5d1632dd497b37f45f558fbb9e00f83603
parentf0f29da92484c6a4faf059b48da3777f4f3f2c76 (diff)
downloadf2fs-tools-1126e38155bf53c3a73a826c0d48d906b08774d0.tar.gz
fsck.f2fs: add --{no-}kernel-check to bypass kernel version diff or not
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>
-rw-r--r--fsck/main.c12
-rw-r--r--fsck/mount.c3
-rw-r--r--include/f2fs_fs.h1
-rw-r--r--lib/libf2fs.c3
4 files changed, 18 insertions, 1 deletions
diff --git a/fsck/main.c b/fsck/main.c
index 4a4b29a..822c0e4 100644
--- a/fsck/main.c
+++ b/fsck/main.c
@@ -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");
diff --git a/fsck/mount.c b/fsck/mount.c
index 882f1ea..23b1d49 100644
--- a/fsck/mount.c
+++ b/fsck/mount.c
@@ -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));
diff --git a/include/f2fs_fs.h b/include/f2fs_fs.h
index a03227e..d146f2c 100644
--- a/include/f2fs_fs.h
+++ b/include/f2fs_fs.h
@@ -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;
diff --git a/lib/libf2fs.c b/lib/libf2fs.c
index 83a578a..bc23068 100644
--- a/lib/libf2fs.c
+++ b/lib/libf2fs.c
@@ -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++) {