[RFC,2/3] btrfs-progs: receive: let option quiet overrule verbose
diff mbox series

Message ID 20191024062825.13097-3-anand.jain@oracle.com
State New
Headers show
Series
  • btrfs-progs: make quiet to overrule verbose
Related show

Commit Message

Anand Jain Oct. 24, 2019, 6:28 a.m. UTC
btrfs receive has both -q|--quiet and -v|--verbose options, if when both
the options are specified, the order of the options makes difference in
the output, which is at times causes confusion.

Fix this by letting option --quite to overrule --verbose option.

Without fix:
---- btrfs receive -q -vv -f /tmp/t /btrfs1 -----
At snapshot ss3
receiving snapshot ss3 uuid=9d0001ec-29e4-194a-a13e-42d9f428d745, ctransid=11 parent_uuid=a6b75134-8865-f045-89d2-c2afcf794475, parent_ctransid=11
BTRFS_IOC_SET_RECEIVED_SUBVOL uuid=9d0001ec-29e4-194a-a13e-42d9f428d745, stransid=11
---- btrfs receive -v -q -f /tmp/t /btrfs1 -----
At snapshot ss3
---- btrfs receive -vv -q -f /tmp/t /btrfs1 -----
At snapshot ss3

with fix:
---- btrfs receive -q -vv -f /tmp/t /btrfs1 -----
At snapshot ss3
---- btrfs receive -v -q -f /tmp/t /btrfs1 -----
At snapshot ss3
---- btrfs receive -vv -q -f /tmp/t /btrfs1 -----
At snapshot ss3

The output with either of them (-q or -v) remains unaffected
by this patch, as shown below:
---- btrfs receive -q -f /tmp/t /btrfs1 -----
At snapshot ss3
---- btrfs receive -v -f /tmp/t /btrfs1 -----
At snapshot ss3
receiving snapshot ss3 uuid=9d0001ec-29e4-194a-a13e-42d9f428d745, ctransid=11 parent_uuid=a6b75134-8865-f045-89d2-c2afcf794475, parent_ctransid=11
BTRFS_IOC_SET_RECEIVED_SUBVOL uuid=9d0001ec-29e4-194a-a13e-42d9f428d745, stransid=11
---- btrfs receive -vv -f /tmp/t /btrfs1 -----
At snapshot ss3
receiving snapshot ss3 uuid=9d0001ec-29e4-194a-a13e-42d9f428d745, ctransid=11 parent_uuid=a6b75134-8865-f045-89d2-c2afcf794475, parent_ctransid=11
BTRFS_IOC_SET_RECEIVED_SUBVOL uuid=9d0001ec-29e4-194a-a13e-42d9f428d745, stransid=11

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

Patch
diff mbox series

diff --git a/cmds/receive.c b/cmds/receive.c
index 4b03938ea3eb..d8c934a7c57c 100644
--- a/cmds/receive.c
+++ b/cmds/receive.c
@@ -1291,6 +1291,7 @@  static int cmd_receive(const struct cmd_struct *cmd, int argc, char **argv)
 	u64 max_errors = 1;
 	int dump = 0;
 	int ret = 0;
+	bool quiet = false;
 
 	memset(&rctx, 0, sizeof(rctx));
 	rctx.mnt_fd = -1;
@@ -1321,7 +1322,7 @@  static int cmd_receive(const struct cmd_struct *cmd, int argc, char **argv)
 			g_verbose++;
 			break;
 		case 'q':
-			g_verbose = 0;
+			quiet = true;
 			break;
 		case 'f':
 			if (arg_copy_path(fromfile, optarg, sizeof(fromfile))) {
@@ -1356,6 +1357,9 @@  static int cmd_receive(const struct cmd_struct *cmd, int argc, char **argv)
 		}
 	}
 
+	if (quiet)
+		g_verbose = 0;
+
 	if (dump && check_argc_exact(argc - optind, 0))
 		usage(cmd);
 	if (!dump && check_argc_exact(argc - optind, 1))