]> sourceware.org Git - lvm2.git/commitdiff
Compress any (obsolete) long LVM1 pvids encountered.
authorAlasdair Kergon <agk@redhat.com>
Tue, 4 May 2004 18:38:11 +0000 (18:38 +0000)
committerAlasdair Kergon <agk@redhat.com>
Tue, 4 May 2004 18:38:11 +0000 (18:38 +0000)
lib/format1/disk-rep.c
lib/format1/disk-rep.h
lib/format1/lvm1-label.c

index 422a175e41623c0c04e9763ed531f49dd840d8cb..aa0d964cc9d4656975a41341e61dd43ca30465e6 100644 (file)
@@ -117,6 +117,7 @@ static void _xlate_extents(struct pe_disk *extents, uint32_t count)
 static int _munge_formats(struct pv_disk *pvd)
 {
        uint32_t pe_start;
+       int b, e;
 
        switch (pvd->version) {
        case 1:
@@ -134,17 +135,50 @@ static int _munge_formats(struct pv_disk *pvd)
                return 0;
        }
 
+        /* UUID too long? */
+        if (pvd->pv_uuid[ID_LEN]) {
+               /* Retain ID_LEN chars from end */
+                for (e = ID_LEN; e < sizeof(pvd->pv_uuid); e++) {
+                        if (!pvd->pv_uuid[e]) {
+                                e--;
+                                break;
+                        }
+                }
+               for (b = 0; b < ID_LEN; b++) {
+                       pvd->pv_uuid[b] = pvd->pv_uuid[++e - ID_LEN];
+                       /* FIXME Remove all invalid chars */
+                       if (pvd->pv_uuid[b] == '/')
+                               pvd->pv_uuid[b] = '#';
+               }
+               memset(&pvd->pv_uuid[ID_LEN], 0, sizeof(pvd->pv_uuid) - ID_LEN);
+        }
+
        return 1;
 }
 
-static int _read_pvd(struct device *dev, struct pv_disk *pvd)
+/* 
+ * If exported, remove "PV_EXP" from end of VG name 
+ */
+static void _munge_exported_vg(struct pv_disk *pvd)
 {
-       if (!dev_read(dev, UINT64_C(0), sizeof(*pvd), pvd)) {
-               log_very_verbose("Failed to read PV data from %s",
-                                dev_name(dev));
-               return 0;
-       }
+       int l;
+       size_t s;
 
+       /* Return if PV not in a VG */
+       if ((!*pvd->vg_name))
+               return;
+       /* FIXME also check vgd->status & VG_EXPORTED? */
+
+       l = strlen(pvd->vg_name);
+       s = sizeof(EXPORTED_TAG);
+       if (!strncmp(pvd->vg_name + l - s + 1, EXPORTED_TAG, s)) {
+               pvd->vg_name[l - s + 1] = '\0';
+                pvd->pv_status |= VG_EXPORTED;
+        }
+}
+
+int munge_pvd(struct device *dev, struct pv_disk *pvd)
+{
        _xlate_pvd(pvd);
 
        if (pvd->id[0] != 'H' || pvd->id[1] != 'M') {
@@ -163,9 +197,23 @@ static int _read_pvd(struct device *dev, struct pv_disk *pvd)
        if (pvd->pv_uuid[0] == '\0')
                uuid_from_num(pvd->pv_uuid, pvd->pv_number);
 
+       /* If VG is exported, set VG name back to the real name */
+       _munge_exported_vg(pvd);
+
        return 1;
 }
 
+static int _read_pvd(struct device *dev, struct pv_disk *pvd)
+{
+       if (!dev_read(dev, UINT64_C(0), sizeof(*pvd), pvd)) {
+               log_very_verbose("Failed to read PV data from %s",
+                                dev_name(dev));
+               return 0;
+       }
+
+       return munge_pvd(dev, pvd);
+}
+
 static int _read_lvd(struct device *dev, uint64_t pos, struct lv_disk *disk)
 {
        if (!dev_read(dev, pos, sizeof(*disk), disk))
@@ -269,26 +317,6 @@ static int _read_extents(struct disk_list *data)
        return 1;
 }
 
-/* 
- * If exported, remove "PV_EXP" from end of VG name 
- */
-void munge_exported_vg(struct pv_disk *pvd)
-{
-       int l;
-       size_t s;
-
-       /* Return if PV not in a VG */
-       if ((!*pvd->vg_name))
-               return;
-
-       l = strlen(pvd->vg_name);
-       s = sizeof(EXPORTED_TAG);
-       if (!strncmp(pvd->vg_name + l - s + 1, EXPORTED_TAG, s)) {
-               pvd->vg_name[l - s + 1] = '\0'; 
-               pvd->pv_status |= VG_EXPORTED;
-       }
-}
-
 static struct disk_list *__read_disk(const struct format_type *fmt,
                                     struct device *dev, struct pool *mem,
                                     const char *vg_name)
@@ -312,9 +340,6 @@ static struct disk_list *__read_disk(const struct format_type *fmt,
                goto bad;
        }
 
-       /* If VG is exported, set VG name back to the real name */
-       munge_exported_vg(&dl->pvd);
-
        if (!(info = lvmcache_add(fmt->labeller, dl->pvd.pv_uuid, dev,
                                  dl->pvd.vg_name, NULL)))
                stack;
index cb084c8c752db2bc30a0ca0786fa074db7823876..b6b03229e99f8234e956830dda2ebe07138e42c4 100644 (file)
@@ -237,7 +237,7 @@ int export_uuids(struct disk_list *dl, struct volume_group *vg);
 void export_numbers(struct list *pvds, struct volume_group *vg);
 
 void export_pv_act(struct list *pvds);
-void munge_exported_vg(struct pv_disk *pvd);
+int munge_pvd(struct device *dev, struct pv_disk *pvd);
 
 /* blech */
 int get_free_vg_number(struct format_instance *fid, struct dev_filter *filter,
index 6e373bb15a6fdbc7f7c51ffd459580a438498a02..ceb73491a417b5e9e708c80d164551ea5ab15115 100644 (file)
@@ -60,7 +60,8 @@ static int _read(struct labeller *l, struct device *dev, char *buf,
        struct pv_disk *pvd = (struct pv_disk *) buf;
        struct lvmcache_info *info;
 
-       munge_exported_vg(pvd);
+       munge_pvd(dev, pvd);
+
        if (!(info = lvmcache_add(l, pvd->pv_uuid, dev, pvd->vg_name, NULL))) {
                stack;
                return 0;
This page took 0.047051 seconds and 5 git commands to generate.