summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--misc/ChangeLog6
-rw-r--r--misc/blkid.8.in4
-rw-r--r--misc/blkid.c28
3 files changed, 33 insertions, 5 deletions
diff --git a/misc/ChangeLog b/misc/ChangeLog
index ac4d1a82..6ba45315 100644
--- a/misc/ChangeLog
+++ b/misc/ChangeLog
@@ -1,3 +1,9 @@
+2005-01-21 Theodore Ts'o <tytso@mit.edu>
+
+ * blkid.c (main): Make blkid -t display all devices that match the
+ specified criteria, not just the first one. (Addresses
+ Debian Bug #290530)
+
2005-01-20 <tytso@snap.thunk.org>
* filefrag.c (frag_report): Fix filefrag so that it works
diff --git a/misc/blkid.8.in b/misc/blkid.8.in
index 14d90579..d4fd670a 100644
--- a/misc/blkid.8.in
+++ b/misc/blkid.8.in
@@ -91,11 +91,11 @@ with no other options.
.TP
.B \-t
Search the blkid cache (plus any devices specifed on the command line)
-for all visible block devices with tokens named
+for all block devices with tokens named
.I NAME
that have the value
.IR value ,
-and print the name of any devices that are found.
+and display any devices which are found.
Common values for
.I NAME
include
diff --git a/misc/blkid.c b/misc/blkid.c
index 1c5ac1b0..60c7b377 100644
--- a/misc/blkid.c
+++ b/misc/blkid.c
@@ -174,17 +174,39 @@ int main(int argc, char **argv)
err = 2;
/* If looking for a specific NAME=value pair, print only that */
if (search_type) {
- blkid_dev dev;
+ blkid_dev_iterate dev_iter;
+ blkid_tag_iterate tag_iter;
+ blkid_dev dev;
+ int found;
+ const char *type, *value;
/* Load any additional devices not in the cache */
for (i = 0; i < numdev; i++)
blkid_get_dev(cache, devices[i], BLKID_DEV_NORMAL);
- if ((dev = blkid_find_dev_with_tag(cache, search_type,
- search_value))) {
+ /*
+ * XXX We need better interfaces in the blkid library
+ * so we don't need to open code as much stuff.
+ */
+ dev_iter = blkid_dev_iterate_begin(cache);
+ while (blkid_dev_next(dev_iter, &dev) == 0) {
+ found = 0;
+
+ tag_iter = blkid_tag_iterate_begin(dev);
+ while (blkid_tag_next(tag_iter, &type, &value) == 0) {
+ if (!strcmp(type, search_type) &&
+ !strcmp(value, search_value))
+ found++;
+ }
+ blkid_tag_iterate_end(tag_iter);
+ if (!found)
+ continue;
+
print_tags(dev, show, numtag, output_format);
err = 0;
}
+ blkid_dev_iterate_end(dev_iter);
+
/* If we didn't specify a single device, show all available devices */
} else if (!numdev) {
blkid_dev_iterate iter;