btrfs-progs: super-recover: add global verbose option

Propagate global --verbose option down to the btrfs rescue super-recover
subcommand.

Both global and local verbose options are now supported:

  btrfs -v rescue super-recover
  btrfs rescue super-recover -v

Signed-off-by: Anand Jain <anand.jain@oracle.com>
Signed-off-by: David Sterba <dsterba@suse.com>
This commit is contained in:
Anand Jain 2019-11-25 18:39:11 +08:00 committed by David Sterba
parent 968721ad77
commit 7c3b845f9d
3 changed files with 8 additions and 8 deletions

View File

@ -226,8 +226,7 @@ static void recover_err_str(int ret)
}
}
int btrfs_recover_superblocks(const char *dname,
int verbose, int yes)
int btrfs_recover_superblocks(const char *dname, int yes)
{
int fd, ret;
struct btrfs_recover_superblock recover;
@ -249,7 +248,7 @@ int btrfs_recover_superblocks(const char *dname,
goto no_recover;
}
if (verbose)
if (bconf.verbose > BTRFS_BCONF_QUIET)
print_all_devices(&recover.fs_devices->devices);
ret = read_fs_supers(&recover);
@ -257,7 +256,7 @@ int btrfs_recover_superblocks(const char *dname,
ret = 1;
goto no_recover;
}
if (verbose) {
if (bconf.verbose > BTRFS_BCONF_QUIET) {
printf("Before Recovering:\n");
print_all_supers(&recover);
}

View File

@ -107,6 +107,8 @@ static const char * const cmd_rescue_super_recover_usage[] = {
"",
"-y Assume an answer of `yes' to all questions",
"-v Verbose mode",
HELPINFO_INSERT_GLOBALS,
HELPINFO_INSERT_VERBOSE,
NULL
};
@ -122,7 +124,6 @@ static int cmd_rescue_super_recover(const struct cmd_struct *cmd,
int argc, char **argv)
{
int ret;
int verbose = 0;
int yes = 0;
char *dname;
@ -133,7 +134,7 @@ static int cmd_rescue_super_recover(const struct cmd_struct *cmd,
break;
switch (c) {
case 'v':
verbose = 1;
bconf_be_verbose();
break;
case 'y':
yes = 1;
@ -155,7 +156,7 @@ static int cmd_rescue_super_recover(const struct cmd_struct *cmd,
error("the device is busy");
return 1;
}
ret = btrfs_recover_superblocks(dname, verbose, yes);
ret = btrfs_recover_superblocks(dname, yes);
return ret;
}
static DEFINE_SIMPLE_COMMAND(rescue_super_recover, "super-recover");

View File

@ -15,7 +15,7 @@
#ifndef __BTRFS_RESCUE_H__
#define __BTRFS_RESCUE_H__
int btrfs_recover_superblocks(const char *path, int verbose, int yes);
int btrfs_recover_superblocks(const char *path, int yes);
int btrfs_recover_chunk_tree(const char *path, int yes);
#endif