1
0
mirror of git://sourceware.org/git/lvm2.git synced 2024-12-21 13:34:40 +03:00

device_mapper: pair with libdm _create_and_load_v4

Apply same enhancement also for internal device mapper library
from the commit: 25ef7a7b1a.
This commit is contained in:
Zdenek Kabelac 2023-10-13 13:18:13 +02:00
parent 0ff027ae2c
commit fb124f0839

View File

@ -1620,7 +1620,7 @@ static int _check_uevent_generated(struct dm_ioctl *dmi)
static int _create_and_load_v4(struct dm_task *dmt) static int _create_and_load_v4(struct dm_task *dmt)
{ {
struct dm_task *task; struct dm_task *task;
int r; int r, ioctl_errno = 0;
uint32_t cookie; uint32_t cookie;
/* Use new task struct to create the device */ /* 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->cookie_set = dmt->cookie_set;
task->add_node = dmt->add_node; task->add_node = dmt->add_node;
if (!dm_task_run(task)) if (!dm_task_run(task)) {
ioctl_errno = task->ioctl_errno;
goto_bad; goto_bad;
}
dm_task_destroy(task); dm_task_destroy(task);
@ -1673,6 +1675,8 @@ static int _create_and_load_v4(struct dm_task *dmt)
task->ima_measurement = dmt->ima_measurement; task->ima_measurement = dmt->ima_measurement;
r = dm_task_run(task); r = dm_task_run(task);
if (!r)
ioctl_errno = task->ioctl_errno;
task->head = NULL; task->head = NULL;
task->tail = NULL; task->tail = NULL;
@ -1719,12 +1723,18 @@ static int _create_and_load_v4(struct dm_task *dmt)
if (!dm_task_run(dmt)) if (!dm_task_run(dmt))
log_error("Failed to revert device creation."); log_error("Failed to revert device creation.");
if (ioctl_errno != 0)
dmt->ioctl_errno = ioctl_errno;
return 0; return 0;
bad: bad:
dm_task_destroy(task); dm_task_destroy(task);
_udev_complete(dmt); _udev_complete(dmt);
if (ioctl_errno != 0)
dmt->ioctl_errno = ioctl_errno;
return 0; return 0;
} }