In some scenarino, 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 <shengy...@oppo.com> --- fsck/dump.c | 3 +++ fsck/fsck.c | 2 +- fsck/main.c | 14 +++++++++++--- include/f2fs_fs.h | 1 + 4 files changed, 16 insertions(+), 4 deletions(-) diff --git a/fsck/dump.c b/fsck/dump.c index dc3c199bab7f..8caceaa4ae06 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 aa3fb97a7022..5a2865dacaf5 100644 --- a/fsck/fsck.c +++ b/fsck/fsck.c @@ -3693,7 +3693,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 25d50e29b6d6..b6e9bff6cdc5 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"); @@ -111,6 +112,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"); @@ -250,7 +252,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[] = { @@ -356,6 +358,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", @@ -409,7 +414,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, @@ -487,6 +492,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; @@ -1311,7 +1319,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 0cb9228288c0..d601e912bc52 100644 --- a/include/f2fs_fs.h +++ b/include/f2fs_fs.h @@ -1545,6 +1545,7 @@ struct f2fs_configuration { int whint; int aliased_devices; uint32_t aliased_segments; + bool answer_no; /* mkfs parameters */ int fake_seed; -- 2.40.1 _______________________________________________ Linux-f2fs-devel mailing list Linux-f2fs-devel@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/linux-f2fs-devel