@@ -234,6 +234,8 @@ static const char * const cmd_subvol_delete_usage[] = {
"-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",
+ HELPINFO_INSERT_GLOBALS,
+ 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++;
+ bconf_be_verbose();
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(1, "Transaction commit: %s\n",
+ !commit_mode ? "none (default)" :
+ commit_mode == COMMIT_AFTER ? "at the end" : "after each");
cnt = optind;
@@ -353,11 +352,9 @@ 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(1, " 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 +395,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(1,
+ "final sync is done for fsid: %s\n",
+ uuidbuf);
}
seen = seen->next;
}
Transpire global --verbose option down to the btrfs subvolume delete sub-command. 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() No need to init bconf.verbose in the sub command. cmds/subvolume.c | 28 +++++++++++++--------------- 1 file changed, 13 insertions(+), 15 deletions(-)