-/*
- * Add a device to the global cache list, along with all its tags.
- */
-blkid_dev blkid_add_dev_to_cache(blkid_cache cache, blkid_dev dev)
-{
- struct list_head *p;
-
- if (!cache || !dev)
- return dev;
-
- if (!dev->bid_id)
- dev->bid_id = ++(cache->bic_idmax);
-
- list_for_each(p, &cache->bic_devs) {
- blkid_dev odev = list_entry(p, struct blkid_struct_dev, bid_devs);
- int dup_uuid, dup_label, dup_name, dup_type;
-
- dup_name = string_compare(odev->bid_name, dev->bid_name);
- dup_label = string_compare(odev->bid_label, dev->bid_label);
- dup_uuid = string_compare(odev->bid_uuid, dev->bid_uuid);
-
- if (odev->bid_id == dev->bid_id)
- dev->bid_id = ++(cache->bic_idmax);
-
- /* Fields different, do nothing (check more fields?) */
- if ((dup_name & SC_DIFF) && (dup_uuid & SC_DIFF) &&
- (dup_label & SC_DIFF))
- continue;
-
- /* We can't simply allow duplicate fields if the bid_type is
- * different, given that a filesystem may change from ext2
- * to ext3 but it will have the same UUID and LABEL fields.
- * We need to discard the old cache entry in this case.
- */
-
- /* If the UUIDs are the same but one is unverified discard it */
- if (dup_uuid == SC_SAME) {
- DBG(printf(" duplicate uuid %s\n", dev->bid_uuid));
- if (!(odev->bid_flags & BLKID_BID_FL_VERIFIED)) {
- dev->bid_id = odev->bid_id; /* keep old id */
- blkid_free_dev(odev);
- goto exit_new;
- } else if (!(dev->bid_flags & BLKID_BID_FL_VERIFIED)) {
- blkid_free_dev(dev);
- dev = odev;
- goto exit_old;
- }
-
- /* This shouldn't happen */
- fprintf(stderr, "blkid: same UUID for %s and %s\n",
- dev->bid_name, odev->bid_name);
- }