Add --force-offline-reencrypt option.

It can be used to enforce offline reencryption
in batch mode when data_device is regular file
and therefore cryptsetup cannot detect properly
active device dm name.

Also it may be useful when active device
auto-detection fails for some reason and user
has no other choice but inspect device holders
manually.
This commit is contained in:
Ondrej Kozina
2022-04-06 19:09:10 +02:00
parent 496a0e37c4
commit 31c4afbc17
7 changed files with 23 additions and 35 deletions

View File

@@ -126,7 +126,7 @@ static int reencrypt_get_active_name(struct crypt_device *cd, const char *data_d
assert(cd);
assert(r_active_name);
if (ARG_SET(OPT_INIT_ONLY_ID)) {
if (ARG_SET(OPT_INIT_ONLY_ID) || ARG_SET(OPT_FORCE_OFFLINE_REENCRYPT_ID)) {
*r_active_name = NULL;
return 0;
}
@@ -870,6 +870,9 @@ static int reencrypt_luks2_resume(struct crypt_device *cd)
.device = tools_get_device_name(crypt_get_device_name(cd), &backing_file)
};
if (ARG_SET(OPT_FORCE_OFFLINE_REENCRYPT_ID) && !ARG_SET(OPT_BATCH_MODE_ID))
log_std(_("Resuming LUKS reencryption in forced offline mode.\n"));
set_int_handler(0);
r = crypt_reencrypt_run(cd, tools_progress, &prog_parms);
free(backing_file);