#include "loopdev.h"
#include "xgetpass.h"
#include "closestream.h"
+#include "optutils.h"
+
+#define EXCL_ERROR "--{all,associated,set-capacity,detach,detach-all,find}"
enum {
A_CREATE = 1, /* setup a new device */
uint64_t offset = 0, sizelimit = 0;
int res = 0, showdev = 0, lo_flags = 0;
+ enum {
+ EXCL_NONE,
+ EXCL_ALL,
+ EXCL_ASSOCIATED,
+ EXCL_SET_CAPACITY,
+ EXCL_DETACH,
+ EXCL_DETACH_ALL,
+ EXCL_FIND
+ };
+ int excl_any = EXCL_NONE;
+
enum {
OPT_SIZELIMIT = CHAR_MAX + 1,
OPT_SHOW
while ((c = getopt_long(argc, argv, "ac:d:De:E:fhj:o:p:PrvV",
longopts, NULL)) != -1) {
-
- if (act && strchr("acdDfj", c))
- errx(EXIT_FAILURE,
- _("the options %s are mutually exclusive"),
- "--{all,associated,set-capacity,detach,detach-all,find}");
-
switch (c) {
case 'a':
+ exclusive_option(&excl_any, EXCL_ALL, EXCL_ERROR);
act = A_SHOW;
break;
case 'c':
+ exclusive_option(&excl_any, EXCL_SET_CAPACITY, EXCL_ERROR);
act = A_SET_CAPACITY;
loopcxt_set_device(&lc, optarg);
break;
lo_flags |= LO_FLAGS_READ_ONLY;
break;
case 'd':
+ exclusive_option(&excl_any, EXCL_DETACH, EXCL_ERROR);
act = A_DELETE;
loopcxt_set_device(&lc, optarg);
break;
case 'D':
+ exclusive_option(&excl_any, EXCL_DETACH_ALL, EXCL_ERROR);
act = A_DELETE_ALL;
break;
case 'E':
encryption = optarg;
break;
case 'f':
+ exclusive_option(&excl_any, EXCL_FIND, EXCL_ERROR);
act = A_FIND_FREE;
break;
case 'h':
usage(stdout);
break;
case 'j':
+ exclusive_option(&excl_any, EXCL_ASSOCIATED, EXCL_ERROR);
act = A_SHOW;
file = optarg;
break;