mirror of
https://gitlab.com/cryptsetup/cryptsetup.git
synced 2025-12-15 04:40:05 +01:00
Change --version option handling and support -V short option.
Fixes #480.
This commit is contained in:
@@ -54,7 +54,6 @@ static uint64_t opt_offset = 0;
|
|||||||
static uint64_t opt_skip = 0;
|
static uint64_t opt_skip = 0;
|
||||||
static int opt_skip_valid = 0;
|
static int opt_skip_valid = 0;
|
||||||
static int opt_readonly = 0;
|
static int opt_readonly = 0;
|
||||||
static int opt_version_mode = 0;
|
|
||||||
static int opt_timeout = 0;
|
static int opt_timeout = 0;
|
||||||
static int opt_tries = 3;
|
static int opt_tries = 3;
|
||||||
static int opt_align_payload = 0;
|
static int opt_align_payload = 0;
|
||||||
@@ -3293,6 +3292,11 @@ static void help(poptContext popt_context,
|
|||||||
#if defined(ENABLE_LUKS_ADJUST_XTS_KEYSIZE) && DEFAULT_LUKS1_KEYBITS != 512
|
#if defined(ENABLE_LUKS_ADJUST_XTS_KEYSIZE) && DEFAULT_LUKS1_KEYBITS != 512
|
||||||
log_std(_("\tLUKS: Default keysize with XTS mode (two internal keys) will be doubled.\n"));
|
log_std(_("\tLUKS: Default keysize with XTS mode (two internal keys) will be doubled.\n"));
|
||||||
#endif
|
#endif
|
||||||
|
poptFreeContext(popt_context);
|
||||||
|
exit(EXIT_SUCCESS);
|
||||||
|
} else if (key->shortName == 'V') {
|
||||||
|
log_std("%s %s\n", PACKAGE_NAME, PACKAGE_VERSION);
|
||||||
|
poptFreeContext(popt_context);
|
||||||
exit(EXIT_SUCCESS);
|
exit(EXIT_SUCCESS);
|
||||||
} else
|
} else
|
||||||
usage(popt_context, EXIT_SUCCESS, NULL, NULL);
|
usage(popt_context, EXIT_SUCCESS, NULL, NULL);
|
||||||
@@ -3342,11 +3346,11 @@ int main(int argc, const char **argv)
|
|||||||
{ NULL, '\0', POPT_ARG_CALLBACK, help, 0, NULL, NULL },
|
{ NULL, '\0', POPT_ARG_CALLBACK, help, 0, NULL, NULL },
|
||||||
{ "help", '?', POPT_ARG_NONE, NULL, 0, N_("Show this help message"), NULL },
|
{ "help", '?', POPT_ARG_NONE, NULL, 0, N_("Show this help message"), NULL },
|
||||||
{ "usage", '\0', POPT_ARG_NONE, NULL, 0, N_("Display brief usage"), NULL },
|
{ "usage", '\0', POPT_ARG_NONE, NULL, 0, N_("Display brief usage"), NULL },
|
||||||
|
{ "version",'V', POPT_ARG_NONE, NULL, 0, N_("Print package version"), NULL },
|
||||||
POPT_TABLEEND
|
POPT_TABLEEND
|
||||||
};
|
};
|
||||||
static struct poptOption popt_options[] = {
|
static struct poptOption popt_options[] = {
|
||||||
{ NULL, '\0', POPT_ARG_INCLUDE_TABLE, popt_help_options, 0, N_("Help options:"), NULL },
|
{ NULL, '\0', POPT_ARG_INCLUDE_TABLE, popt_help_options, 0, N_("Help options:"), NULL },
|
||||||
{ "version", '\0', POPT_ARG_NONE, &opt_version_mode, 0, N_("Print package version"), NULL },
|
|
||||||
{ "verbose", 'v', POPT_ARG_NONE, &opt_verbose, 0, N_("Shows more detailed error messages"), NULL },
|
{ "verbose", 'v', POPT_ARG_NONE, &opt_verbose, 0, N_("Shows more detailed error messages"), NULL },
|
||||||
{ "debug", '\0', POPT_ARG_NONE, &opt_debug, 0, N_("Show debug messages"), NULL },
|
{ "debug", '\0', POPT_ARG_NONE, &opt_debug, 0, N_("Show debug messages"), NULL },
|
||||||
{ "debug-json", '\0', POPT_ARG_NONE, &opt_debug_json, 0, N_("Show debug messages including JSON metadata"), NULL },
|
{ "debug-json", '\0', POPT_ARG_NONE, &opt_debug_json, 0, N_("Show debug messages including JSON metadata"), NULL },
|
||||||
@@ -3491,12 +3495,6 @@ int main(int argc, const char **argv)
|
|||||||
usage(popt_context, EXIT_FAILURE, poptStrerror(r),
|
usage(popt_context, EXIT_FAILURE, poptStrerror(r),
|
||||||
poptBadOption(popt_context, POPT_BADOPTION_NOALIAS));
|
poptBadOption(popt_context, POPT_BADOPTION_NOALIAS));
|
||||||
|
|
||||||
if (opt_version_mode) {
|
|
||||||
log_std("%s %s\n", PACKAGE_NAME, PACKAGE_VERSION);
|
|
||||||
poptFreeContext(popt_context);
|
|
||||||
exit(EXIT_SUCCESS);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!(aname = poptGetArg(popt_context)))
|
if (!(aname = poptGetArg(popt_context)))
|
||||||
usage(popt_context, EXIT_FAILURE, _("Argument <action> missing."),
|
usage(popt_context, EXIT_FAILURE, _("Argument <action> missing."),
|
||||||
poptGetInvocationName(popt_context));
|
poptGetInvocationName(popt_context));
|
||||||
|
|||||||
@@ -42,7 +42,6 @@ static const char *opt_pbkdf = NULL;
|
|||||||
static long opt_pbkdf_memory = DEFAULT_LUKS2_MEMORY_KB;
|
static long opt_pbkdf_memory = DEFAULT_LUKS2_MEMORY_KB;
|
||||||
static long opt_pbkdf_parallel = DEFAULT_LUKS2_PARALLEL_THREADS;
|
static long opt_pbkdf_parallel = DEFAULT_LUKS2_PARALLEL_THREADS;
|
||||||
static long opt_pbkdf_iterations = 0;
|
static long opt_pbkdf_iterations = 0;
|
||||||
static int opt_version_mode = 0;
|
|
||||||
static int opt_random = 0;
|
static int opt_random = 0;
|
||||||
static int opt_urandom = 0;
|
static int opt_urandom = 0;
|
||||||
static int opt_bsize = 4;
|
static int opt_bsize = 4;
|
||||||
@@ -1576,6 +1575,11 @@ static void help(poptContext popt_context,
|
|||||||
if (key->shortName == '?') {
|
if (key->shortName == '?') {
|
||||||
log_std("%s %s\n", PACKAGE_REENC, PACKAGE_VERSION);
|
log_std("%s %s\n", PACKAGE_REENC, PACKAGE_VERSION);
|
||||||
poptPrintHelp(popt_context, stdout, 0);
|
poptPrintHelp(popt_context, stdout, 0);
|
||||||
|
poptFreeContext(popt_context);
|
||||||
|
exit(EXIT_SUCCESS);
|
||||||
|
} else if (key->shortName == 'V') {
|
||||||
|
log_std("%s %s\n", PACKAGE_REENC, PACKAGE_VERSION);
|
||||||
|
poptFreeContext(popt_context);
|
||||||
exit(EXIT_SUCCESS);
|
exit(EXIT_SUCCESS);
|
||||||
} else
|
} else
|
||||||
usage(popt_context, EXIT_SUCCESS, NULL, NULL);
|
usage(popt_context, EXIT_SUCCESS, NULL, NULL);
|
||||||
@@ -1587,11 +1591,11 @@ int main(int argc, const char **argv)
|
|||||||
{ NULL, '\0', POPT_ARG_CALLBACK, help, 0, NULL, NULL },
|
{ NULL, '\0', POPT_ARG_CALLBACK, help, 0, NULL, NULL },
|
||||||
{ "help", '?', POPT_ARG_NONE, NULL, 0, N_("Show this help message"), NULL },
|
{ "help", '?', POPT_ARG_NONE, NULL, 0, N_("Show this help message"), NULL },
|
||||||
{ "usage", '\0', POPT_ARG_NONE, NULL, 0, N_("Display brief usage"), NULL },
|
{ "usage", '\0', POPT_ARG_NONE, NULL, 0, N_("Display brief usage"), NULL },
|
||||||
|
{ "version",'V', POPT_ARG_NONE, NULL, 0, N_("Print package version"), NULL },
|
||||||
POPT_TABLEEND
|
POPT_TABLEEND
|
||||||
};
|
};
|
||||||
static struct poptOption popt_options[] = {
|
static struct poptOption popt_options[] = {
|
||||||
{ NULL, '\0', POPT_ARG_INCLUDE_TABLE, popt_help_options, 0, N_("Help options:"), NULL },
|
{ NULL, '\0', POPT_ARG_INCLUDE_TABLE, popt_help_options, 0, N_("Help options:"), NULL },
|
||||||
{ "version", '\0', POPT_ARG_NONE, &opt_version_mode, 0, N_("Print package version"), NULL },
|
|
||||||
{ "verbose", 'v', POPT_ARG_NONE, &opt_verbose, 0, N_("Shows more detailed error messages"), NULL },
|
{ "verbose", 'v', POPT_ARG_NONE, &opt_verbose, 0, N_("Shows more detailed error messages"), NULL },
|
||||||
{ "debug", '\0', POPT_ARG_NONE, &opt_debug, 0, N_("Show debug messages"), NULL },
|
{ "debug", '\0', POPT_ARG_NONE, &opt_debug, 0, N_("Show debug messages"), NULL },
|
||||||
{ "block-size", 'B', POPT_ARG_INT, &opt_bsize, 0, N_("Reencryption block size"), N_("MiB") },
|
{ "block-size", 'B', POPT_ARG_INT, &opt_bsize, 0, N_("Reencryption block size"), N_("MiB") },
|
||||||
@@ -1644,12 +1648,6 @@ int main(int argc, const char **argv)
|
|||||||
usage(popt_context, EXIT_FAILURE, poptStrerror(r),
|
usage(popt_context, EXIT_FAILURE, poptStrerror(r),
|
||||||
poptBadOption(popt_context, POPT_BADOPTION_NOALIAS));
|
poptBadOption(popt_context, POPT_BADOPTION_NOALIAS));
|
||||||
|
|
||||||
if (opt_version_mode) {
|
|
||||||
log_std("%s %s\n", PACKAGE_REENC, PACKAGE_VERSION);
|
|
||||||
poptFreeContext(popt_context);
|
|
||||||
exit(EXIT_SUCCESS);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!opt_batch_mode)
|
if (!opt_batch_mode)
|
||||||
log_verbose(_("Reencryption will change: %s%s%s%s%s%s."),
|
log_verbose(_("Reencryption will change: %s%s%s%s%s%s."),
|
||||||
opt_keep_key ? "" : _("volume key"),
|
opt_keep_key ? "" : _("volume key"),
|
||||||
|
|||||||
@@ -61,8 +61,6 @@ static int opt_integrity_bitmap = 0;
|
|||||||
|
|
||||||
static int opt_integrity_recalculate = 0;
|
static int opt_integrity_recalculate = 0;
|
||||||
|
|
||||||
static int opt_version_mode = 0;
|
|
||||||
|
|
||||||
static const char **action_argv;
|
static const char **action_argv;
|
||||||
static int action_argc;
|
static int action_argc;
|
||||||
|
|
||||||
@@ -499,6 +497,11 @@ static void help(poptContext popt_context,
|
|||||||
log_std(_("\nDefault compiled-in dm-integrity parameters:\n"
|
log_std(_("\nDefault compiled-in dm-integrity parameters:\n"
|
||||||
"\tTag size: %u bytes, Checksum algorithm: %s\n"),
|
"\tTag size: %u bytes, Checksum algorithm: %s\n"),
|
||||||
DEFAULT_TAG_SIZE, DEFAULT_ALG_NAME);
|
DEFAULT_TAG_SIZE, DEFAULT_ALG_NAME);
|
||||||
|
poptFreeContext(popt_context);
|
||||||
|
exit(EXIT_SUCCESS);
|
||||||
|
} else if (key->shortName == 'V') {
|
||||||
|
log_std("%s %s\n", PACKAGE_INTEGRITY, PACKAGE_VERSION);
|
||||||
|
poptFreeContext(popt_context);
|
||||||
exit(EXIT_SUCCESS);
|
exit(EXIT_SUCCESS);
|
||||||
} else
|
} else
|
||||||
usage(popt_context, EXIT_SUCCESS, NULL, NULL);
|
usage(popt_context, EXIT_SUCCESS, NULL, NULL);
|
||||||
@@ -523,11 +526,11 @@ int main(int argc, const char **argv)
|
|||||||
{ NULL, '\0', POPT_ARG_CALLBACK, help, 0, NULL, NULL },
|
{ NULL, '\0', POPT_ARG_CALLBACK, help, 0, NULL, NULL },
|
||||||
{ "help", '?', POPT_ARG_NONE, NULL, 0, N_("Show this help message"), NULL },
|
{ "help", '?', POPT_ARG_NONE, NULL, 0, N_("Show this help message"), NULL },
|
||||||
{ "usage", '\0', POPT_ARG_NONE, NULL, 0, N_("Display brief usage"), NULL },
|
{ "usage", '\0', POPT_ARG_NONE, NULL, 0, N_("Display brief usage"), NULL },
|
||||||
|
{ "version",'V', POPT_ARG_NONE, NULL, 0, N_("Print package version"), NULL },
|
||||||
POPT_TABLEEND
|
POPT_TABLEEND
|
||||||
};
|
};
|
||||||
static struct poptOption popt_options[] = {
|
static struct poptOption popt_options[] = {
|
||||||
{ NULL, '\0', POPT_ARG_INCLUDE_TABLE, popt_help_options, 0, N_("Help options:"), NULL },
|
{ NULL, '\0', POPT_ARG_INCLUDE_TABLE, popt_help_options, 0, N_("Help options:"), NULL },
|
||||||
{ "version", '\0', POPT_ARG_NONE, &opt_version_mode, 0, N_("Print package version"), NULL },
|
|
||||||
{ "verbose", 'v', POPT_ARG_NONE, &opt_verbose, 0, N_("Shows more detailed error messages"), NULL },
|
{ "verbose", 'v', POPT_ARG_NONE, &opt_verbose, 0, N_("Shows more detailed error messages"), NULL },
|
||||||
{ "debug", '\0', POPT_ARG_NONE, &opt_debug, 0, N_("Show debug messages"), NULL },
|
{ "debug", '\0', POPT_ARG_NONE, &opt_debug, 0, N_("Show debug messages"), NULL },
|
||||||
{ "batch-mode", 'q', POPT_ARG_NONE, &opt_batch_mode, 0, N_("Do not ask for confirmation"), NULL },
|
{ "batch-mode", 'q', POPT_ARG_NONE, &opt_batch_mode, 0, N_("Do not ask for confirmation"), NULL },
|
||||||
@@ -587,12 +590,6 @@ int main(int argc, const char **argv)
|
|||||||
usage(popt_context, EXIT_FAILURE, poptStrerror(r),
|
usage(popt_context, EXIT_FAILURE, poptStrerror(r),
|
||||||
poptBadOption(popt_context, POPT_BADOPTION_NOALIAS));
|
poptBadOption(popt_context, POPT_BADOPTION_NOALIAS));
|
||||||
|
|
||||||
if (opt_version_mode) {
|
|
||||||
log_std("%s %s\n", PACKAGE_INTEGRITY, PACKAGE_VERSION);
|
|
||||||
poptFreeContext(popt_context);
|
|
||||||
exit(EXIT_SUCCESS);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!(aname = poptGetArg(popt_context)))
|
if (!(aname = poptGetArg(popt_context)))
|
||||||
usage(popt_context, EXIT_FAILURE, _("Argument <action> missing."),
|
usage(popt_context, EXIT_FAILURE, _("Argument <action> missing."),
|
||||||
poptGetInvocationName(popt_context));
|
poptGetInvocationName(popt_context));
|
||||||
|
|||||||
@@ -41,8 +41,6 @@ static int opt_ignore_corruption = 0;
|
|||||||
static int opt_ignore_zero_blocks = 0;
|
static int opt_ignore_zero_blocks = 0;
|
||||||
static int opt_check_at_most_once = 0;
|
static int opt_check_at_most_once = 0;
|
||||||
|
|
||||||
static int opt_version_mode = 0;
|
|
||||||
|
|
||||||
static const char **action_argv;
|
static const char **action_argv;
|
||||||
static int action_argc;
|
static int action_argc;
|
||||||
|
|
||||||
@@ -392,6 +390,11 @@ static void help(poptContext popt_context,
|
|||||||
DEFAULT_VERITY_HASH, DEFAULT_VERITY_DATA_BLOCK,
|
DEFAULT_VERITY_HASH, DEFAULT_VERITY_DATA_BLOCK,
|
||||||
DEFAULT_VERITY_HASH_BLOCK, DEFAULT_VERITY_SALT_SIZE,
|
DEFAULT_VERITY_HASH_BLOCK, DEFAULT_VERITY_SALT_SIZE,
|
||||||
1);
|
1);
|
||||||
|
poptFreeContext(popt_context);
|
||||||
|
exit(EXIT_SUCCESS);
|
||||||
|
} else if (key->shortName == 'V') {
|
||||||
|
log_std("%s %s\n", PACKAGE_VERITY, PACKAGE_VERSION);
|
||||||
|
poptFreeContext(popt_context);
|
||||||
exit(EXIT_SUCCESS);
|
exit(EXIT_SUCCESS);
|
||||||
} else
|
} else
|
||||||
usage(popt_context, EXIT_SUCCESS, NULL, NULL);
|
usage(popt_context, EXIT_SUCCESS, NULL, NULL);
|
||||||
@@ -417,11 +420,11 @@ int main(int argc, const char **argv)
|
|||||||
{ NULL, '\0', POPT_ARG_CALLBACK, help, 0, NULL, NULL },
|
{ NULL, '\0', POPT_ARG_CALLBACK, help, 0, NULL, NULL },
|
||||||
{ "help", '?', POPT_ARG_NONE, NULL, 0, N_("Show this help message"), NULL },
|
{ "help", '?', POPT_ARG_NONE, NULL, 0, N_("Show this help message"), NULL },
|
||||||
{ "usage", '\0', POPT_ARG_NONE, NULL, 0, N_("Display brief usage"), NULL },
|
{ "usage", '\0', POPT_ARG_NONE, NULL, 0, N_("Display brief usage"), NULL },
|
||||||
|
{ "version",'V', POPT_ARG_NONE, NULL, 0, N_("Print package version"), NULL },
|
||||||
POPT_TABLEEND
|
POPT_TABLEEND
|
||||||
};
|
};
|
||||||
static struct poptOption popt_options[] = {
|
static struct poptOption popt_options[] = {
|
||||||
{ NULL, '\0', POPT_ARG_INCLUDE_TABLE, popt_help_options, 0, N_("Help options:"), NULL },
|
{ NULL, '\0', POPT_ARG_INCLUDE_TABLE, popt_help_options, 0, N_("Help options:"), NULL },
|
||||||
{ "version", '\0', POPT_ARG_NONE, &opt_version_mode, 0, N_("Print package version"), NULL },
|
|
||||||
{ "verbose", 'v', POPT_ARG_NONE, &opt_verbose, 0, N_("Shows more detailed error messages"), NULL },
|
{ "verbose", 'v', POPT_ARG_NONE, &opt_verbose, 0, N_("Shows more detailed error messages"), NULL },
|
||||||
{ "debug", '\0', POPT_ARG_NONE, &opt_debug, 0, N_("Show debug messages"), NULL },
|
{ "debug", '\0', POPT_ARG_NONE, &opt_debug, 0, N_("Show debug messages"), NULL },
|
||||||
{ "no-superblock", 0, POPT_ARG_VAL, &use_superblock, 0, N_("Do not use verity superblock"), NULL },
|
{ "no-superblock", 0, POPT_ARG_VAL, &use_superblock, 0, N_("Do not use verity superblock"), NULL },
|
||||||
@@ -489,12 +492,6 @@ int main(int argc, const char **argv)
|
|||||||
usage(popt_context, EXIT_FAILURE, poptStrerror(r),
|
usage(popt_context, EXIT_FAILURE, poptStrerror(r),
|
||||||
poptBadOption(popt_context, POPT_BADOPTION_NOALIAS));
|
poptBadOption(popt_context, POPT_BADOPTION_NOALIAS));
|
||||||
|
|
||||||
if (opt_version_mode) {
|
|
||||||
log_std("%s %s\n", PACKAGE_VERITY, PACKAGE_VERSION);
|
|
||||||
poptFreeContext(popt_context);
|
|
||||||
exit(EXIT_SUCCESS);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!(aname = poptGetArg(popt_context)))
|
if (!(aname = poptGetArg(popt_context)))
|
||||||
usage(popt_context, EXIT_FAILURE, _("Argument <action> missing."),
|
usage(popt_context, EXIT_FAILURE, _("Argument <action> missing."),
|
||||||
poptGetInvocationName(popt_context));
|
poptGetInvocationName(popt_context));
|
||||||
|
|||||||
Reference in New Issue
Block a user