summaryrefslogtreecommitdiff
path: root/libdm/dm-tools
diff options
context:
space:
mode:
authorMikulas Patocka <mpatocka@redhat.com>2019-09-16 05:58:10 -0400
committerZdenek Kabelac <zkabelac@redhat.com>2019-10-04 17:31:55 +0200
commit667b33dd3be1068ffb92783e189cbc1b41c9ac28 (patch)
treeb5916e88c9137d74085514679d972c69795533f4 /libdm/dm-tools
parentebc9274be07299e1defd332685a2dff2c5b43cdf (diff)
downloadlvm2-667b33dd3be1068ffb92783e189cbc1b41c9ac28.tar.gz
dm: introduce DM_GET_TARGET_VERSION
Adds support for the DM_GET_TARGET_VERSION to dmsetup. It introduces a new comman "target-version" that will accept list of targets and print their version. Signed-off-by: Mikulas Patocka <mpatocka@redhat.com>
Diffstat (limited to 'libdm/dm-tools')
-rw-r--r--libdm/dm-tools/dmsetup.c28
1 files changed, 28 insertions, 0 deletions
diff --git a/libdm/dm-tools/dmsetup.c b/libdm/dm-tools/dmsetup.c
index 7267d0da9..7d60d2f1b 100644
--- a/libdm/dm-tools/dmsetup.c
+++ b/libdm/dm-tools/dmsetup.c
@@ -2589,6 +2589,33 @@ out:
return r;
}
+/* Show target names and their version numbers */
+static int _target_version(CMD_ARGS)
+{
+ int r = 0;
+ struct dm_task *dmt;
+ struct dm_versions *target;
+
+ if (!(dmt = dm_task_create(DM_GET_TARGET_VERSION)))
+ return_0;
+
+ if (!dm_task_set_name(dmt, argv[0]))
+ goto_out;
+
+ if (!_task_run(dmt))
+ goto_out;
+
+ target = dm_task_get_versions(dmt);
+ printf("%-16s v%d.%d.%d\n", target->name, target->version[0],
+ target->version[1], target->version[2]);
+
+ r = 1;
+
+out:
+ dm_task_destroy(dmt);
+ return r;
+}
+
static int _info(CMD_ARGS)
{
int r = 0;
@@ -6241,6 +6268,7 @@ static struct command _dmsetup_commands[] = {
{"udevcomplete", "<cookie>", 1, 1, 0, 0, _udevcomplete},
{"udevcomplete_all", "[<age_in_minutes>]", 0, 1, 0, 0, _udevcomplete_all},
{"udevcookies", "", 0, 0, 0, 0, _udevcookies},
+ {"target-version", "[<target>...]", 1, -1, 1, 0, _target_version},
{"targets", "", 0, 0, 0, 0, _targets},
{"version", "", 0, 0, 0, 0, _version},
{"setgeometry", "<device> <cyl> <head> <sect> <start>", 5, 5, 0, 0, _setgeometry},