51
51
blkid_dev blkid_get_dev(blkid_cache cache, const char *devname, int flags)
53
53
blkid_dev dev = NULL, tmp;
54
struct list_head *p, *pnext;
56
56
if (!cache || !devname)
78
78
cache->bic_flags |= BLKID_BIC_FL_CHANGED;
81
if (flags & BLKID_DEV_VERIFY)
81
if (flags & BLKID_DEV_VERIFY) {
82
82
dev = blkid_verify(cache, dev);
83
if (!dev || !(dev->bid_flags & BLKID_BID_FL_VERIFIED))
86
* If the device is verified, then search the blkid
87
* cache for any entries that match on the type, uuid,
88
* and label, and verify them; if a cache entry can
89
* not be verified, then it's stale and so we remove
92
list_for_each_safe(p, pnext, &cache->bic_devs) {
96
dev2 = list_entry(p, struct blkid_struct_dev, bid_devs);
97
if (dev2->bid_flags & BLKID_BID_FL_VERIFIED)
99
if (!dev->bid_type || !dev2->bid_type ||
100
strcmp(dev->bid_type, dev2->bid_type))
102
if (dev->bid_label && dev2->bid_label &&
103
strcmp(dev->bid_label, dev2->bid_label))
105
if (dev->bid_uuid && dev2->bid_uuid &&
106
strcmp(dev->bid_uuid, dev2->bid_uuid))
108
if ((dev->bid_label && !dev2->bid_label) ||
109
(!dev->bid_label && dev2->bid_label) ||
110
(dev->bid_uuid && !dev2->bid_uuid) ||
111
(!dev->bid_uuid && dev2->bid_uuid))
113
dev2 = blkid_verify(cache, dev2);
114
if (dev2 && !(dev2->bid_flags & BLKID_BID_FL_VERIFIED))
115
blkid_free_dev(dev2);