mirror of
git://sourceware.org/git/lvm2.git
synced 2024-12-21 13:34:40 +03:00
Userspace support for LIST_VERSIONS ioctl.
This commit is contained in:
parent
bd094b5d1d
commit
cf37d5c7ab
@ -12,6 +12,7 @@ Base {
|
|||||||
dm_task_get_deps;
|
dm_task_get_deps;
|
||||||
dm_task_get_name;
|
dm_task_get_name;
|
||||||
dm_task_get_names;
|
dm_task_get_names;
|
||||||
|
dm_task_get_versions;
|
||||||
dm_task_get_uuid;
|
dm_task_get_uuid;
|
||||||
dm_task_set_ro;
|
dm_task_set_ro;
|
||||||
dm_task_set_newname;
|
dm_task_set_newname;
|
||||||
|
@ -80,6 +80,7 @@ static struct cmd_data _cmd_data_v4[] = {
|
|||||||
{"names", DM_LIST_DEVICES, {4, 0, 0}},
|
{"names", DM_LIST_DEVICES, {4, 0, 0}},
|
||||||
{"clear", DM_TABLE_CLEAR, {4, 0, 0}},
|
{"clear", DM_TABLE_CLEAR, {4, 0, 0}},
|
||||||
{"mknodes", DM_DEV_STATUS, {4, 0, 0}},
|
{"mknodes", DM_DEV_STATUS, {4, 0, 0}},
|
||||||
|
{"versions", DM_LIST_VERSIONS, {4, 1, 0}},
|
||||||
};
|
};
|
||||||
/* *INDENT-ON* */
|
/* *INDENT-ON* */
|
||||||
|
|
||||||
@ -384,6 +385,10 @@ static int _dm_names_v1(struct dm_ioctl_v1 *dmi)
|
|||||||
struct stat buf;
|
struct stat buf;
|
||||||
char path[PATH_MAX];
|
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))) {
|
if (!(d = opendir(dev_dir))) {
|
||||||
log_error("%s: opendir failed: %s", dev_dir, strerror(errno));
|
log_error("%s: opendir failed: %s", dev_dir, strerror(errno));
|
||||||
return 0;
|
return 0;
|
||||||
@ -736,6 +741,12 @@ struct dm_names *dm_task_get_names(struct dm_task *dmt)
|
|||||||
dmt->dmi.v4->data_start);
|
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)
|
int dm_task_set_ro(struct dm_task *dmt)
|
||||||
{
|
{
|
||||||
dmt->read_only = 1;
|
dmt->read_only = 1;
|
||||||
|
@ -105,6 +105,7 @@ static struct cmd_data _cmd_data_v1[] = {
|
|||||||
{ "names", 0, {4, 0, 0} },
|
{ "names", 0, {4, 0, 0} },
|
||||||
{ "clear", 0, {4, 0, 0} },
|
{ "clear", 0, {4, 0, 0} },
|
||||||
{ "mknodes", 0, {4, 0, 0} },
|
{ "mknodes", 0, {4, 0, 0} },
|
||||||
|
{ "versions", 0, {4, 1, 0} },
|
||||||
};
|
};
|
||||||
/* *INDENT-ON* */
|
/* *INDENT-ON* */
|
||||||
|
|
||||||
|
@ -57,7 +57,9 @@ enum {
|
|||||||
|
|
||||||
DM_DEVICE_CLEAR,
|
DM_DEVICE_CLEAR,
|
||||||
|
|
||||||
DM_DEVICE_MKNODES
|
DM_DEVICE_MKNODES,
|
||||||
|
|
||||||
|
DM_DEVICE_LIST_VERSIONS
|
||||||
};
|
};
|
||||||
|
|
||||||
struct dm_task;
|
struct dm_task;
|
||||||
@ -97,6 +99,13 @@ struct dm_names {
|
|||||||
char name[0];
|
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_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_driver_version(struct dm_task *dmt, char *version, size_t size);
|
||||||
int dm_task_get_info(struct dm_task *dmt, struct dm_info *dmi);
|
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_deps *dm_task_get_deps(struct dm_task *dmt);
|
||||||
struct dm_names *dm_task_get_names(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_ro(struct dm_task *dmt);
|
||||||
int dm_task_set_newname(struct dm_task *dmt, const char *newname);
|
int dm_task_set_newname(struct dm_task *dmt, const char *newname);
|
||||||
|
@ -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.
|
* 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)
|
static int _info(int argc, char **argv, void *data)
|
||||||
{
|
{
|
||||||
int r = 0;
|
int r = 0;
|
||||||
@ -611,6 +645,7 @@ static struct command _commands[] = {
|
|||||||
{"status", "[<dev_name>]", 0, 1, _status},
|
{"status", "[<dev_name>]", 0, 1, _status},
|
||||||
{"table", "[<dev_name>]", 0, 1, _status},
|
{"table", "[<dev_name>]", 0, 1, _status},
|
||||||
{"wait", "<dev_name> [<event_nr>]", 1, 2, _wait},
|
{"wait", "<dev_name> [<event_nr>]", 1, 2, _wait},
|
||||||
|
{"targets", "", 0, 0, _targets},
|
||||||
{"version", "", 0, 0, _version},
|
{"version", "", 0, 0, _version},
|
||||||
{NULL, NULL, 0, 0, NULL}
|
{NULL, NULL, 0, 0, NULL}
|
||||||
};
|
};
|
||||||
|
Loading…
Reference in New Issue
Block a user