summaryrefslogtreecommitdiff
path: root/cmds-subvolume.c
diff options
context:
space:
mode:
authorDavid Sterba <dsterba@suse.com>2016-01-13 15:38:28 +0100
committerDavid Sterba <dsterba@suse.com>2016-01-13 16:43:48 +0100
commit0aa796cad7ed3fce9d5964646a8f1f5a142b4989 (patch)
tree09826ebe4b46c6d1ff4cf9f86781179277969f6d /cmds-subvolume.c
parentb9ec406c0fe1abb06b39eca57a1fd6b97e8e62ee (diff)
btrfs-progs: subvol show: handle options by getopt
The subvolume show command does not take any optios but at least it should honor "--", as reported. Bugzilla: https://bugzilla.kernel.org/show_bug.cgi?id=110181 Reported-by: <moviuro+kernel@gmail.com> Signed-off-by: David Sterba <dsterba@suse.com>
Diffstat (limited to 'cmds-subvolume.c')
-rw-r--r--cmds-subvolume.c21
1 files changed, 18 insertions, 3 deletions
diff --git a/cmds-subvolume.c b/cmds-subvolume.c
index 424b00b4..26af0a71 100644
--- a/cmds-subvolume.c
+++ b/cmds-subvolume.c
@@ -921,13 +921,28 @@ static int cmd_subvol_show(int argc, char **argv)
int ret = 1;
DIR *dirstream1 = NULL, *dirstream2 = NULL;
- if (check_argc_exact(argc, 2))
+ while (1) {
+ static const struct option long_options[] = {
+ {NULL, 0, NULL, 0}
+ };
+ int c = getopt_long(argc, argv, "", long_options, NULL);
+
+ if (c < 0)
+ break;
+
+ switch (c) {
+ default:
+ usage(cmd_subvol_show_usage);
+ }
+ }
+
+ if (check_argc_exact(argc - optind, 1))
usage(cmd_subvol_show_usage);
- fullpath = realpath(argv[1], NULL);
+ fullpath = realpath(argv[optind], NULL);
if (!fullpath) {
error("cannot find real path for '%s': %s",
- argv[1], strerror(errno));
+ argv[optind], strerror(errno));
goto out;
}