]>
git.ipfire.org Git - thirdparty/systemd.git/blob - src/shared/dm-util.c
2 #include <linux/dm-ioctl.h>
7 #include "string-util.h"
9 int dm_deferred_remove(const char *name
) {
11 struct dm_ioctl dm
= {
17 .data_size
= sizeof(dm
),
18 .flags
= DM_DEFERRED_REMOVE
,
21 _cleanup_close_
int fd
= -1;
25 /* Unfortunately, libcryptsetup doesn't provide a proper API for this, hence call the ioctl()
28 if (strlen(name
) >= sizeof(dm
.name
))
29 return -ENODEV
; /* A device with a name longer than this cannot possibly exist */
31 fd
= open("/dev/mapper/control", O_RDWR
|O_CLOEXEC
);
35 strncpy_exact(dm
.name
, name
, sizeof(dm
.name
));
37 if (ioctl(fd
, DM_DEV_REMOVE
, &dm
))