diff options
Diffstat (limited to 'exfat/dump')
-rw-r--r-- | exfat/dump/dumpexfat.8 | 4 | ||||
-rw-r--r-- | exfat/dump/main.c | 26 |
2 files changed, 16 insertions, 14 deletions
diff --git a/exfat/dump/dumpexfat.8 b/exfat/dump/dumpexfat.8 index 36fb28ad1..7fea0653c 100644 --- a/exfat/dump/dumpexfat.8 +++ b/exfat/dump/dumpexfat.8 @@ -13,7 +13,7 @@ .B \-u ] [ -.B \-v +.B \-V ] .I device @@ -33,7 +33,7 @@ systems. Dump ranges of used sectors starting from 0 and separated with spaces. May be useful for backup tools. .TP -.BI \-v +.BI \-V Print version and copyright. .SH EXIT CODES diff --git a/exfat/dump/main.c b/exfat/dump/main.c index fa80903b8..8650d5170 100644 --- a/exfat/dump/main.c +++ b/exfat/dump/main.c @@ -140,13 +140,13 @@ static int dump_full(const char* spec, bool used_sectors) static void usage(const char* prog) { - fprintf(stderr, "Usage: %s [-s] [-u] [-v] <device>\n", prog); + fprintf(stderr, "Usage: %s [-s] [-u] [-V] <device>\n", prog); exit(1); } int main(int argc, char* argv[]) { - char** pp; + int opt; const char* spec = NULL; bool sb_only = false; bool used_sectors = false; @@ -154,24 +154,26 @@ int main(int argc, char* argv[]) printf("dumpexfat %u.%u.%u\n", EXFAT_VERSION_MAJOR, EXFAT_VERSION_MINOR, EXFAT_VERSION_PATCH); - for (pp = argv + 1; *pp; pp++) + while ((opt = getopt(argc, argv, "suV")) != -1) { - if (strcmp(*pp, "-s") == 0) + switch (opt) + { + case 's': sb_only = true; - else if (strcmp(*pp, "-u") == 0) + break; + case 'u': used_sectors = true; - else if (strcmp(*pp, "-v") == 0) - { + break; + case 'V': puts("Copyright (C) 2011-2013 Andrew Nayenko"); return 0; - } - else if (spec == NULL) - spec = *pp; - else + default: usage(argv[0]); + } } - if (spec == NULL) + if (argc - optind != 1) usage(argv[0]); + spec = argv[optind]; if (sb_only) return dump_sb(spec); |