repart: Allow keeping luks2 volumes opened
This commit is contained in:
+9
-5
@@ -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);
|
||||
|
||||
Reference in New Issue
Block a user