On 6/10/25 20:37, Sheng Yong wrote: > 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> > --- > 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 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 4d05e1b4a21b..14677128dc2d 100644 > --- a/fsck/fsck.c > +++ b/fsck/fsck.c > @@ -3834,7 +3834,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 c5d41597934a..b01a22c8cf53 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");
It needs to update manual of fsck.f2fs and dump.f2fs as well? Thanks, > @@ -263,7 +265,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[] = { > @@ -396,6 +398,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", > @@ -449,7 +454,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, > @@ -527,6 +532,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; > @@ -1369,7 +1377,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 f7268d1e90ff..5cd4ad666c06 100644 > --- a/include/f2fs_fs.h > +++ b/include/f2fs_fs.h > @@ -1593,6 +1593,7 @@ struct f2fs_configuration { > int whint; > int aliased_devices; > uint32_t aliased_segments; > + bool answer_no; > > /* mkfs parameters */ > int fake_seed; _______________________________________________ Linux-f2fs-devel mailing list Linux-f2fs-devel@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/linux-f2fs-devel