[RFC,07/14] btrfs-progs: migrate rescue chunk-recover to global verbose
diff mbox series

Message ID 1571652082-25982-8-git-send-email-anand.jain@oracle.com
State New
Headers show
Series
  • btrfs-progs: global-verbose option
Related show

Commit Message

Anand Jain Oct. 21, 2019, 10:01 a.m. UTC
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(-)

Patch
diff mbox series

diff --git a/cmds/rescue.c b/cmds/rescue.c
index e8eab6808bc3..1785bc164264 100644
--- a/cmds/rescue.c
+++ b/cmds/rescue.c
@@ -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) {