diff mbox series

[v2,10/16] btrfs-progs: rescue super-recover: use global verbose option

Message ID 1574678357-22222-11-git-send-email-anand.jain@oracle.com (mailing list archive)
State New, archived
Headers show
Series btrfs-progs: global verbose and quiet option | expand

Commit Message

Anand Jain Nov. 25, 2019, 10:39 a.m. UTC
Transpire global --verbose option down to the btrfs rescue super-recover
sub-command.

For example: Both global and local verbose options are now supported.
btrfs -v|--verbose rescue super-recover
btrfs rescue super-recover -v

Suggested-by: David Sterba <dsterba@suse.com>
Signed-off-by: Anand Jain <anand.jain@oracle.com>
---
v2: Use new helper functions and defines
     HELPINFO_INSERT_GLOBALS, BTRFS_BCONF_UNSET, BTRFS_BCONF_QUIET
     bconf_be_verbose(), bconf_be_quiet()
    Drop verbose argument in btrfs_recover_superblocks()

 cmds/rescue-super-recover.c | 7 +++----
 cmds/rescue.c               | 7 ++++---
 cmds/rescue.h               | 2 +-
 3 files changed, 8 insertions(+), 8 deletions(-)
diff mbox series

Patch

diff --git a/cmds/rescue-super-recover.c b/cmds/rescue-super-recover.c
index 5d6bea836c8b..3a60eb40c8bb 100644
--- a/cmds/rescue-super-recover.c
+++ b/cmds/rescue-super-recover.c
@@ -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);
 	}
diff --git a/cmds/rescue.c b/cmds/rescue.c
index 19de5235a22e..2e14c98ba911 100644
--- a/cmds/rescue.c
+++ b/cmds/rescue.c
@@ -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");
diff --git a/cmds/rescue.h b/cmds/rescue.h
index e594954f78e2..3b99ec6b0daa 100644
--- a/cmds/rescue.h
+++ b/cmds/rescue.h
@@ -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