]> git.ipfire.org Git - thirdparty/util-linux.git/commitdiff
wipefs: use exclusive_option()
authorSami Kerola <kerolasa@iki.fi>
Fri, 15 Jun 2012 22:06:20 +0000 (00:06 +0200)
committerSami Kerola <kerolasa@iki.fi>
Sun, 17 Jun 2012 15:59:59 +0000 (17:59 +0200)
Signed-off-by: Sami Kerola <kerolasa@iki.fi>
misc-utils/wipefs.c

index 259ca3766ce7c54a31f8f82daf71f77182a29bb3..f10b5ee4e22f08dbcf208d244f3ec9a27acb2a64 100644 (file)
@@ -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);