1 /* SPDX-License-Identifier: LGPL-2.1-or-later */
4 #include <linux/dm-ioctl.h>
9 #include "string-util.h"
11 int dm_deferred_remove_cancel(const char *name
) {
12 _cleanup_close_
int fd
= -1;
14 struct dm_ioctl dm_ioctl
;
15 struct dm_target_msg dm_target_msg
;
16 char msg_text
[STRLEN("@cancel_deferred_remove") + 1];
17 } _packed_ message
= {
24 .data_size
= sizeof(struct message
),
25 .data_start
= sizeof(struct dm_ioctl
),
27 .msg_text
= "@cancel_deferred_remove",
32 if (strlen(name
) >= sizeof(message
.dm_ioctl
.name
))
33 return -ENODEV
; /* A device with a name longer than this cannot possibly exist */
35 strncpy_exact(message
.dm_ioctl
.name
, name
, sizeof(message
.dm_ioctl
.name
));
37 fd
= open("/dev/mapper/control", O_RDWR
|O_CLOEXEC
);
41 if (ioctl(fd
, DM_TARGET_MSG
, &message
))