From: Sheng Yong <shengyo...@xiaomi.com> In some scenario, such as autotest, it is not expected to answer question from fsck or dump. To simply answer no to all these questions, this patch adds an option `N' to do that.
Signed-off-by: Sheng Yong <shengyo...@xiaomi.com> Reviewed-by: Chao Yu <c...@kernel.org> --- v3: update manual --- fsck/dump.c | 3 +++ fsck/fsck.c | 2 +- fsck/main.c | 14 +++++++++++--- include/f2fs_fs.h | 1 + man/dump.f2fs.8 | 3 +++ man/fsck.f2fs.8 | 3 +++ 6 files changed, 22 insertions(+), 4 deletions(-) diff --git a/fsck/dump.c b/fsck/dump.c index 66d6c791ae09..10df7e593bfe 100644 --- a/fsck/dump.c +++ b/fsck/dump.c @@ -681,6 +681,9 @@ static int dump_filesystem(struct f2fs_sb_info *sbi, struct node_info *ni, if (c.show_file_map) return dump_inode_blk(sbi, ni->ino, node_blk); + if (c.answer_no) + return 0; + printf("Do you want to dump this %s into %s/? [Y/N] ", S_ISDIR(imode) ? "folder" : "file", base_path); diff --git a/fsck/fsck.c b/fsck/fsck.c index 4c36dc1d0451..0b53c67e3b8a 100644 --- a/fsck/fsck.c +++ b/fsck/fsck.c @@ -3848,7 +3848,7 @@ int fsck_verify(struct f2fs_sb_info *sbi) } #ifndef WITH_ANDROID - if (nr_unref_nid && !c.ro) { + if (nr_unref_nid && !c.ro && !c.answer_no) { char ans[255] = {0}; int res; diff --git a/fsck/main.c b/fsck/main.c index 324629ea531b..d034dc39218c 100644 --- a/fsck/main.c +++ b/fsck/main.c @@ -86,6 +86,7 @@ void fsck_usage() MSG(0, " -t show directory tree\n"); MSG(0, " -q preserve quota limits\n"); MSG(0, " -y fix all the time\n"); + MSG(0, " -N answer \"No\" for all questions\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"); @@ -114,6 +115,7 @@ void dump_usage() MSG(0, " -f do not prompt before dumping\n"); MSG(0, " -H support write hint\n"); MSG(0, " -y alias for -f\n"); + MSG(0, " -N answer \"No\" for all questions\n"); MSG(0, " -o dump inodes to the given path\n"); MSG(0, " -P preserve mode/owner/group for dumped inode\n"); MSG(0, " -L Preserves symlinks. Otherwise symlinks are dumped as regular files.\n"); @@ -266,7 +268,7 @@ void f2fs_parse_options(int argc, char *argv[]) } if (!strcmp("fsck.f2fs", prog)) { - const char *option_string = ":aC:c:m:Md:fg:HlO:p:q:StyV"; + const char *option_string = ":aC:c:m:Md:fg:HlO:p:q:StyNV"; int opt = 0, val; char *token; struct option long_opt[] = { @@ -399,6 +401,9 @@ void f2fs_parse_options(int argc, char *argv[]) c.force = 1; MSG(0, "Info: Force to fix corruption\n"); break; + case 'N': + c.answer_no = true; + break; case 'q': c.preserve_limits = atoi(optarg); MSG(0, "Info: Preserve quota limits = %d\n", @@ -452,7 +457,7 @@ void f2fs_parse_options(int argc, char *argv[]) } } else if (!strcmp("dump.f2fs", prog)) { #ifdef WITH_DUMP - const char *option_string = "d:fi:I:n:LMo:Prs:Sa:b:Vy"; + const char *option_string = "d:fi:I:n:LMo:Prs:Sa:b:VyN"; static struct dump_option dump_opt = { .nid = 0, /* default root ino */ .start_nat = -1, @@ -530,6 +535,9 @@ void f2fs_parse_options(int argc, char *argv[]) case 'f': c.force = 1; break; + case 'N': + c.answer_no = true; + break; case 'r': dump_opt.use_root_nid = 1; break; @@ -1372,7 +1380,7 @@ fsck_again: f2fs_do_umount(sbi); - if (c.func == FSCK && c.bug_on) { + if (c.func == FSCK && c.bug_on && !c.answer_no) { if (!c.ro && c.fix_on == 0 && c.auto_fix == 0 && !c.dry_run) { char ans[255] = {0}; retry: diff --git a/include/f2fs_fs.h b/include/f2fs_fs.h index 1686b9a29d4c..be2e85376c16 100644 --- a/include/f2fs_fs.h +++ b/include/f2fs_fs.h @@ -1595,6 +1595,7 @@ struct f2fs_configuration { int whint; int aliased_devices; uint32_t aliased_segments; + bool answer_no; /* mkfs parameters */ int fake_seed; diff --git a/man/dump.f2fs.8 b/man/dump.f2fs.8 index 4035d57ad6e1..975aa9c091a1 100644 --- a/man/dump.f2fs.8 +++ b/man/dump.f2fs.8 @@ -96,6 +96,9 @@ Specify a block address to retrieve its metadata information. Specify the level of debugging options. The default number is 0, which shows basic debugging messages. .TP +.BI \-N +Answer "No" for all questsions. +.TP .SH AUTHOR Initial checking code was written by Byoung Geun Kim <bgbg....@samsung.com>. .SH AVAILABILITY diff --git a/man/fsck.f2fs.8 b/man/fsck.f2fs.8 index c20c43144897..e3e3b04bb5b0 100644 --- a/man/fsck.f2fs.8 +++ b/man/fsck.f2fs.8 @@ -67,6 +67,9 @@ Enable to show every directory entries in the partition. Specify the level of debugging options. The default number is 0, which shows basic debugging messages. .TP +.BI \-N +Answer "No" for all questsions. +.TP .BI \--nolinear-lookup Tune linear lookup fallback, must specify an argument, 0: enable linear lookup, 1: disable linear lookup. For android case, it will disable linear lookup by default. .TP -- 2.43.0 _______________________________________________ Linux-f2fs-devel mailing list Linux-f2fs-devel@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/linux-f2fs-devel