bug-parted
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[PATCH parted 2/5] dasd: Remove (bogus) part_info pointer from DasdParti


From: Hans de Goede
Subject: [PATCH parted 2/5] dasd: Remove (bogus) part_info pointer from DasdPartitionData
Date: Tue, 3 Nov 2009 13:08:57 +0100

The part_info pointer in DasdPartitionData was only used to
pass fdasd partition_info_t pointers from dasd_write to
the dasd_write dasd_update_type utility function. Since these
pointers are not valid outside the lifetime of dasd_write, they
should not be stored in the longer lived DasdPartitionData.

* libparted/labels/dasd.c(DasdPartitionData): Remove part_info member.
(dasd_read): Stop setting DasdPartitionData part_info.
(dasd_update_type): Add part_info argument to pass fdasd
partition_info_t pointers from dasd_write.
(dasd_write): Stop setting DasdPartitionData part_info, pass
partition_info_t pointers to dasd_update_type as a separate argument.
---
 libparted/labels/dasd.c |   24 ++++++++++--------------
 1 files changed, 10 insertions(+), 14 deletions(-)

diff --git a/libparted/labels/dasd.c b/libparted/labels/dasd.c
index 6c8de52..a7df859 100644
--- a/libparted/labels/dasd.c
+++ b/libparted/labels/dasd.c
@@ -66,7 +66,6 @@ typedef struct {
        int system;
        int     raid;
        int     lvm;
-       void *part_info;
 } DasdPartitionData;
 
 typedef struct {
@@ -410,7 +409,6 @@ dasd_read (PedDisk* disk)
 
                vtoc_ebcdic_enc(p->f1->DS1DSNAM, p->f1->DS1DSNAM, 44);
 
-               dasd_data->part_info = (void *) p;
                dasd_data->type = 0;
 
                constraint_exact = ped_constraint_exact (&part->geom);
@@ -464,8 +462,10 @@ error_close_dev:
 }
 
 static int
-dasd_update_type (const PedDisk* disk, struct fdasd_anchor *anchor)
+dasd_update_type (const PedDisk* disk, struct fdasd_anchor *anchor,
+                 partition_info_t *part_info[USABLE_PARTITIONS])
 {
+       int i;
        PedPartition* part;
        LinuxSpecific* arch_specific;
        DasdDiskSpecific* disk_specific;
@@ -475,22 +475,21 @@ dasd_update_type (const PedDisk* disk, struct 
fdasd_anchor *anchor)
 
        PDEBUG;
 
-       for (part = ped_disk_next_partition(disk, NULL); part;
-            part = ped_disk_next_partition(disk, part)) {
+       for (i = 1; i <= USABLE_PARTITIONS; i++) {
                partition_info_t *p;
                char *ch = NULL;
                DasdPartitionData* dasd_data;
 
                PDEBUG;
 
-               if (part->type & PED_PARTITION_FREESPACE
-                       || part->type & PED_PARTITION_METADATA)
+               part = ped_disk_get_partition(disk, i);
+               if (!part)
                        continue;
 
                PDEBUG;
 
                dasd_data = part->disk_specific;
-               p = dasd_data->part_info;
+               p = part_info[i - 1];
 
                if (!p ) {
                        PDEBUG;
@@ -549,6 +548,7 @@ dasd_write (const PedDisk* disk)
        LinuxSpecific* arch_specific;
        DasdDiskSpecific* disk_specific;
        struct fdasd_anchor anchor;
+       partition_info_t *part_info[USABLE_PARTITIONS];
 
        PED_ASSERT(disk != NULL, return 0);
        PED_ASSERT(disk->dev != NULL, return 0);
@@ -577,7 +577,6 @@ dasd_write (const PedDisk* disk)
 
        for (i = 1; i <= USABLE_PARTITIONS; i++) {
                unsigned int start, stop;
-               int type;
 
                PDEBUG;
                part = ped_disk_get_partition(disk, i);
@@ -595,15 +594,12 @@ dasd_write (const PedDisk* disk)
                PDEBUG;
                dasd_data = part->disk_specific;
 
-               type = dasd_data->type;
-               PDEBUG;
-
                p = fdasd_add_partition(&anchor, start, stop);
                if (!p) {
                        PDEBUG;
                        goto error;
                }
-               dasd_data->part_info = (void *) p;
+               part_info[i - 1] = p;
                p->type = dasd_data->system;
        }
 
@@ -612,7 +608,7 @@ dasd_write (const PedDisk* disk)
        if (!fdasd_prepare_labels(&anchor, arch_specific->fd))
                goto error;
 
-       dasd_update_type(disk, &anchor);
+       dasd_update_type(disk, &anchor, part_info);
        PDEBUG;
 
        if (!fdasd_write_labels(&anchor, arch_specific->fd))
-- 
1.6.5.1





reply via email to

[Prev in Thread] Current Thread [Next in Thread]