@@ -28,6 +28,8 @@
#include "common/help.h"
#include "cmds/rescue.h"
+extern bool global_verbose;
+
static const char * const rescue_cmd_group_usage[] = {
"btrfs rescue <command> [options] <path>",
NULL
@@ -37,9 +39,9 @@ static const char * const cmd_rescue_chunk_recover_usage[] = {
"btrfs rescue chunk-recover [options] <device>",
"Recover the chunk tree by scanning the devices one by one.",
"",
- "-y Assume an answer of `yes' to all questions",
- "-v Verbose mode",
- "-h Help",
+ "-y Assume an answer of `yes' to all questions",
+ HELPINFO_INSERT_VERBOSE_SHORT,
+ "-h Help",
NULL
};
@@ -49,7 +51,6 @@ static int cmd_rescue_chunk_recover(const struct cmd_struct *cmd,
int ret = 0;
char *file;
int yes = 0;
- int verbose = 0;
optind = 0;
while (1) {
@@ -61,7 +62,7 @@ static int cmd_rescue_chunk_recover(const struct cmd_struct *cmd,
yes = 1;
break;
case 'v':
- verbose = 1;
+ global_verbose = true;
break;
default:
usage_unknown_option(cmd, argv);
@@ -83,7 +84,7 @@ static int cmd_rescue_chunk_recover(const struct cmd_struct *cmd,
return 1;
}
- ret = btrfs_recover_chunk_tree(file, verbose, yes);
+ ret = btrfs_recover_chunk_tree(file, global_verbose, yes);
if (!ret) {
fprintf(stdout, "Chunk tree recovered successfully\n");
} else if (ret > 0) {
Now with this patch the btrfs rescue chunk-recover can display verbose output either at the sub-command level or at the top level. For example 'btrfs --verbose rescue chunk-recover <>' or 'btrfs rescue chunk-recover -v <>'. Suggested-by: David Sterba <dsterba@suse.com> Signed-off-by: Anand Jain <anand.jain@oracle.com> --- cmds/rescue.c | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-)