summaryrefslogtreecommitdiff
path: root/cmds-subvolume.c
diff options
context:
space:
mode:
authorDavid Sterba <dsterba@suse.com>2016-03-01 16:02:08 +0100
committerDavid Sterba <dsterba@suse.com>2016-03-14 13:42:47 +0100
commitbabe94e4817aca45aef409b7a21bc47e51cda6ff (patch)
treea00641b956754d6bd002bb23c6b8e3d3a18b8740 /cmds-subvolume.c
parentc27640938de1506e0a02f7f928a00886d5da616a (diff)
btrfs-progs: add getopt stubs where needed
Commands that do not take any options do not use getopt, which means the standard option separator "--" does not work. Update all command handlers that need it, argv needs to be referenced using the optind that is correctly pointed after the separator. Signed-off-by: David Sterba <dsterba@suse.com>
Diffstat (limited to 'cmds-subvolume.c')
-rw-r--r--cmds-subvolume.c20
1 files changed, 13 insertions, 7 deletions
diff --git a/cmds-subvolume.c b/cmds-subvolume.c
index 9d9b0af..02e1dec 100644
--- a/cmds-subvolume.c
+++ b/cmds-subvolume.c
@@ -788,7 +788,9 @@ static int cmd_subvol_get_default(int argc, char **argv)
u64 default_id;
DIR *dirstream = NULL;
- if (check_argc_exact(argc, 2))
+ clean_args_no_options(argc, argv, cmd_subvol_get_default_usage);
+
+ if (check_argc_exact(argc - optind, 2))
usage(cmd_subvol_get_default_usage);
subvol = argv[1];
@@ -850,11 +852,13 @@ static int cmd_subvol_set_default(int argc, char **argv)
char *subvolid;
DIR *dirstream = NULL;
- if (check_argc_exact(argc, 3))
+ clean_args_no_options(argc, argv, cmd_subvol_set_default_usage);
+
+ if (check_argc_exact(argc - optind, 2))
usage(cmd_subvol_set_default_usage);
- subvolid = argv[1];
- path = argv[2];
+ subvolid = argv[optind];
+ path = argv[optind + 1];
objectid = arg_strtou64(subvolid);
@@ -887,11 +891,13 @@ static int cmd_subvol_find_new(int argc, char **argv)
u64 last_gen;
DIR *dirstream = NULL;
- if (check_argc_exact(argc, 3))
+ clean_args_no_options(argc, argv, cmd_subvol_find_new_usage);
+
+ if (check_argc_exact(argc - optind, 2))
usage(cmd_subvol_find_new_usage);
- subvol = argv[1];
- last_gen = arg_strtou64(argv[2]);
+ subvol = argv[optind];
+ last_gen = arg_strtou64(argv[optind + 1]);
ret = test_issubvolume(subvol);
if (ret < 0) {