]> sourceware.org Git - lvm2.git/commitdiff
o extra error checking
authorJoe Thornber <thornber@redhat.com>
Tue, 27 Nov 2001 20:03:45 +0000 (20:03 +0000)
committerJoe Thornber <thornber@redhat.com>
Tue, 27 Nov 2001 20:03:45 +0000 (20:03 +0000)
lib/format1/import-extents.c

index 0cb71f0899f90aa4da8eb4320ecb7fc00c992589..7bcd96341c218e9e0c58cda74208c0b7dcdb361e 100644 (file)
@@ -82,6 +82,7 @@ static int _fill_lv_array(struct lv_map **lvs,
        struct lv_map *lvm;
        int i = 0;
 
+       memset(lvs, 0, sizeof(*lvs) * MAX_LV);
        list_iterate(lvh, &dl->lvds) {
                struct lvd_list *ll = list_item(lvh, struct lvd_list);
 
@@ -95,7 +96,7 @@ static int _fill_lv_array(struct lv_map **lvs,
                lvm->stripes = ll->lvd.lv_stripes;
                lvm->stripe_size = ll->lvd.lv_stripesize;
 
-               lvs[i++] = lvm;
+               lvs[ll->lvd.lv_number] = lvm;
        }
 
        return 1;
@@ -128,13 +129,15 @@ static int _fill_maps(struct hash_table *maps, struct volume_group *vg,
                        if (lv_num == UNMAPPED_EXTENT)
                                continue;
 
-                       else if(lv_num > dl->pvd.lv_cur) {
-                               log_err("invalid lv in extent map");
-                               return 0;
-
                        } else {
                                lv_num--;
                                lvm = lvms[lv_num];
+
+                               if(!lvm) {
+                                       log_err("invalid lv in extent map");
+                                       return 0;
+                               }
+
                                le = e[i].le_num;
 
                                if (le >= lvm->lv->le_count) {
@@ -143,6 +146,12 @@ static int _fill_maps(struct hash_table *maps, struct volume_group *vg,
                                        return 0;
                                }
 
+                               if (lvm->map[le].pv) {
+                                       log_err("logical extent (%u) "
+                                               "already mapped.", le);
+                                       return 0;
+                               }
+
                                lvm->map[le].pv = pv;
                                lvm->map[le].pe = i;
                        }
@@ -205,7 +214,8 @@ static int _build_segments(struct pool *mem, struct lv_map *lvm)
 
        len = sizeof(*seg) * (stripes * sizeof(seg->area[0]));
 
-       for (le = 0; le < lvm->lv->le_count;) {
+       le = 0;
+       while (le < lvm->lv->le_count) {
                if (!(seg = pool_zalloc(mem, len))) {
                        stack;
                        return 0;
This page took 0.036859 seconds and 5 git commands to generate.