btrfs subvolume delete already supports verbose at the sub-command level, this patch restores same verbose which can be either enabled by the sub-command or from the top level command.
Suggested-by: David Sterba <dste...@suse.com> Signed-off-by: Anand Jain <anand.j...@oracle.com> --- cmds/subvolume.c | 35 +++++++++++++++++------------------ 1 file changed, 17 insertions(+), 18 deletions(-) diff --git a/cmds/subvolume.c b/cmds/subvolume.c index 7a5fd79bb1f3..18efd0cf6e4a 100644 --- a/cmds/subvolume.c +++ b/cmds/subvolume.c @@ -43,6 +43,8 @@ #include "common/path-utils.h" #include "common/device-scan.h" +extern bool global_verbose; + static int wait_for_subvolume_cleaning(int fd, size_t count, uint64_t *ids, int sleep_interval) { @@ -231,9 +233,9 @@ static const char * const cmd_subvol_delete_usage[] = { "after a crash). Use one of the --commit options to wait until the", "operation is safely stored on the media.", "", - "-c|--commit-after wait for transaction commit at the end of the operation", - "-C|--commit-each wait for transaction commit after deleting each subvolume", - "-v|--verbose verbose output of operations", + "-c|--commit-after wait for transaction commit at the end of the operation", + "-C|--commit-each wait for transaction commit after deleting each subvolume", + HELPINFO_INSERT_VERBOSE, NULL }; @@ -248,7 +250,6 @@ static int cmd_subvol_delete(const struct cmd_struct *cmd, char *dupvname = NULL; char *path; DIR *dirstream = NULL; - int verbose = 0; int commit_mode = 0; u8 fsid[BTRFS_FSID_SIZE]; char uuidbuf[BTRFS_UUID_UNPARSED_SIZE]; @@ -278,7 +279,7 @@ static int cmd_subvol_delete(const struct cmd_struct *cmd, commit_mode = COMMIT_EACH; break; case 'v': - verbose++; + global_verbose = true; break; default: usage_unknown_option(cmd, argv); @@ -288,11 +289,9 @@ static int cmd_subvol_delete(const struct cmd_struct *cmd, if (check_argc_min(argc - optind, 1)) return 1; - if (verbose > 0) { - printf("Transaction commit: %s\n", - !commit_mode ? "none (default)" : - commit_mode == COMMIT_AFTER ? "at the end" : "after each"); - } + pr_verbose(global_verbose, "Transaction commit: %s\n", + !commit_mode ? "none (default)" : + commit_mode == COMMIT_AFTER ? "at the end" : "after each"); cnt = optind; @@ -353,11 +352,10 @@ again: } if (add_seen_fsid(fsid, seen_fsid_hash, fd, dirstream) == 0) { - if (verbose > 0) { - uuid_unparse(fsid, uuidbuf); - printf(" new fs is found for '%s', fsid: %s\n", - path, uuidbuf); - } + uuid_unparse(fsid, uuidbuf); + pr_verbose(global_verbose, + " new fs is found for '%s', fsid: %s\n", + path, uuidbuf); /* * This is the first time a subvolume on this * filesystem is deleted, keep fd in order to issue @@ -398,10 +396,11 @@ keep_fd: "unable to do final sync after deletion: %m, fsid: %s", uuidbuf); ret = 1; - } else if (verbose > 0) { + } else { uuid_unparse(seen->fsid, uuidbuf); - printf("final sync is done for fsid: %s\n", - uuidbuf); + pr_verbose(global_verbose, + "final sync is done for fsid: %s\n", + uuidbuf); } seen = seen->next; } -- 1.8.3.1