]> sourceware.org Git - dm.git/commitdiff
Userspace support for LIST_VERSIONS ioctl.
authorAlasdair Kergon <agk@redhat.com>
Fri, 23 Jan 2004 14:37:45 +0000 (14:37 +0000)
committerAlasdair Kergon <agk@redhat.com>
Fri, 23 Jan 2004 14:37:45 +0000 (14:37 +0000)
VERSION
dmsetup/dmsetup.c
kernel/ioctl/dm-ioctl.h
lib/.export.sym
lib/ioctl/libdevmapper.c
lib/ioctl/libdm-compat.h
lib/libdevmapper.h

diff --git a/VERSION b/VERSION
index 812bd23837e45d8f2adc7329e30a0e448777c8e3..01d78c29ee95785621d6663c226a77572695d5e8 100644 (file)
--- a/VERSION
+++ b/VERSION
@@ -1 +1 @@
-1.00.07-cvs (2003-11-21)
+1.00.07-cvs (2004-01-23)
index b8ed05d394ae91f8074b131a4c4f1fa8986583c7..a51dac319646d43a6c9145a72dd5c312079a4246 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * Copyright (C) 2001 Sistina Software (UK) Limited.
+ * Copyright (C) 2001-2003 Sistina Software (UK) Limited.
  *
  * This file is released under the GPL.
  */
@@ -462,6 +462,40 @@ static int _status(int argc, char **argv, void *data)
 
 }
 
