int fd;
char *dm_name;
char *volume;
+ bool keep;
struct crypt_device *device;
} DecryptedPartitionTarget;
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);