From fb124f083985138ed82d8b1efbb0be704c605412 Mon Sep 17 00:00:00 2001 From: Zdenek Kabelac Date: Fri, 13 Oct 2023 13:18:13 +0200 Subject: [PATCH] device_mapper: pair with libdm _create_and_load_v4 Apply same enhancement also for internal device mapper library from the commit: 25ef7a7b1a876f491bd361369423d7309358f6c1. --- device_mapper/ioctl/libdm-iface.c | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/device_mapper/ioctl/libdm-iface.c b/device_mapper/ioctl/libdm-iface.c index 00e2eb9e9..a17a4e468 100644 --- a/device_mapper/ioctl/libdm-iface.c +++ b/device_mapper/ioctl/libdm-iface.c @@ -1620,7 +1620,7 @@ static int _check_uevent_generated(struct dm_ioctl *dmi) static int _create_and_load_v4(struct dm_task *dmt) { struct dm_task *task; - int r; + int r, ioctl_errno = 0; uint32_t cookie; /* Use new task struct to create the device */ @@ -1646,8 +1646,10 @@ static int _create_and_load_v4(struct dm_task *dmt) task->cookie_set = dmt->cookie_set; task->add_node = dmt->add_node; - if (!dm_task_run(task)) + if (!dm_task_run(task)) { + ioctl_errno = task->ioctl_errno; goto_bad; + } dm_task_destroy(task); @@ -1673,6 +1675,8 @@ static int _create_and_load_v4(struct dm_task *dmt) task->ima_measurement = dmt->ima_measurement; r = dm_task_run(task); + if (!r) + ioctl_errno = task->ioctl_errno; task->head = NULL; task->tail = NULL; @@ -1719,12 +1723,18 @@ static int _create_and_load_v4(struct dm_task *dmt) if (!dm_task_run(dmt)) log_error("Failed to revert device creation."); + if (ioctl_errno != 0) + dmt->ioctl_errno = ioctl_errno; + return 0; bad: dm_task_destroy(task); _udev_complete(dmt); + if (ioctl_errno != 0) + dmt->ioctl_errno = ioctl_errno; + return 0; }