+/* Show target names and their version numbers */
+static int _targets(int argc, char **argv, void *data)
+{
+       int r = 0;
+       struct dm_task *dmt;
+       struct dm_versions *target;
+       struct dm_versions *last_target;
+
+       if (!(dmt = dm_task_create(DM_DEVICE_LIST_VERSIONS)))
+               return 0;
+
+       if (!dm_task_run(dmt))
+               goto out;
+
+       target = dm_task_get_versions(dmt);
+
+       /* Fetch targets and print 'em */
+       do {
+               last_target = target;
+
+               printf("%-16s v%d.%d.%d\n", target->name, target->version[0],
+                      target->version[1], target->version[2]);
+
+               target = (void *) target + target->next;
+       } while (last_target != target);
+
+       r = 1;
+
+      out:
+       dm_task_destroy(dmt);
+       return r;
+
+}
+
 static int _info(int argc, char **argv, void *data)
 {
        int r = 0;
@@ -611,6 +645,7 @@ static struct command _commands[] = {
        {"status", "[<dev_name>]", 0, 1, _status},
        {"table", "[<dev_name>]", 0, 1, _status},
        {"wait", "<dev_name> [<event_nr>]", 1, 2, _wait},
+       {"targets", "", 0, 0, _targets},
        {"version", "", 0, 0, _version},
        {NULL, NULL, 0, 0, NULL}
 };
index 7487d36ae5d770a5a4981eef98a786666aae1501..0dc85fc472b3ad6af4c42bea145f58a49c829be3 100644 (file)
@@ -185,6 +185,8 @@ enum {
        DM_TABLE_CLEAR_CMD,
        DM_TABLE_DEPS_CMD,
        DM_TABLE_STATUS_CMD,
+
+       DM_LIST_VERSIONS_CMD,
 };
 
 #define DM_IOCTL 0xfd
@@ -192,6 +194,7 @@ enum {
 #define DM_VERSION       _IOWR(DM_IOCTL, DM_VERSION_CMD, struct dm_ioctl)
 #define DM_REMOVE_ALL    _IOWR(DM_IOCTL, DM_REMOVE_ALL_CMD, struct dm_ioctl)
 #define DM_LIST_DEVICES  _IOWR(DM_IOCTL, DM_LIST_DEVICES_CMD, struct dm_ioctl)
+#define DM_LIST_VERSIONS _IOWR(DM_IOCTL, DM_LIST_VERSIONS_CMD, struct dm_ioctl)
 
 #define DM_DEV_CREATE    _IOWR(DM_IOCTL, DM_DEV_CREATE_CMD, struct dm_ioctl)
 #define DM_DEV_REMOVE    _IOWR(DM_IOCTL, DM_DEV_REMOVE_CMD, struct dm_ioctl)
index 0399e6e2e44fe30364f8e37a611c4ebc1c81778c..1c5b956e32c7795a2d2210a3d7796cdafc54b4a4 100644 (file)
@@ -12,6 +12,7 @@ Base {
                dm_task_get_deps;
                dm_task_get_name;
                dm_task_get_names;
+               dm_task_get_versions;
                dm_task_get_uuid;
                dm_task_set_ro;
                dm_task_set_newname;
index ac7ba0c86a280299d4b8d0f3039081f8bd3d576a..10bcba60a228d5a71017d7c8e76a4f3c239a0746 100644 (file)
@@ -80,6 +80,7 @@ static struct cmd_data _cmd_data_v4[] = {
        {"names",       DM_LIST_DEVICES,        {4, 0, 0}},
        {"clear",       DM_TABLE_CLEAR,         {4, 0, 0}},
        {"mknodes",     DM_DEV_STATUS,          {4, 0, 0}},
+       {"versions",    DM_LIST_VERSIONS,       {4, 1, 0}},
 };
 /* *INDENT-ON* */
 
@@ -384,6 +385,10 @@ static int _dm_names_v1(struct dm_ioctl_v1 *dmi)
        struct stat buf;
        char path[PATH_MAX];
 
+       log_print("Warning: Device list may be incomplete with interface "
+                 "version 1.");
+       log_print("Please upgrade your kernel device-mapper driver.");
+
        if (!(d = opendir(dev_dir))) {
                log_error("%s: opendir failed: %s", dev_dir, strerror(errno));
                return 0;
@@ -736,6 +741,12 @@ struct dm_names *dm_task_get_names(struct dm_task *dmt)
                                    dmt->dmi.v4->data_start);
 }
 
+struct dm_versions *dm_task_get_versions(struct dm_task *dmt)
+{
+       return (struct dm_versions *) (((void *) dmt->dmi.v4) +
+                                      dmt->dmi.v4->data_start);
+}
+
 int dm_task_set_ro(struct dm_task *dmt)
 {
        dmt->read_only = 1;
index af7a9f1f719b0ad450ac250bc9d4247d1d15567a..bf16bb8166e8516b704fcf816010785d9f6b7c81 100644 (file)
@@ -89,22 +89,23 @@ enum {
 
 /* *INDENT-OFF* */
 static struct cmd_data _cmd_data_v1[] = {
-        { "create",    DM_DEV_CREATE_V1,       {1, 0, 0} },
-        { "reload",    DM_DEV_RELOAD_V1,       {1, 0, 0} },
-        { "remove",    DM_DEV_REMOVE_V1,       {1, 0, 0} },
-        { "remove_all",        DM_REMOVE_ALL_V1,       {1, 0, 0} },
-        { "suspend",   DM_DEV_SUSPEND_V1,      {1, 0, 0} },
-        { "resume",    DM_DEV_SUSPEND_V1,      {1, 0, 0} },
-        { "info",      DM_DEV_STATUS_V1,       {1, 0, 0} },
-        { "deps",      DM_DEV_DEPS_V1,         {1, 0, 0} },
-        { "rename",    DM_DEV_RENAME_V1,       {1, 0, 0} },
-        { "version",   DM_VERSION_V1,          {1, 0, 0} },
-        { "status",    DM_TARGET_STATUS_V1,    {1, 0, 0} },
-        { "table",     DM_TARGET_STATUS_V1,    {1, 0, 0} },
-        { "waitevent", DM_TARGET_WAIT_V1,      {1, 0, 0} },
-        { "names",     0,                      {4, 0, 0} },
-        { "clear",     0,                      {4, 0, 0} },
-        { "mknodes",   0,                      {4, 0, 0} },
+       { "create",     DM_DEV_CREATE_V1,       {1, 0, 0} },
+       { "reload",     DM_DEV_RELOAD_V1,       {1, 0, 0} },
+       { "remove",     DM_DEV_REMOVE_V1,       {1, 0, 0} },
+       { "remove_all", DM_REMOVE_ALL_V1,       {1, 0, 0} },
+       { "suspend",    DM_DEV_SUSPEND_V1,      {1, 0, 0} },
+       { "resume",     DM_DEV_SUSPEND_V1,      {1, 0, 0} },
+       { "info",       DM_DEV_STATUS_V1,       {1, 0, 0} },
+       { "deps",       DM_DEV_DEPS_V1,         {1, 0, 0} },
+       { "rename",     DM_DEV_RENAME_V1,       {1, 0, 0} },
+       { "version",    DM_VERSION_V1,          {1, 0, 0} },
+       { "status",     DM_TARGET_STATUS_V1,    {1, 0, 0} },
+       { "table",      DM_TARGET_STATUS_V1,    {1, 0, 0} },
+       { "waitevent",  DM_TARGET_WAIT_V1,      {1, 0, 0} },
+       { "names",      0,                      {4, 0, 0} },
+       { "clear",      0,                      {4, 0, 0} },
+       { "mknodes",    0,                      {4, 0, 0} },
+       { "versions",   0,                      {4, 1, 0} },
 };
 /* *INDENT-ON* */
 
index 42ef16a5c715bdef48c644a969598e0bda055de4..87038c35a412a6a6f90e3eca5fe12251ba8964a2 100644 (file)
@@ -57,7 +57,9 @@ enum {
 
        DM_DEVICE_CLEAR,
 
-       DM_DEVICE_MKNODES
+       DM_DEVICE_MKNODES,
+
+       DM_DEVICE_LIST_VERSIONS
 };
 
 struct dm_task;
@@ -97,6 +99,13 @@ struct dm_names {
        char name[0];
 };
 
+struct dm_versions {
+        uint32_t next;         /* Offset to next struct from start of this struct */
+        uint32_t version[3];
+
+        char name[0];
+};
+
 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);
@@ -105,6 +114,7 @@ const char *dm_task_get_uuid(struct dm_task *dmt);
 
 struct dm_deps *dm_task_get_deps(struct dm_task *dmt);
 struct dm_names *dm_task_get_names(struct dm_task *dmt);
+struct dm_versions *dm_task_get_versions(struct dm_task *dmt);
 
 int dm_task_set_ro(struct dm_task *dmt);
 int dm_task_set_newname(struct dm_task *dmt, const char *newname);
This page took 0.036105 seconds and 5 git commands to generate.