diff mbox series

[RFC,1/3] btrfs-progs: send: let option quiet overrule verbose

Message ID 20191024062825.13097-2-anand.jain@oracle.com (mailing list archive)
State New, archived
Headers show
Series btrfs-progs: make quiet to overrule verbose | expand

Commit Message

Anand Jain Oct. 24, 2019, 6:28 a.m. UTC
btrfs send has both -q|--quiet and -v|--verbose options, now the test
here is, which option shall take the precedence if in case both of them
are specified.

Per current implementation it really depends on the order of the options
as shown below

Without fix:
---- btrfs send -q /btrfs/ss2 -f /tmp/t -----
---- btrfs send -q -v /btrfs/ss2 -f /tmp/t -----
At subvol /btrfs/ss2
---- btrfs send -q -vv /btrfs/ss2 -f /tmp/t -----
At subvol /btrfs/ss2
BTRFS_IOC_SEND returned 0
joining genl thread
---- btrfs send -v -q /btrfs/ss2 -f /tmp/t -----
---- btrfs send -vv -q /btrfs/ss2 -f /tmp/t -----
---- btrfs send -v -q -v /btrfs/ss2 -f /tmp/t -----
At subvol /btrfs/ss2

If the effectiveness of the output depends on the chronological order
of the options -q and -v specified in the command line, then its rather
confusing at times.

So fix it by making the option -q|--quiet to overrule the -v|--verbose
option if when both of them are specified.

So with the fix:
---- btrfs send -q /btrfs/ss2 -f /tmp/t -----
---- btrfs send -q -v /btrfs/ss2 -f /tmp/t -----
---- btrfs send -q -vv /btrfs/ss2 -f /tmp/t -----
---- btrfs send -v -q /btrfs/ss2 -f /tmp/t -----
---- btrfs send -vv -q /btrfs/ss2 -f /tmp/t -----
---- btrfs send -v -q -v /btrfs/ss2 -f /tmp/t -----

Signed-off-by: Anand Jain <anand.jain@oracle.com>
---
 cmds/send.c | 6 +++++-
 1 file changed, 5 insertions(+), 1 deletion(-)
diff mbox series

Patch

diff --git a/cmds/send.c b/cmds/send.c
index 7ce6c3273857..4bf2be7db4d0 100644
--- a/cmds/send.c
+++ b/cmds/send.c
@@ -477,6 +477,7 @@  static int cmd_send(const struct cmd_struct *cmd, int argc, char **argv)
 	int full_send = 1;
 	int new_end_cmd_semantic = 0;
 	u64 send_flags = 0;
+	bool quiet = false;
 
 	memset(&send, 0, sizeof(send));
 	send.dump_fd = fileno(stdout);
@@ -500,7 +501,7 @@  static int cmd_send(const struct cmd_struct *cmd, int argc, char **argv)
 			g_verbose++;
 			break;
 		case 'q':
-			g_verbose = 0;
+			quiet = true;
 			break;
 		case 'e':
 			new_end_cmd_semantic = 1;
@@ -584,6 +585,9 @@  static int cmd_send(const struct cmd_struct *cmd, int argc, char **argv)
 	if (check_argc_min(argc - optind, 1))
 		return 1;
 
+	if (quiet)
+		g_verbose = 0;
+
 	if (outname[0]) {
 		int tmpfd;