Whamcloud - gitweb
blkid: Make sure a device returned by blkid_find_dev_with_tag exists
authorTheodore Ts'o <tytso@mit.edu>
Sun, 29 Jun 2008 01:02:01 +0000 (21:02 -0400)
committerTheodore Ts'o <tytso@mit.edu>
Sun, 29 Jun 2008 02:17:43 +0000 (22:17 -0400)
There could be stale entries in blkid file, so if the device does not
exist, skip it.

Addresses-Debian-Bug: #487758, #487783

Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
lib/blkid/tag.c

index 44dd86d..8a8ac99 100644 (file)
@@ -10,6 +10,7 @@
  * %End-Header%
  */
 
+#include <unistd.h>
 #include <stdlib.h>
 #include <string.h>
 #include <stdio.h>
@@ -355,7 +356,8 @@ try_again:
                                                   bit_names);
 
                        if (!strcmp(tmp->bit_val, value) &&
-                           tmp->bit_dev->bid_pri > pri) {
+                           (tmp->bit_dev->bid_pri > pri) &&
+                           !access(tmp->bit_dev->bid_name, F_OK)) {
                                dev = tmp->bit_dev;
                                pri = dev->bid_pri;
                        }
@@ -363,7 +365,7 @@ try_again:
        }
        if (dev && !(dev->bid_flags & BLKID_BID_FL_VERIFIED)) {
                dev = blkid_verify(cache, dev);
-               if (dev && (dev->bid_flags & BLKID_BID_FL_VERIFIED))
+               if (!dev || (dev && (dev->bid_flags & BLKID_BID_FL_VERIFIED)))
                        goto try_again;
        }