diff options
author | Zdenek Kabelac <zkabelac@redhat.com> | 2018-06-23 23:02:24 +0200 |
---|---|---|
committer | Zdenek Kabelac <zkabelac@redhat.com> | 2018-06-25 15:07:55 +0200 |
commit | 4194fc9bbdc9107120ba09c22e56612d854fdd41 (patch) | |
tree | 1a35163e9df842ca6ab1fa01debccd7f3df2f45a /device_mapper | |
parent | 739a213d2ee01cc95861c342fde73e87088de6bb (diff) | |
download | lvm2-4194fc9bbdc9107120ba09c22e56612d854fdd41.tar.gz |
device_mapper: add new _dm_task_create_device_status
Introduce new function _dm_task_create_device_status for grabbing
status of device for better code sharing.
Diffstat (limited to 'device_mapper')
-rw-r--r-- | device_mapper/libdm-deptree.c | 32 |
1 files changed, 23 insertions, 9 deletions
diff --git a/device_mapper/libdm-deptree.c b/device_mapper/libdm-deptree.c index 5327b2e04..bb552b679 100644 --- a/device_mapper/libdm-deptree.c +++ b/device_mapper/libdm-deptree.c @@ -1382,20 +1382,14 @@ out: return r; } -static int _thin_pool_get_status(struct dm_tree_node *dnode, - struct dm_status_thin_pool *s) +static struct dm_task *_dm_task_create_device_status(uint32_t major, uint32_t minor) { struct dm_task *dmt; - int r = 0; - uint64_t start, length; - char *type = NULL; - char *params = NULL; if (!(dmt = dm_task_create(DM_DEVICE_STATUS))) - return_0; + return_NULL; - if (!dm_task_set_major(dmt, dnode->info.major) || - !dm_task_set_minor(dmt, dnode->info.minor)) { + if (!dm_task_set_major(dmt, major) || !dm_task_set_minor(dmt, minor)) { log_error("Failed to set major minor."); goto out; } @@ -1406,6 +1400,26 @@ static int _thin_pool_get_status(struct dm_tree_node *dnode, if (!dm_task_run(dmt)) goto_out; + return dmt; +out: + dm_task_destroy(dmt); + + return NULL; +} + +static int _thin_pool_get_status(struct dm_tree_node *dnode, + struct dm_status_thin_pool *s) +{ + struct dm_task *dmt; + int r = 0; + uint64_t start, length; + char *type = NULL; + char *params = NULL; + + if (!(dmt = _dm_task_create_device_status(dnode->info.major, + dnode->info.minor))) + return_0; + dm_get_next_target(dmt, NULL, &start, &length, &type, ¶ms); if (!type || (strcmp(type, "thin-pool") != 0)) { |