diff options
author | Sami Kerola | 2012-06-16 00:06:20 +0200 |
---|---|---|
committer | Sami Kerola | 2012-06-17 17:59:59 +0200 |
commit | 58f0252a18f11f0b458845cedec43ee591ccabae (patch) | |
tree | a8f64ee4ef81944c99129bd9bb118788d85dca9c /misc-utils/wipefs.c | |
parent | wdctl: correct manual section reference (diff) | |
download | kernel-qcow2-util-linux-58f0252a18f11f0b458845cedec43ee591ccabae.tar.gz kernel-qcow2-util-linux-58f0252a18f11f0b458845cedec43ee591ccabae.tar.xz kernel-qcow2-util-linux-58f0252a18f11f0b458845cedec43ee591ccabae.zip |
wipefs: use exclusive_option()
Signed-off-by: Sami Kerola <kerolasa@iki.fi>
Diffstat (limited to 'misc-utils/wipefs.c')
-rw-r--r-- | misc-utils/wipefs.c | 13 |
1 files changed, 10 insertions, 3 deletions
diff --git a/misc-utils/wipefs.c b/misc-utils/wipefs.c index 259ca3766..f10b5ee4e 100644 --- a/misc-utils/wipefs.c +++ b/misc-utils/wipefs.c @@ -39,6 +39,7 @@ #include "match.h" #include "c.h" #include "closestream.h" +#include "optutils.h" struct wipe_desc { loff_t offset; /* magic string offset */ @@ -382,6 +383,13 @@ main(int argc, char **argv) int c, all = 0, has_offset = 0, noact = 0, quiet = 0; int mode = WP_MODE_PRETTY; + enum { + EXCL_NONE, + EXCL_ALL, + EXCL_OFFSET + }; + int excl_any = EXCL_NONE; + static const struct option longopts[] = { { "all", 0, 0, 'a' }, { "help", 0, 0, 'h' }, @@ -402,6 +410,7 @@ main(int argc, char **argv) while ((c = getopt_long(argc, argv, "ahno:pqt:V", longopts, NULL)) != -1) { switch(c) { case 'a': + exclusive_option(&excl_any, EXCL_ALL, "--{all,offset}"); all++; break; case 'h': @@ -411,6 +420,7 @@ main(int argc, char **argv) noact++; break; case 'o': + exclusive_option(&excl_any, EXCL_OFFSET, "--{all,offset}"); wp0 = add_offset(wp0, strtosize_or_err(optarg, _("invalid offset argument")), 1); has_offset++; @@ -434,9 +444,6 @@ main(int argc, char **argv) } } - if (wp0 && all) - errx(EXIT_FAILURE, _("--offset and --all are mutually exclusive")); - if (optind == argc) usage(stderr); |