Whamcloud - gitweb
Make blkid -t display all devices that match the specified criteria,
authorTheodore Ts'o <tytso@mit.edu>
Sat, 22 Jan 2005 00:11:05 +0000 (19:11 -0500)
committerTheodore Ts'o <tytso@mit.edu>
Sat, 22 Jan 2005 00:11:05 +0000 (19:11 -0500)
not just the first one.  (Addresses Debian Bug #290530)

Update the blkid man page's description of the -t option.

misc/ChangeLog
misc/blkid.8.in
misc/blkid.c

index ac4d1a8..6ba4531 100644 (file)
@@ -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
index 14d9057..d4fd670 100644 (file)
@@ -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
index 1c5ac1b..60c7b37 100644 (file)
@@ -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;