1
0
mirror of git://sourceware.org/git/lvm2.git synced 2024-12-21 13:34:40 +03:00

Add --target to dmsetup ls.

This commit is contained in:
Alasdair Kergon 2005-05-16 16:04:34 +00:00
parent ebf21d3f93
commit 2272500bc8
3 changed files with 36 additions and 14 deletions

View File

@ -1,7 +1,7 @@
Version 1.01.02 -
=============================
Call dm_lib_exit() and dm_lib_release() automatically now.
Add --target <target_type> filter to dmsetup table/status.
Add --target <target_type> filter to dmsetup table/status/ls.
Fix dmsetup getopt_long usage.
Version 1.01.01 - 29 Mar 2005

View File

@ -29,7 +29,7 @@ dmsetup \- low level logical volume management
.B dmsetup rename
.I device_name new_name
.br
.B dmsetup ls
.B dmsetup ls [--target target_type]
.br
.B dmsetup info
.I [device_name]
@ -145,8 +145,10 @@ Outputs some brief information about the device in the form:
.br
UUID
.IP \fBls
.I [--target target_type]
.br
List device names.
List device names. Optionally only list devices that have at least
one target of the specified type.
.IP \fBload|reload
.I device_name [table_file]
.br

View File

@ -600,6 +600,14 @@ static int _process_all(int argc, char **argv,
return r;
}
static void _display_dev(struct dm_task *dmt, char *name)
{
struct dm_info info;
if (dm_task_get_info(dmt, &info))
printf("%s\t(%u, %u)\n", name, info.major, info.minor);
}
static int _status(int argc, char **argv, void *data)
{
int r = 0;
@ -612,6 +620,7 @@ static int _status(int argc, char **argv, void *data)
struct dm_names *names = (struct dm_names *) data;
char *name = NULL;
int matched = 0;
int ls_only = 0;
if (data)
name = names->name;
@ -627,6 +636,9 @@ static int _status(int argc, char **argv, void *data)
else
cmd = DM_DEVICE_STATUS;
if (!strcmp(argv[0], "ls"))
ls_only = 1;
if (!(dmt = dm_task_create(cmd)))
return 0;
@ -647,6 +659,10 @@ static int _status(int argc, char **argv, void *data)
if (_switches[TARGET_ARG] && target_type &&
strcmp(target_type, _target))
continue;
if (ls_only) {
_display_dev(dmt, name);
next = NULL;
} else {
if (!matched && _switches[VERBOSE_ARG])
_display_info(dmt);
if (data && !_switches[VERBOSE_ARG])
@ -656,10 +672,11 @@ static int _status(int argc, char **argv, void *data)
start, length, target_type, params);
}
printf("\n");
}
matched = 1;
} while (next);
if (data && _switches[VERBOSE_ARG] && matched)
if (data && _switches[VERBOSE_ARG] && matched && !ls_only)
printf("\n");
r = 1;
@ -842,6 +859,9 @@ static int _display_name(int argc, char **argv, void *data)
static int _ls(int argc, char **argv, void *data)
{
if (_switches[TARGET_ARG] && _target)
return _status(argc, argv, data);
else
return _process_all(argc, argv, _display_name);
}
@ -871,7 +891,7 @@ static struct command _commands[] = {
{"reload", "<device> [<table_file>]", 0, 2, _load},
{"rename", "<device> <new_name>", 1, 2, _rename},
{"message", "<device> <sector> <message>", 2, -1, _message},
{"ls", "", 0, 0, _ls},
{"ls", "[--target <target_type>]", 0, 0, _ls},
{"info", "[<device>]", 0, 1, _info},
{"deps", "[<device>]", 0, 1, _deps},
{"status", "[<device>] [--target <target_type>]", 0, 1, _status},