[v2,15/20] btrfs-progs: sub list: Update help message of -d option
diff mbox

Message ID 113c9e55f4eb4fab5fb991be0fe1288f64f66316.1529310485.git.misono.tomohiro@jp.fujitsu.com
State New
Headers show

Commit Message

Misono Tomohiro June 18, 2018, 8:41 a.m. UTC
Explicitly states that -d requires root privileges.
Also, update some option handling with regard to -d option.

Signed-off-by: Misono Tomohiro <misono.tomohiro@jp.fujitsu.com>
---
 Documentation/btrfs-subvolume.asciidoc | 3 ++-
 cmds-subvolume.c                       | 8 ++++++++
 2 files changed, 10 insertions(+), 1 deletion(-)

Patch
diff mbox

diff --git a/Documentation/btrfs-subvolume.asciidoc b/Documentation/btrfs-subvolume.asciidoc
index 0381c92c..2db1d479 100644
--- a/Documentation/btrfs-subvolume.asciidoc
+++ b/Documentation/btrfs-subvolume.asciidoc
@@ -149,7 +149,8 @@  only snapshot subvolumes in the filesystem will be listed.
 -r::::
 only readonly subvolumes in the filesystem will be listed.
 -d::::
-list deleted subvolumes that are not yet cleaned.
+list deleted subvolumes that are not yet cleaned
+(require root privileges).
 
 Other;;
 -t::::
diff --git a/cmds-subvolume.c b/cmds-subvolume.c
index 552c6dea..ef39789a 100644
--- a/cmds-subvolume.c
+++ b/cmds-subvolume.c
@@ -1569,6 +1569,7 @@  static const char * const cmd_subvol_list_usage[] = {
 	"-s           list only snapshots",
 	"-r           list readonly subvolumes (including snapshots)",
 	"-d           list deleted subvolumes that are not yet cleaned",
+	"             (require root privileges)",
 	"",
 	"Other:",
 	"-t           print the result as a table",
@@ -1744,6 +1745,13 @@  static int cmd_subvol_list(int argc, char **argv)
 		goto out;
 	}
 
+	if (filter_set->only_deleted &&
+			(is_list_all || absolute_path || follow_mount)) {
+		ret = -1;
+		error("cannot use -d with -a/f/A option");
+		goto out;
+	}
+
 	subvol = argv[optind];
 	fd = btrfs_open_dir(subvol, &dirstream, 1);
 	if (fd < 0) {