summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAlasdair Kergon <agk@redhat.com>2005-05-16 16:04:34 +0000
committerAlasdair Kergon <agk@redhat.com>2005-05-16 16:04:34 +0000
commit2272500bc8d919c32426cdfbbefc1d1af69a0688 (patch)
tree05b1af9fc6cdad69922d24dd7fa449471d51c570
parentebf21d3f938b702fb02358d7b80d63ce67daa641 (diff)
downloadlvm2-2272500bc8d919c32426cdfbbefc1d1af69a0688.tar.gz
lvm2-2272500bc8d919c32426cdfbbefc1d1af69a0688.tar.xz
lvm2-2272500bc8d919c32426cdfbbefc1d1af69a0688.zip
Add --target to dmsetup ls.
-rw-r--r--WHATS_NEW_DM2
-rw-r--r--man/dmsetup.8.in6
-rw-r--r--tools/dmsetup.c42
3 files changed, 36 insertions, 14 deletions
diff --git a/WHATS_NEW_DM b/WHATS_NEW_DM
index 6fa4bec9..a72f43d2 100644
--- a/WHATS_NEW_DM
+++ b/WHATS_NEW_DM
@@ -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
diff --git a/man/dmsetup.8.in b/man/dmsetup.8.in
index b98454f8..835494a9 100644
--- a/man/dmsetup.8.in
+++ b/man/dmsetup.8.in
@@ -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
diff --git a/tools/dmsetup.c b/tools/dmsetup.c
index 19a53f87..9eab6a47 100644
--- a/tools/dmsetup.c
+++ b/tools/dmsetup.c
@@ -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,19 +659,24 @@ static int _status(int argc, char **argv, void *data)
if (_switches[TARGET_ARG] && target_type &&
strcmp(target_type, _target))
continue;
- if (!matched && _switches[VERBOSE_ARG])
- _display_info(dmt);
- if (data && !_switches[VERBOSE_ARG])
- printf("%s: ", name);
- if (target_type) {
- printf("%" PRIu64 " %" PRIu64 " %s %s",
- start, length, target_type, params);
+ if (ls_only) {
+ _display_dev(dmt, name);
+ next = NULL;
+ } else {
+ if (!matched && _switches[VERBOSE_ARG])
+ _display_info(dmt);
+ if (data && !_switches[VERBOSE_ARG])
+ printf("%s: ", name);
+ if (target_type) {
+ printf("%" PRIu64 " %" PRIu64 " %s %s",
+ start, length, target_type, params);
+ }
+ printf("\n");
}
- 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,7 +859,10 @@ static int _display_name(int argc, char **argv, void *data)
static int _ls(int argc, char **argv, void *data)
{
- return _process_all(argc, argv, _display_name);
+ 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},