diff --git a/Documentation/btrfs-subvolume.asciidoc b/Documentation/btrfs-subvolume.asciidoc index c187fd8685..a2452a00a2 100644 --- a/Documentation/btrfs-subvolume.asciidoc +++ b/Documentation/btrfs-subvolume.asciidoc @@ -43,7 +43,7 @@ from normal directories. SUBCOMMAND ----------- -*create* [-i ] []:: +*create* [-v] [-i ] []:: Create a subvolume in . + If is not given, subvolume will be created in the currently @@ -54,6 +54,9 @@ directory. -i :::: Add the newly created subvolume to a qgroup. This option can be given multiple times. ++ +-v:::: +be a bit more verbose *delete* [options] [...]:: Delete the subvolume(s) from the filesystem. @@ -74,6 +77,9 @@ wait for transaction commit at the end of the operation + -C|--commit-each:::: wait for transaction commit after delet each subvolume ++ +-v:::: +be a bit more verbose (may be specified more than once) *find-new* :: List the recently modified files in a subvolume, after ID. @@ -145,13 +151,16 @@ command. *show* :: Show information of a given subvolume in the . -*snapshot* [-r] |[/]:: +*snapshot* [-v] [-r] |[/]:: Create a writable/readonly snapshot of the subvolume with the name in the directory. + If only is given, the subvolume will be named the basename of . If is not a subvolume, btrfs returns an error. If '-r' is given, the snapshot will be readonly. ++ +-v:::: +be a bit more verbose *sync* [subvolid...]:: Wait until given subvolume(s) are completely removed from the filesystem diff --git a/cmds-subvolume.c b/cmds-subvolume.c index be1a54a4f3..bf542e39c4 100644 --- a/cmds-subvolume.c +++ b/cmds-subvolume.c @@ -116,6 +116,7 @@ static const char * const cmd_subvol_create_usage[] = { static int cmd_subvol_create(int argc, char **argv) { int retval, res, len; + int verbose = 0; int fddst = -1; char *dupname = NULL; char *dupdir = NULL; @@ -146,6 +147,9 @@ static int cmd_subvol_create(int argc, char **argv) goto out; } break; + case 'v': + verbose++; + break; default: usage(cmd_subvol_create_usage); } @@ -185,7 +189,9 @@ static int cmd_subvol_create(int argc, char **argv) if (fddst < 0) goto out; - printf("Create subvolume '%s/%s'\n", dstdir, newname); + if (verbose) + printf("Create subvolume '%s/%s'\n", dstdir, newname); + if (inherit) { struct btrfs_ioctl_vol_args_v2 args; @@ -288,7 +294,7 @@ static int cmd_subvol_delete(int argc, char **argv) {NULL, 0, NULL, 0} }; - c = getopt_long(argc, argv, "cC", long_options, NULL); + c = getopt_long(argc, argv, "cCv", long_options, NULL); if (c < 0) break; @@ -310,7 +316,7 @@ static int cmd_subvol_delete(int argc, char **argv) if (check_argc_min(argc - optind, 1)) usage(cmd_subvol_delete_usage); - if (verbose > 0) { + if (verbose > 1) { printf("Transaction commit: %s\n", !commit_mode ? "none (default)" : commit_mode == 1 ? "at the end" : "after each"); @@ -352,9 +358,10 @@ static int cmd_subvol_delete(int argc, char **argv) goto out; } - printf("Delete subvolume (%s): '%s/%s'\n", - commit_mode == 2 || (commit_mode == 1 && cnt + 1 == argc) - ? "commit" : "no-commit", dname, vname); + if (verbose) + printf("Delete subvolume (%s): '%s/%s'\n", + commit_mode == 2 || (commit_mode == 1 && cnt + 1 == argc) + ? "commit" : "no-commit", dname, vname); memset(&args, 0, sizeof(args)); strncpy_null(args.name, vname); res = ioctl(fd, BTRFS_IOC_SNAP_DESTROY, &args); @@ -628,6 +635,7 @@ static int cmd_subvol_snapshot(int argc, char **argv) int res, retval; int fd = -1, fddst = -1; int len, readonly = 0; + int verbose = 0; char *dupname = NULL; char *dupdir = NULL; char *newname; @@ -639,7 +647,7 @@ static int cmd_subvol_snapshot(int argc, char **argv) optind = 1; memset(&args, 0, sizeof(args)); while (1) { - int c = getopt(argc, argv, "c:i:r"); + int c = getopt(argc, argv, "c:i:rv"); if (c < 0) break; @@ -661,6 +669,9 @@ static int cmd_subvol_snapshot(int argc, char **argv) case 'r': readonly = 1; break; + case 'v': + verbose++; + break; case 'x': res = qgroup_inherit_add_copy(&inherit, optarg, 1); if (res) { @@ -728,13 +739,15 @@ static int cmd_subvol_snapshot(int argc, char **argv) if (fd < 0) goto out; - if (readonly) { - args.flags |= BTRFS_SUBVOL_RDONLY; - printf("Create a readonly snapshot of '%s' in '%s/%s'\n", - subvol, dstdir, newname); - } else { - printf("Create a snapshot of '%s' in '%s/%s'\n", - subvol, dstdir, newname); + if (verbose) { + if (readonly) { + args.flags |= BTRFS_SUBVOL_RDONLY; + printf("Create a readonly snapshot of '%s' in '%s/%s'\n", + subvol, dstdir, newname); + } else { + printf("Create a snapshot of '%s' in '%s/%s'\n", + subvol, dstdir, newname); + } } args.fd = fd;