@@ -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);
@@ -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;
@@ -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:
@@ -1545,6 +1545,7 @@ struct f2fs_configuration {
int whint;
int aliased_devices;
uint32_t aliased_segments;
+ bool answer_no;
/* mkfs parameters */
int fake_seed;
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 <shengyong@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(-)