From ffc88f2eebadd3cd38ed4fffeadedc68897acf3c Mon Sep 17 00:00:00 2001 From: Alasdair Kergon Date: Mon, 17 Oct 2005 18:05:39 +0000 Subject: [PATCH] dm_driver_version --- WHATS_NEW_DM | 1 + libdm/.exported_symbols | 1 + libdm/libdevmapper.h | 1 + libdm/libdm-common.c | 21 +++++++++++++++++++++ tools/dmsetup.c | 19 ++----------------- 5 files changed, 26 insertions(+), 17 deletions(-) diff --git a/WHATS_NEW_DM b/WHATS_NEW_DM index 99283d619..60cb014e6 100644 --- a/WHATS_NEW_DM +++ b/WHATS_NEW_DM @@ -1,5 +1,6 @@ Version 1.02.00 - ============================= + Add dm_driver_version(). Added dependency tree functions to library. Added hash, bitset, pool, dbg_malloc to library. Added ls --tree to dmsetup. diff --git a/libdm/.exported_symbols b/libdm/.exported_symbols index 85374dd46..cb7eb0b3c 100644 --- a/libdm/.exported_symbols +++ b/libdm/.exported_symbols @@ -81,3 +81,4 @@ dm_hash_get_key dm_hash_get_data dm_hash_get_first dm_hash_get_next +dm_driver_version diff --git a/libdm/libdevmapper.h b/libdm/libdevmapper.h index a1fa6eee7..4df4a0798 100644 --- a/libdm/libdevmapper.h +++ b/libdm/libdevmapper.h @@ -188,6 +188,7 @@ void dm_lib_exit(void) __attribute((destructor)); * Use NULL for all devices. */ int dm_mknodes(const char *name); +int dm_driver_version(char *version, size_t size); /***************************** * Dependency tree functions * diff --git a/libdm/libdm-common.c b/libdm/libdm-common.c index 4c11856b7..ed4392c80 100644 --- a/libdm/libdm-common.c +++ b/libdm/libdm-common.c @@ -469,3 +469,24 @@ out: dm_task_destroy(dmt); return r; } + +int dm_driver_version(char *version, size_t size) +{ + struct dm_task *dmt; + int r = 0; + + if (!(dmt = dm_task_create(DM_DEVICE_VERSION))) + return 0; + + if (!dm_task_run(dmt)) + log_error("Failed to get driver version"); + + if (!dm_task_get_driver_version(dmt, version, size)) + goto out; + + r = 1; + +out: + dm_task_destroy(dmt); + return r; +} diff --git a/tools/dmsetup.c b/tools/dmsetup.c index 4b2d7c01c..30b6c8b7c 100644 --- a/tools/dmsetup.c +++ b/tools/dmsetup.c @@ -497,32 +497,17 @@ static int _message(int argc, char **argv, void *data) static int _version(int argc, char **argv, void *data) { - int r = 0; - struct dm_task *dmt; char version[80]; if (dm_get_library_version(version, sizeof(version))) printf("Library version: %s\n", version); - if (!(dmt = dm_task_create(DM_DEVICE_VERSION))) + if (dm_driver_version(version, sizeof(version))) return 0; - if (!dm_task_run(dmt)) - goto out; - - if (!dm_task_get_driver_version(dmt, (char *) &version, - sizeof(version))) { - goto out; - } - printf("Driver version: %s\n", version); - r = 1; - - out: - dm_task_destroy(dmt); - - return r; + return 1; } static int _simple(int task, const char *name, uint32_t event_nr, int display) -- 2.43.5