cryptsetup: add close --cancel-deferred

Allows to remove a previously set deferred removal from the command
line.

[mbroz: ported to new CLI parsing]
This commit is contained in:
Luca Boccassi
2020-07-15 15:38:07 +01:00
committed by Milan Broz
parent 3062a9ba91
commit 53d3ca0062
4 changed files with 14 additions and 1 deletions

View File

@@ -101,7 +101,7 @@ For backward compatibility there are \fBclose\fR command aliases:
\fBtcryptClose\fR (all behaves exactly the same, device type is \fBtcryptClose\fR (all behaves exactly the same, device type is
determined automatically from active device). determined automatically from active device).
\fB<options>\fR can be [\-\-deferred] \fB<options>\fR can be [\-\-deferred] or [\-\-cancel\-deferred]
.PP .PP
\fIstatus\fR <name> \fIstatus\fR <name>
@@ -1267,6 +1267,9 @@ for \fBpwquality.conf(5)\fR and \fBpasswdqc.conf(5)\fR.
.B "\-\-deferred" .B "\-\-deferred"
Defers device removal in \fIclose\fR command until the last user closes it. Defers device removal in \fIclose\fR command until the last user closes it.
.TP .TP
.B "\-\-cancel\-deferred"
Removes a previously configured deferred device removal in \fIclose\fR command.
.TP
.B "\-\-disable\-locks" .B "\-\-disable\-locks"
Disable lock protection for metadata on disk. Disable lock protection for metadata on disk.
This option is valid only for LUKS2 and ignored for other formats. This option is valid only for LUKS2 and ignored for other formats.

View File

@@ -617,6 +617,8 @@ static int action_close(void)
if (ARG_SET(OPT_DEFERRED_ID)) if (ARG_SET(OPT_DEFERRED_ID))
flags |= CRYPT_DEACTIVATE_DEFERRED; flags |= CRYPT_DEACTIVATE_DEFERRED;
if (ARG_SET(OPT_CANCEL_DEFERRED_ID))
flags |= CRYPT_DEACTIVATE_DEFERRED_CANCEL;
r = crypt_init_by_name(&cd, action_argv[0]); r = crypt_init_by_name(&cd, action_argv[0]);
if (r == 0) if (r == 0)
@@ -3679,6 +3681,11 @@ int main(int argc, const char **argv)
_("Options --refresh and --test-passphrase are mutually exclusive."), _("Options --refresh and --test-passphrase are mutually exclusive."),
poptGetInvocationName(popt_context)); poptGetInvocationName(popt_context));
if (ARG_SET(OPT_CANCEL_DEFERRED_ID) && ARG_SET(OPT_DEFERRED_ID))
usage(popt_context, EXIT_FAILURE,
_("Options --cancel-deferred and --deferred cannot be used at the same time."),
poptGetInvocationName(popt_context));
/* open action specific check */ /* open action specific check */
if (ARG_SET(OPT_SHARED_ID) && strcmp_or_null(device_type, "plain")) if (ARG_SET(OPT_SHARED_ID) && strcmp_or_null(device_type, "plain"))
usage(popt_context, EXIT_FAILURE, usage(popt_context, EXIT_FAILURE,

View File

@@ -29,6 +29,8 @@ ARG(OPT_ALLOW_DISCARDS, '\0', POPT_ARG_NONE, N_("Allow discards (aka TRIM) reque
ARG(OPT_BATCH_MODE, 'q', POPT_ARG_NONE, N_("Do not ask for confirmation"), NULL, CRYPT_ARG_BOOL, {}, {}) ARG(OPT_BATCH_MODE, 'q', POPT_ARG_NONE, N_("Do not ask for confirmation"), NULL, CRYPT_ARG_BOOL, {}, {})
ARG(OPT_CANCEL_DEFERRED, '\0', POPT_ARG_NONE, N_("Cancel a previously set deferred device removal"), NULL, CRYPT_ARG_BOOL, {}, OPT_DEFERRED_ACTIONS)
ARG(OPT_CIPHER, 'c', POPT_ARG_STRING, N_("The cipher used to encrypt the disk (see /proc/crypto)"), NULL, CRYPT_ARG_STRING, {}, {}) ARG(OPT_CIPHER, 'c', POPT_ARG_STRING, N_("The cipher used to encrypt the disk (see /proc/crypto)"), NULL, CRYPT_ARG_STRING, {}, {})
ARG(OPT_DEBUG, '\0', POPT_ARG_NONE, N_("Show debug messages"), NULL, CRYPT_ARG_BOOL, {}, {}) ARG(OPT_DEBUG, '\0', POPT_ARG_NONE, N_("Show debug messages"), NULL, CRYPT_ARG_BOOL, {}, {})

View File

@@ -30,6 +30,7 @@
#define OPT_BITMAP_SECTORS_PER_BIT "bitmap-sectors-per-bit" #define OPT_BITMAP_SECTORS_PER_BIT "bitmap-sectors-per-bit"
#define OPT_BLOCK_SIZE "block-size" #define OPT_BLOCK_SIZE "block-size"
#define OPT_BUFFER_SECTORS "buffer-sectors" #define OPT_BUFFER_SECTORS "buffer-sectors"
#define OPT_CANCEL_DEFERRED "cancel-deferred"
#define OPT_CHECK_AT_MOST_ONCE "check-at-most-once" #define OPT_CHECK_AT_MOST_ONCE "check-at-most-once"
#define OPT_CIPHER "cipher" #define OPT_CIPHER "cipher"
#define OPT_DATA_BLOCK_SIZE "data-block-size" #define OPT_DATA_BLOCK_SIZE "data-block-size"