From 73967233e49fb2c80665bef067b7874df4407724 Mon Sep 17 00:00:00 2001 From: Zdenek Kabelac Date: Mon, 6 Nov 2023 14:39:30 +0100 Subject: [PATCH] dev_manager: reuse _setup_task_run --- lib/activate/dev_manager.c | 19 +++---------------- 1 file changed, 3 insertions(+), 16 deletions(-) diff --git a/lib/activate/dev_manager.c b/lib/activate/dev_manager.c index 43ea6aa75..9b1dcd250 100644 --- a/lib/activate/dev_manager.c +++ b/lib/activate/dev_manager.c @@ -4103,7 +4103,7 @@ out: */ int get_crypt_table_offset(dev_t crypt_devt, uint32_t *offset_bytes) { - struct dm_task *dmt = dm_task_create(DM_DEVICE_TABLE); + struct dm_task *dmt; uint64_t start, length; char *target_type = NULL; void *next = NULL; @@ -4113,23 +4113,10 @@ int get_crypt_table_offset(dev_t crypt_devt, uint32_t *offset_bytes) int spaces = 0; unsigned i, i_off = 0; - if (!dmt) + if (!(dmt = _setup_task_run(DM_DEVICE_TABLE, NULL, NULL, NULL, NULL, + MAJOR(crypt_devt), MINOR(crypt_devt), 0, 0, 0))) return_0; - if (!dm_task_set_major_minor(dmt, (int)MAJOR(crypt_devt), (int)MINOR(crypt_devt), 0)) { - dm_task_destroy(dmt); - return_0; - } - - /* Non-blocking status read */ - if (!dm_task_no_flush(dmt)) - log_warn("WARNING: Can't set no_flush for dm status."); - - if (!dm_task_run(dmt)) { - dm_task_destroy(dmt); - return_0; - } - next = dm_get_next_target(dmt, next, &start, &length, &target_type, ¶ms); if (!target_type || !params || strcmp(target_type, "crypt")) {