+ usage(popt_context, EXIT_FAILURE, buf,
+ poptGetInvocationName(popt_context));
+ }
+
+ /* FIXME: rewrite this from scratch */
+
+ if (opt_shared && strcmp(aname, "create"))
+ usage(popt_context, EXIT_FAILURE,
+ _("Option --shared is allowed only for create operation.\n"),
+ poptGetInvocationName(popt_context));
+
+ if (opt_allow_discards &&
+ strcmp(aname, "luksOpen") &&
+ strcmp(aname, "create") &&
+ strcmp(aname, "loopaesOpen"))
+ usage(popt_context, EXIT_FAILURE,
+ _("Option --allow-discards is allowed only for luksOpen, loopaesOpen and create operation.\n"),
+ poptGetInvocationName(popt_context));
+
+ if (opt_key_size &&
+ strcmp(aname, "luksFormat") &&
+ strcmp(aname, "create") &&
+ strcmp(aname, "loopaesOpen") &&
+ strcmp(aname, "benchmark"))
+ usage(popt_context, EXIT_FAILURE,
+ _("Option --key-size is allowed only for luksFormat, create, loopaesOpen and benchmark.\n"
+ "To limit read from keyfile use --keyfile-size=(bytes)."),
+ poptGetInvocationName(popt_context));
+
+ if (opt_test_passphrase &&
+ strcmp(aname, "luksOpen"))
+ usage(popt_context, EXIT_FAILURE,
+ _("Option --test-passphrase is allowed only for luksOpen.\n"),
+ poptGetInvocationName(popt_context));
+
+ if (opt_key_size % 8)
+ usage(popt_context, EXIT_FAILURE,
+ _("Key size must be a multiple of 8 bits"),
+ poptGetInvocationName(popt_context));
+
+ if (!strcmp(aname, "luksKillSlot") && action_argc > 1)
+ opt_key_slot = atoi(action_argv[1]);
+ if (opt_key_slot != CRYPT_ANY_SLOT &&
+ (opt_key_slot < 0 || opt_key_slot >= crypt_keyslot_max(CRYPT_LUKS1)))
+ usage(popt_context, EXIT_FAILURE, _("Key slot is invalid."),