summaryrefslogtreecommitdiff
path: root/cmds-restore.c
diff options
context:
space:
mode:
authorDavid Sterba <dsterba@suse.cz>2015-01-19 13:30:06 +0100
committerDavid Sterba <dsterba@suse.cz>2015-01-19 13:30:06 +0100
commitecbf1339a63e99a8ef7d5ddc334e38a39f291d3d (patch)
tree0483487c6fa237ac649c4bd0414bb564a7111925 /cmds-restore.c
parentca7b429f263ab19acf606846dd560be7e8519302 (diff)
btrfs-progs: cleanup, move getop long options close to their use
Move long_option defintions just before getopt_long everywhere. Signed-off-by: David Sterba <dsterba@suse.cz>
Diffstat (limited to 'cmds-restore.c')
-rw-r--r--cmds-restore.c23
1 files changed, 13 insertions, 10 deletions
diff --git a/cmds-restore.c b/cmds-restore.c
index 859deaf3..795332db 100644
--- a/cmds-restore.c
+++ b/cmds-restore.c
@@ -1122,12 +1122,6 @@ out:
return ret;
}
-static struct option long_options[] = {
- { "path-regex", 1, NULL, 256},
- { "dry-run", 0, NULL, 'D'},
- { NULL, 0, NULL, 0}
-};
-
const char * const cmd_restore_usage[] = {
"btrfs restore [options] <device> <path> | -l <device>",
"Try to restore files from a damaged filesystem (unmounted)",
@@ -1162,8 +1156,6 @@ int cmd_restore(int argc, char **argv)
u64 root_objectid = 0;
int len;
int ret;
- int opt;
- int option_index = 0;
int super_mirror = 0;
int find_dir = 0;
int list_roots = 0;
@@ -1172,8 +1164,19 @@ int cmd_restore(int argc, char **argv)
regex_t match_reg, *mreg = NULL;
char reg_err[256];
- while ((opt = getopt_long(argc, argv, "sxviot:u:df:r:lDc", long_options,
- &option_index)) != -1) {
+ while (1) {
+ int opt;
+ int option_index = 0;
+ static struct option long_options[] = {
+ { "path-regex", 1, NULL, 256},
+ { "dry-run", 0, NULL, 'D'},
+ { NULL, 0, NULL, 0}
+ };
+
+ opt = getopt_long(argc, argv, "sxviot:u:df:r:lDc", long_options,
+ &option_index);
+ if (opt < 0)
+ break;
switch (opt) {
case 's':