]> git.ipfire.org Git - thirdparty/systemd.git/commitdiff
dm-util: use CRYPT_DEACTIVATE_DEFERRED instead of ioctl
authorLuca Boccassi <luca.boccassi@microsoft.com>
Tue, 14 Jul 2020 14:07:21 +0000 (15:07 +0100)
committerLuca Boccassi <luca.boccassi@microsoft.com>
Tue, 21 Jul 2020 22:26:41 +0000 (23:26 +0100)
src/home/homework-luks.c
src/shared/dissect-image.c
src/shared/dm-util.c
src/shared/dm-util.h

index 99cab0929e55e2dcace842a58504a7e986362743..ba47688b0f187f940913bcedb59622eae5ba7757 100644 (file)
@@ -1295,7 +1295,7 @@ int home_activate_luks(
 
         loop_device_relinquish(setup.loop);
 
-        r = dm_deferred_remove(setup.dm_name);
+        r = crypt_deactivate_by_name(NULL, setup.dm_name, CRYPT_DEACTIVATE_DEFERRED);
         if (r < 0)
                 log_warning_errno(r, "Failed to relinquish DM device, ignoring: %m");
 
index fdf4d481f6545805d93560244c110c507fc69fa3..3641412dd1f1cbc87d08163773fbf66e9f36b70c 100644 (file)
@@ -1437,7 +1437,7 @@ int decrypted_image_relinquish(DecryptedImage *d) {
                 if (p->relinquished)
                         continue;
 
-                r = dm_deferred_remove(p->name);
+                r = crypt_deactivate_by_name(NULL, p->name, CRYPT_DEACTIVATE_DEFERRED);
                 if (r < 0)
                         return log_debug_errno(r, "Failed to mark %s for auto-removal: %m", p->name);
 
index d817e5b0e5e2a14207cf54d15da907fd655f4881..9ffa42702730467ac882ed37c0eab6cb0da8ecfb 100644 (file)
@@ -5,37 +5,3 @@
 #include "dm-util.h"
 #include "fd-util.h"
 #include "string-util.h"
-
-int dm_deferred_remove(const char *name) {
-
-        struct dm_ioctl dm = {
-                .version = {
-                        DM_VERSION_MAJOR,
-                        DM_VERSION_MINOR,
-                        DM_VERSION_PATCHLEVEL
-                },
-                .data_size = sizeof(dm),
-                .flags = DM_DEFERRED_REMOVE,
-        };
-
-        _cleanup_close_ int fd = -1;
-
-        assert(name);
-
-        /* Unfortunately, libcryptsetup doesn't provide a proper API for this, hence call the ioctl()
-         * directly. */
-
-        if (strlen(name) >= sizeof(dm.name))
-                return -ENODEV; /* A device with a name longer than this cannot possibly exist */
-
-        fd = open("/dev/mapper/control", O_RDWR|O_CLOEXEC);
-        if (fd < 0)
-                return -errno;
-
-        strncpy_exact(dm.name, name, sizeof(dm.name));
-
-        if (ioctl(fd, DM_DEV_REMOVE, &dm))
-                return -errno;
-
-        return 0;
-}
index 6c78bfe75b7f745fa0bb2ec44ce20e076b4f07a6..3bae3d43cb8e5785fe0d19fbc0cb3cd2cad6c8d3 100644 (file)
@@ -1,4 +1,2 @@
 /* SPDX-License-Identifier: LGPL-2.1+ */
 #pragma once
-
-int dm_deferred_remove(const char *name);