From: Karel Zak Date: Fri, 24 Feb 2017 10:59:53 +0000 (+0100) Subject: blkzone: use optutils.h to check mutually exclusive options X-Git-Tag: v2.30-rc1~212 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=c16970f794e43e4a8aff954a663792268b87dfde;p=thirdparty%2Futil-linux.git blkzone: use optutils.h to check mutually exclusive options Signed-off-by: Karel Zak --- diff --git a/sys-utils/blkzone.c b/sys-utils/blkzone.c index b9f1ed7528..e2c33770cb 100644 --- a/sys-utils/blkzone.c +++ b/sys-utils/blkzone.c @@ -42,6 +42,7 @@ #include "closestream.h" #include "blkdev.h" #include "sysfs.h" +#include "optutils.h" struct blkzone_control; @@ -305,8 +306,8 @@ static void __attribute__((__noreturn__)) usage(FILE *out) fputs(USAGE_OPTIONS, out); fputs(_(" -o, --offset start sector of zone to act (in 512-byte sectors)\n"), out); - fputs(_(" -l, --length maximum sectors to act (in 512-byte sectors)\n"), out); - fputs(_(" -c, --count maximum number of zones\n"), out); + fputs(_(" -l, --length maximum sectors to act (in 512-byte sectors)\n"), out); + fputs(_(" -c, --count maximum number of zones\n"), out); fputs(_(" -v, --verbose display more details\n"), out); fputs(USAGE_SEPARATOR, out); fputs(USAGE_HELP, out); @@ -328,13 +329,19 @@ int main(int argc, char **argv) static const struct option longopts[] = { { "help", no_argument, NULL, 'h' }, - { "count", required_argument, NULL, 'c' }, /* max #of zones to operate on */ + { "count", required_argument, NULL, 'c' }, /* max #of zones to operate on */ { "length", required_argument, NULL, 'l' }, /* max of sectors to operate on */ { "offset", required_argument, NULL, 'o' }, /* starting LBA */ { "verbose", no_argument, NULL, 'v' }, { "version", no_argument, NULL, 'V' }, { NULL, 0, NULL, 0 } }; + static const ul_excl_t excl[] = { /* rows and cols in ASCII order */ + { 'c', 'l' }, + { 0 } + }; + int excl_st[ARRAY_SIZE(excl)] = UL_EXCL_STATUS_INIT; + setlocale(LC_ALL, ""); bindtextdomain(PACKAGE, LOCALEDIR); @@ -350,6 +357,9 @@ int main(int argc, char **argv) } while ((c = getopt_long(argc, argv, "hc:l:o:vV", longopts, NULL)) != -1) { + + err_exclusive_options(c, longopts, excl, excl_st); + switch (c) { case 'h': usage(stdout); @@ -380,9 +390,6 @@ int main(int argc, char **argv) if (!ctl.command) errx(EXIT_FAILURE, _("no command specified")); - if (ctl.count && ctl.length) - errx(EXIT_FAILURE, _("zone count and number of sectors cannot be specified together")); - if (optind == argc) errx(EXIT_FAILURE, _("no device specified")); ctl.devname = argv[optind++];