]> sourceware.org Git - lvm2.git/commitdiff
dm: introduce DM_GET_TARGET_VERSION
authorMikulas Patocka <mpatocka@redhat.com>
Mon, 16 Sep 2019 09:58:10 +0000 (05:58 -0400)
committerZdenek Kabelac <zkabelac@redhat.com>
Fri, 4 Oct 2019 15:31:55 +0000 (17:31 +0200)
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>
device_mapper/all.h
device_mapper/ioctl/libdm-iface.c
device_mapper/misc/dm-ioctl.h
libdm/dm-tools/dmsetup.c
libdm/ioctl/libdm-iface.c
libdm/libdevmapper.h
libdm/misc/dm-ioctl.h

index bdb69e1bb326efb908e63965ee10b34a1334bb2e..52b546f1f62a890ea9e7929b375b47c929428b0f 100644 (file)
@@ -121,7 +121,9 @@ enum {
 
        DM_DEVICE_SET_GEOMETRY,
 
-       DM_DEVICE_ARM_POLL
+       DM_DEVICE_ARM_POLL,
+
+       DM_GET_TARGET_VERSION
 };
 
 /*
index d33342661a53335426b4a8f2db18a6fd6a105a67..fe04af8bfc8821cea9988d173b6b181ed7ae8b1c 100644 (file)
@@ -119,6 +119,9 @@ static struct cmd_data _cmd_data_v4[] = {
 #ifdef DM_DEV_ARM_POLL
        {"armpoll",     DM_DEV_ARM_POLL,        {4, 36, 0}},
 #endif
+#ifdef DM_GET_TARGET_VERSION
+       {"target-version", DM_GET_TARGET_VERSION, {4, 41, 0}},
+#endif
 };
 /* *INDENT-ON* */
 
index 79f574cd9258467a66003cdcdf7de0259f8a157b..cc2374c366a4591f4e50bc799afd1456460523bf 100644 (file)
@@ -244,6 +244,7 @@ enum {
        DM_TARGET_MSG_CMD,
        DM_DEV_SET_GEOMETRY_CMD,
        DM_DEV_ARM_POLL_CMD,
+       DM_GET_TARGET_VERSION_CMD,
 };
 
 #define DM_IOCTL 0xfd
@@ -270,6 +271,8 @@ enum {
 #define DM_TARGET_MSG   _IOWR(DM_IOCTL, DM_TARGET_MSG_CMD, struct dm_ioctl)
 #define DM_DEV_SET_GEOMETRY    _IOWR(DM_IOCTL, DM_DEV_SET_GEOMETRY_CMD, struct dm_ioctl)
 
+#define DM_GET_TARGET_VERSION  _IOWR(DM_IOCTL, DM_GET_TARGET_VERSION_CMD, struct dm_ioctl)
+
 #define DM_VERSION_MAJOR       4
 #define DM_VERSION_MINOR       36
 #define DM_VERSION_PATCHLEVEL  0
index 7267d0da9077582d95187adfa8fd00973656e6eb..7d60d2f1bcacf19a7891f5dc44e33f5d7a2da1a5 100644 (file)
@@ -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},
index b195c115f1fde17f7bd29858f192d3c5b5497e6c..dd46b674a620970980262c4f89192e23a51fc302 100644 (file)
@@ -118,6 +118,9 @@ static struct cmd_data _cmd_data_v4[] = {
 #ifdef DM_DEV_ARM_POLL
        {"armpoll",     DM_DEV_ARM_POLL,        {4, 36, 0}},
 #endif
+#ifdef DM_GET_TARGET_VERSION
+       {"target-version", DM_GET_TARGET_VERSION, {4, 41, 0}},
+#endif
 };
 /* *INDENT-ON* */
 
index e885f52ae68310052cab02a157522ced3bcb42f2..81c67dcf217daf89fdd55895345e3afe94658153 100644 (file)
@@ -121,7 +121,9 @@ enum {
 
        DM_DEVICE_SET_GEOMETRY,
 
-       DM_DEVICE_ARM_POLL
+       DM_DEVICE_ARM_POLL,
+
+       DM_GET_TARGET_VERSION
 };
 
 /*
index 79f574cd9258467a66003cdcdf7de0259f8a157b..52a7a93d1b2360d38a650c4c70a14ee686d5d86a 100644 (file)
@@ -244,6 +244,7 @@ enum {
        DM_TARGET_MSG_CMD,
        DM_DEV_SET_GEOMETRY_CMD,
        DM_DEV_ARM_POLL_CMD,
+       DM_GET_TARGET_VERSION_CMD,
 };
 
 #define DM_IOCTL 0xfd
@@ -269,6 +270,7 @@ enum {
 
 #define DM_TARGET_MSG   _IOWR(DM_IOCTL, DM_TARGET_MSG_CMD, struct dm_ioctl)
 #define DM_DEV_SET_GEOMETRY    _IOWR(DM_IOCTL, DM_DEV_SET_GEOMETRY_CMD, struct dm_ioctl)
+#define DM_GET_TARGET_VERSION  _IOWR(DM_IOCTL, DM_GET_TARGET_VERSION_CMD, struct dm_ioctl)
 
 #define DM_VERSION_MAJOR       4
 #define DM_VERSION_MINOR       36
This page took 0.047978 seconds and 5 git commands to generate.