From: Valentin David Date: Thu, 12 Mar 2026 22:14:45 +0000 (+0100) Subject: repart: Allow keeping luks2 volumes opened X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=77b15343bcd861b866007035895e9a51bd0a0063;p=thirdparty%2Fsystemd.git repart: Allow keeping luks2 volumes opened --- diff --git a/src/repart/repart.c b/src/repart/repart.c index 0e5ba58af2a..a2958f3212f 100644 --- a/src/repart/repart.c +++ b/src/repart/repart.c @@ -4920,6 +4920,7 @@ typedef struct DecryptedPartitionTarget { int fd; char *dm_name; char *volume; + bool keep; struct crypt_device *device; } DecryptedPartitionTarget; @@ -4932,11 +4933,14 @@ static DecryptedPartitionTarget* decrypted_partition_target_free(DecryptedPartit safe_close(t->fd); - /* udev or so might access out block device in the background while we are done. Let's hence - * force detach the volume. We sync'ed before, hence this should be safe. */ - r = sym_crypt_deactivate_by_name(t->device, t->dm_name, CRYPT_DEACTIVATE_FORCE); - if (r < 0) - log_warning_errno(r, "Failed to deactivate LUKS device, ignoring: %m"); + if (!t->keep) { + /* udev or so might access our block device in the background while we are done. Let's hence + * force detach the volume. We sync'ed before, hence this should be safe. */ + r = sym_crypt_deactivate_by_name(t->device, t->dm_name, CRYPT_DEACTIVATE_FORCE); + if (r < 0) + log_warning_errno(r, "Failed to deactivate LUKS device, ignoring: %m"); + } else + log_debug("Keeping encrypted device '%s' open.", t->dm_name); sym_crypt_free(t->device); free(t->dm_name);