/*
- * Copyright (C) 2001 Sistina Software (UK) Limited.
+ * Copyright (C) 2001-2003 Sistina Software (UK) Limited.
*
* This file is released under the GPL.
*/
}
+/* 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;
{"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}
};
{"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* */
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;
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;
/* *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* */