summaryrefslogtreecommitdiff
path: root/lib/blkid/devname.c
diff options
context:
space:
mode:
authorTheodore Ts'o <tytso@mit.edu>2008-06-28 22:09:43 -0400
committerTheodore Ts'o <tytso@mit.edu>2008-06-28 22:17:54 -0400
commitbf58e3d1c68be63d673d232154bde5854e031afc (patch)
tree096cbb4290ccb9a14200368ceb2e25d880f18498 /lib/blkid/devname.c
parentb697f9d01c5f07842426f7d8e918bf3110028662 (diff)
downloade2fsprogs-bf58e3d1c68be63d673d232154bde5854e031afc.tar.gz
blkid: Eliminate stale entries that duplicate a verified device
Addresses-Debian-Bug: #487758, #487783 Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
Diffstat (limited to 'lib/blkid/devname.c')
-rw-r--r--lib/blkid/devname.c38
1 files changed, 36 insertions, 2 deletions
diff --git a/lib/blkid/devname.c b/lib/blkid/devname.c
index 29cde8e7..df968599 100644
--- a/lib/blkid/devname.c
+++ b/lib/blkid/devname.c
@@ -51,7 +51,7 @@
blkid_dev blkid_get_dev(blkid_cache cache, const char *devname, int flags)
{
blkid_dev dev = NULL, tmp;
- struct list_head *p;
+ struct list_head *p, *pnext;
if (!cache || !devname)
return NULL;
@@ -78,8 +78,42 @@ blkid_dev blkid_get_dev(blkid_cache cache, const char *devname, int flags)
cache->bic_flags |= BLKID_BIC_FL_CHANGED;
}
- if (flags & BLKID_DEV_VERIFY)
+ if (flags & BLKID_DEV_VERIFY) {
dev = blkid_verify(cache, dev);
+ if (!dev || !(dev->bid_flags & BLKID_BID_FL_VERIFIED))
+ return dev;
+ /*
+ * If the device is verified, then search the blkid
+ * cache for any entries that match on the type, uuid,
+ * and label, and verify them; if a cache entry can
+ * not be verified, then it's stale and so we remove
+ * it.
+ */
+ list_for_each_safe(p, pnext, &cache->bic_devs) {
+ blkid_dev dev2;
+ if (!p)
+ break;
+ dev2 = list_entry(p, struct blkid_struct_dev, bid_devs);
+ if (dev2->bid_flags & BLKID_BID_FL_VERIFIED)
+ continue;
+ if (strcmp(dev->bid_type, dev2->bid_type))
+ continue;
+ if (dev->bid_label && dev2->bid_label &&
+ strcmp(dev->bid_label, dev2->bid_label))
+ continue;
+ if (dev->bid_uuid && dev2->bid_uuid &&
+ strcmp(dev->bid_uuid, dev2->bid_uuid))
+ continue;
+ if ((dev->bid_label && !dev2->bid_label) ||
+ (!dev->bid_label && dev2->bid_label) ||
+ (dev->bid_uuid && !dev2->bid_uuid) ||
+ (!dev->bid_uuid && dev2->bid_uuid))
+ continue;
+ dev2 = blkid_verify(cache, dev2);
+ if (dev2 && !(dev2->bid_flags & BLKID_BID_FL_VERIFIED))
+ blkid_free_dev(dev2);
+ }
+ }
return dev;
}