From 444b7d2360327bb746ecbf63d4b289a37f8407e8 Mon Sep 17 00:00:00 2001 From: Alasdair Kergon Date: Thu, 17 Jan 2002 14:13:25 +0000 Subject: [PATCH] Add function that returns the library version. --- libdm/libdevmapper.h | 1 + libdm/libdm-common.c | 6 ++++++ libdm/{libdm-common.h => libdm-common.h.in} | 2 ++ tools/dmsetup.c | 3 +++ 4 files changed, 12 insertions(+) rename libdm/{libdm-common.h => libdm-common.h.in} (91%) diff --git a/libdm/libdevmapper.h b/libdm/libdevmapper.h index 1e5076c5b..53789feeb 100644 --- a/libdm/libdevmapper.h +++ b/libdm/libdevmapper.h @@ -66,6 +66,7 @@ struct dm_info { unsigned int target_count; }; +int dm_get_library_version(char *version, size_t size); int dm_task_get_driver_version(struct dm_task *dmt, char *version, size_t size); int dm_task_get_info(struct dm_task *dmt, struct dm_info *dmi); diff --git a/libdm/libdm-common.c b/libdm/libdm-common.c index 708a459e1..040edacdf 100644 --- a/libdm/libdm-common.c +++ b/libdm/libdm-common.c @@ -58,6 +58,12 @@ void _build_dev_path(char *buffer, size_t len, const char *dev_name) snprintf(buffer, len, "%s/%s", _dm_dir, dev_name); } +int dm_get_library_version(char *version, size_t size) +{ + strncpy(version, DM_LIB_VERSION, size); + return 1; +} + struct dm_task *dm_task_create(int type) { struct dm_task *dmt = malloc(sizeof(*dmt)); diff --git a/libdm/libdm-common.h b/libdm/libdm-common.h.in similarity index 91% rename from libdm/libdm-common.h rename to libdm/libdm-common.h.in index 0261557ab..1bdc3ca26 100644 --- a/libdm/libdm-common.h +++ b/libdm/libdm-common.h.in @@ -14,3 +14,5 @@ extern struct target *create_target(uint64_t start, int add_dev_node(const char *dev_name, dev_t dev); int rm_dev_node(const char *dev_name); +#define DM_LIB_VERSION @DM_LIB_VERSION@ + diff --git a/tools/dmsetup.c b/tools/dmsetup.c index 48bd5d5c9..87834ac23 100644 --- a/tools/dmsetup.c +++ b/tools/dmsetup.c @@ -162,6 +162,9 @@ static int _version(int argc, char **argv) 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))) return 0;