~csurbhi/ubuntu/maverick/e2fsprogs/e2fsprogs.fix-505719

« back to all changes in this revision

Viewing changes to lib/blkid/devname.c

  • Committer: Bazaar Package Importer
  • Author(s): Steve Langasek
  • Date: 2008-08-08 20:32:11 UTC
  • mfrom: (1.1.11 upstream)
  • Revision ID: james.westby@ubuntu.com-20080808203211-w72lpsd9q7o3bw6x
Tags: 1.41.0-3ubuntu1
* Merge from Debian unstable (LP: #254152, #246461), remaining changes:
  - Do not build-depend on dietlibc-dev, which is in universe.

Show diffs side-by-side

added added

removed removed

Lines of Context:
51
51
blkid_dev blkid_get_dev(blkid_cache cache, const char *devname, int flags)
52
52
{
53
53
        blkid_dev dev = NULL, tmp;
54
 
        struct list_head *p;
 
54
        struct list_head *p, *pnext;
55
55
 
56
56
        if (!cache || !devname)
57
57
                return NULL;
78
78
                cache->bic_flags |= BLKID_BIC_FL_CHANGED;
79
79
        }
80
80
 
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))
 
84
                        return dev;
 
85
                /* 
 
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
 
90
                 * it.
 
91
                 */
 
92
                list_for_each_safe(p, pnext, &cache->bic_devs) {
 
93
                        blkid_dev dev2;
 
94
                        if (!p)
 
95
                                break;
 
96
                        dev2 = list_entry(p, struct blkid_struct_dev, bid_devs);
 
97
                        if (dev2->bid_flags & BLKID_BID_FL_VERIFIED)
 
98
                                continue;
 
99
                        if (!dev->bid_type || !dev2->bid_type ||
 
100
                            strcmp(dev->bid_type, dev2->bid_type))
 
101
                                continue;
 
102
                        if (dev->bid_label && dev2->bid_label &&
 
103
                            strcmp(dev->bid_label, dev2->bid_label))
 
104
                                continue;
 
105
                        if (dev->bid_uuid && dev2->bid_uuid &&
 
106
                            strcmp(dev->bid_uuid, dev2->bid_uuid))
 
107
                                continue;
 
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))
 
112
                                continue;
 
113
                        dev2 = blkid_verify(cache, dev2);
 
114
                        if (dev2 && !(dev2->bid_flags & BLKID_BID_FL_VERIFIED))
 
115
                                blkid_free_dev(dev2);
 
116
                }
 
117
        }
83
118
        return dev;
84
119
}
85
120