From babe94e4817aca45aef409b7a21bc47e51cda6ff Mon Sep 17 00:00:00 2001 From: David Sterba Date: Tue, 1 Mar 2016 16:02:08 +0100 Subject: 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 --- cmds-subvolume.c | 20 +++++++++++++------- 1 file changed, 13 insertions(+), 7 deletions(-) (limited to 'cmds-subvolume.c') diff --git a/cmds-subvolume.c b/cmds-subvolume.c index 9d9b0af7..02e1dec1 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) { -- cgit v1.2.3