[Parted-commits] GNU Parted Official Repository: Changes to 'next'

Jim Meyering meyering at alioth.debian.org
Thu Nov 5 10:18:03 UTC 2009


 libparted/arch/linux.c  |    7 ++
 libparted/arch/linux.h  |    6 -
 libparted/labels/dasd.c |  154 ++++++++++++++++++++++++++----------------------
 3 files changed, 91 insertions(+), 76 deletions(-)

New commits:
commit d031409df013669ac70969cc50603ca0dc81e3c0
Author: Hans de Goede <hdegoede at redhat.com>
Date:   Tue Nov 3 13:09:00 2009 +0100

    dasd: fix disk duplication
    
    Fix dasd_duplicate and add a dasd_partition_duplicate function.
    * libparted/labels/dasd.c(dasd_partition_duplicate): New function.
    (dasd_duplicate): Don't set the disk_specific pointer to NULL!
    (dasd_duplicate): Copy DasdDiskSpecific from old disk to new disk.

diff --git a/libparted/labels/dasd.c b/libparted/labels/dasd.c
index c9194c4..eda2709 100644
--- a/libparted/labels/dasd.c
+++ b/libparted/labels/dasd.c
@@ -82,6 +82,7 @@ static PedPartition* dasd_partition_new (const PedDisk* disk,
 										 const PedFileSystemType* fs_type,
 										 PedSector start,
 										 PedSector end);
+static PedPartition* dasd_partition_duplicate (const PedPartition *part);
 static void dasd_partition_destroy (PedPartition* part);
 static int dasd_partition_set_flag (PedPartition* part,
 									PedPartitionFlag flag,
@@ -116,6 +117,7 @@ static PedDiskOps dasd_disk_ops = {
 	partition_set_system: dasd_partition_set_system,
 
 	partition_new: dasd_partition_new,
+	partition_duplicate: dasd_partition_duplicate,
 	partition_destroy: dasd_partition_destroy,
 	partition_set_flag:	dasd_partition_set_flag,
 	partition_get_flag:	dasd_partition_get_flag,
@@ -129,8 +131,6 @@ static PedDiskOps dasd_disk_ops = {
 	get_max_primary_partition_count: dasd_get_max_primary_partition_count,
 	get_max_supported_partition_count: dasd_get_max_supported_partition_count,
 	get_partition_alignment: dasd_get_partition_alignment,
-
-	partition_duplicate: NULL
 };
 
 static PedDiskType dasd_disk_type = {
@@ -176,7 +176,8 @@ dasd_duplicate (const PedDisk* disk)
 	if (!new_disk)
 		return NULL;
 
-	new_disk->disk_specific = NULL;
+	memcpy(new_disk->disk_specific, disk->disk_specific,
+	       sizeof(DasdDiskSpecific));
 
 	return new_disk;
 }
@@ -631,6 +632,23 @@ error:
 	return 0;
 }
 
+static PedPartition*
+dasd_partition_duplicate (const PedPartition *part)
+{
+	PedPartition *new_part;
+
+	new_part = ped_partition_new (part->disk, part->type, part->fs_type,
+				      part->geom.start, part->geom.end);
+	if (!new_part)
+		return NULL;
+	new_part->num = part->num;
+
+	memcpy(new_part->disk_specific, part->disk_specific,
+	       sizeof(DasdPartitionData));
+
+	return new_part;
+}
+
 static void
 dasd_partition_destroy (PedPartition* part)
 {

commit 8e0f8c4216c44ac5b11bc5303a9032e40d0b38c8
Author: Hans de Goede <hdegoede at redhat.com>
Date:   Tue Nov 3 13:08:59 2009 +0100

    dasd: set disk_specific->format_type in dasd_alloc
    
    Set disk_specific->format_type in dasd_alloc, so that the disk
    returned by ped_disk_new_fresh is a valid dasd disk.
    * libparted/labels/dasd.c (dasd_alloc): Set disk_specific->format_type.

diff --git a/libparted/labels/dasd.c b/libparted/labels/dasd.c
index 22c47ee..c9194c4 100644
--- a/libparted/labels/dasd.c
+++ b/libparted/labels/dasd.c
@@ -160,6 +160,9 @@ dasd_alloc (const PedDevice* dev)
 		return NULL;
 	}
 
+	/* CDL format, newer */
+	disk_specific->format_type = 2;
+
 	return disk;
 }
 

commit 0d5c7bc90cb41ae7798a83b3efe4119ca4886f61
Author: Hans de Goede <hdegoede at redhat.com>
Date:   Tue Nov 3 13:08:58 2009 +0100

    dasd: cache real_sector_size in linux_probe
    
    dasd_alloc was doing an ioctl to get the real sector size for the dasd
    device (we are faking 512 bytes sectors), but when called directly
    from ped_disk_new_fresh(), the device is not open causing this to fail.
    
    This patch fixes things by caching the real_sector_size in the linux
    arch_specific data and making the dasd label handling use this.
    libparted/arch/linux.c(_device_set_sector_size): Cache real sector size.
    (_device_set_sector_size, init_dasd, linux_new): Only compile dasd code
    on s390 and s390x.

diff --git a/libparted/arch/linux.c b/libparted/arch/linux.c
index 271bc8b..52d8fa8 100644
--- a/libparted/arch/linux.c
+++ b/libparted/arch/linux.c
@@ -652,10 +652,13 @@ _device_set_sector_size (PedDevice* dev)
         }
 #endif
 
+#if defined __s390__ || defined __s390x__
         /* Return PED_SECTOR_SIZE_DEFAULT for DASDs. */
         if (dev->type == PED_DEVICE_DASD) {
+                arch_specific->real_sector_size = dev->sector_size;
                 dev->sector_size = PED_SECTOR_SIZE_DEFAULT;
         }
+#endif
 
         if (dev->sector_size != PED_SECTOR_SIZE_DEFAULT) {
                 ped_exception_throw (
@@ -1079,6 +1082,7 @@ error:
         return 0;
 }
 
+#if defined __s390__ || defined __s390x__
 static int
 init_dasd (PedDevice* dev, const char* model_name)
 {
@@ -1134,6 +1138,7 @@ error_close_dev:
 error:
         return 0;
 }
+#endif
 
 static int
 init_generic (PedDevice* dev, const char* model_name)
@@ -1280,10 +1285,12 @@ linux_new (const char* path)
                         goto error_free_arch_specific;
                 break;
 
+#if defined __s390__ || defined __s390x__
         case PED_DEVICE_DASD:
                 if (!init_dasd (dev, _("IBM S390 DASD drive")))
                         goto error_free_arch_specific;
                 break;
+#endif
 
         case PED_DEVICE_VIODASD:
                 if (!init_generic (dev, _("IBM iSeries Virtual DASD")))
diff --git a/libparted/labels/dasd.c b/libparted/labels/dasd.c
index dc8af4f..22c47ee 100644
--- a/libparted/labels/dasd.c
+++ b/libparted/labels/dasd.c
@@ -69,7 +69,6 @@ typedef struct {
 } DasdPartitionData;
 
 typedef struct {
-	unsigned int real_sector_size;
 	unsigned int format_type;
 } DasdDiskSpecific;
 
@@ -161,18 +160,6 @@ dasd_alloc (const PedDevice* dev)
 		return NULL;
 	}
 
-	/* because we lie to parted we have to compensate with the
-	   real sector size.  Record that now. */
-	if (ioctl(arch_specific->fd, BLKSSZGET,
-			  &disk_specific->real_sector_size) == -1) {
-		ped_exception_throw(PED_EXCEPTION_ERROR, PED_EXCEPTION_CANCEL,
-							_("Unable to determine the block "
-							  "size of this dasd"));
-		free(disk_specific);
-		free(disk);
-		return NULL;
-	}
-
 	return disk;
 }
 
@@ -320,7 +307,7 @@ dasd_read (PedDisk* disk)
 		end = (long long)(long long) anchor.geo.cylinders
 		      * (long long)anchor.geo.heads
 		      * (long long)disk->dev->hw_geom.sectors
-		      * (long long)disk_specific->real_sector_size
+		      * (long long)arch_specific->real_sector_size
 		      / (long long)disk->dev->sector_size - 1;
 		part = ped_partition_new (disk, PED_PARTITION_PROTECTED, NULL, start, end);
 		if (!part)
@@ -359,11 +346,11 @@ dasd_read (PedDisk* disk)
 
 		start = (long long)(long long) p->start_trk
 				* (long long) disk->dev->hw_geom.sectors
-				* (long long) disk_specific->real_sector_size
+				* (long long) arch_specific->real_sector_size
 				/ (long long) disk->dev->sector_size;
 		end   = (long long)((long long) p->end_trk + 1)
 				* (long long) disk->dev->hw_geom.sectors
-				* (long long) disk_specific->real_sector_size
+				* (long long) arch_specific->real_sector_size
 				/ (long long) disk->dev->sector_size - 1;
 		part = ped_partition_new(disk, PED_PARTITION_NORMAL, NULL,
                                          start, end);
@@ -423,11 +410,11 @@ dasd_read (PedDisk* disk)
 		if (p->fspace_trk > 0) {
 			start = (long long)((long long) p->end_trk + 1)
 					* (long long) disk->dev->hw_geom.sectors
-					* (long long) disk_specific->real_sector_size
+					* (long long) arch_specific->real_sector_size
 					/ (long long) disk->dev->sector_size;
 			end   = (long long)((long long) p->end_trk + 1 + p->fspace_trk)
 					* (long long) disk->dev->hw_geom.sectors
-					* (long long) disk_specific->real_sector_size
+					* (long long) arch_specific->real_sector_size
 					/ (long long) disk->dev->sector_size - 1;
 			part = ped_partition_new (disk, PED_PARTITION_NORMAL,
                                                   NULL, start, end);
@@ -586,9 +573,9 @@ dasd_write (const PedDisk* disk)
 		PDEBUG;
 
 		start = part->geom.start * disk->dev->sector_size
-				/ disk_specific->real_sector_size / disk->dev->hw_geom.sectors;
+				/ arch_specific->real_sector_size / disk->dev->hw_geom.sectors;
 		stop = (part->geom.end + 1)
-			   * disk->dev->sector_size / disk_specific->real_sector_size
+			   * disk->dev->sector_size / arch_specific->real_sector_size
 			   / disk->dev->hw_geom.sectors - 1;
 
 		PDEBUG;
@@ -734,8 +721,9 @@ static PedAlignment*
 dasd_get_partition_alignment(const PedDisk *disk)
 {
         DasdDiskSpecific* disk_specific = disk->disk_specific;
+        LinuxSpecific *arch_specific = LINUX_SPECIFIC(disk->dev);
         PedSector sector_size =
-                disk_specific->real_sector_size / disk->dev->sector_size;
+                arch_specific->real_sector_size / disk->dev->sector_size;
 
         return ped_alignment_new(0, disk->dev->hw_geom.sectors * sector_size);
 }
@@ -754,7 +742,7 @@ _primary_constraint (PedDisk* disk)
 
 	arch_specific = LINUX_SPECIFIC (disk->dev);
 	disk_specific = disk->disk_specific;
-	sector_size = disk_specific->real_sector_size / disk->dev->sector_size;
+	sector_size = arch_specific->real_sector_size / disk->dev->sector_size;
 
 	if (!ped_alignment_init (&start_align, 0,
 							 disk->dev->hw_geom.sectors * sector_size))
@@ -880,7 +868,7 @@ dasd_alloc_metadata (PedDisk* disk)
 	else
         /* Mark the start of the disk as metadata. */
 		vtoc_end = (FIRST_USABLE_TRK * (long long) disk->dev->hw_geom.sectors
-				   * (long long) disk_specific->real_sector_size
+				   * (long long) arch_specific->real_sector_size
 				   / (long long) disk->dev->sector_size) - 1;
 
 	new_part = ped_partition_new (disk,PED_PARTITION_METADATA,NULL,0,vtoc_end);

commit a665b2f0f6f7879ff91967765c08a44979e4a230
Author: Hans de Goede <hdegoede at redhat.com>
Date:   Tue Nov 3 13:08:57 2009 +0100

    dasd: remove bogus part_info pointer from DasdPartitionData
    
    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.

diff --git a/libparted/labels/dasd.c b/libparted/labels/dasd.c
index 6c8de52..dc8af4f 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 {
@@ -337,7 +336,7 @@ dasd_read (PedDisk* disk)
 		if (!ped_disk_add_partition (disk, part, NULL))
 			goto error_close_dev;
 
-        	fdasd_cleanup(&anchor);
+		fdasd_cleanup(&anchor);
 
 		return 1;
 	}
@@ -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,7 +462,8 @@ 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])
 {
 	PedPartition* part;
 	LinuxSpecific* arch_specific;
@@ -475,22 +474,22 @@ 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)) {
+	unsigned int i;
+	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))

commit a8a7c7bf1b62df64078fd22a8f443ad3c877ca41
Author: Hans de Goede <hdegoede at redhat.com>
Date:   Tue Nov 3 13:08:56 2009 +0100

    dasd: clean up anchor handling
    
    The current dasd label code keeps an fdasd anchor struct in the
    DasdDiskSpecific struct, and fills this during dasd_read. However this
    anchor does not get updated with any future mods, until dasd_write,
    at which points it gets completely re-initialized.
    
    Since the contents of the anchor saved during read does not get used
    anywhere else, this patch switches to using local anchor structs in
    dasd_read and dasd_write. This will also allow writing a significantly
    simpler duplicate implementation, then the one which is currently
    added to the Fedora package with a patch from Joel Granados (The
    current master dasd_duplicate implementation is not functional).
    
    This patch also fixes several missing calls to fdasd_cleanup() fixing
    several memory leaks.
    
    * libparted/arch/linux.h (struct _LinuxSpecific): Drop anchor member.
    * libparted/labels/dasd.c (DasdDiskSpecific): Drop anchor member.
    (dasd_clobber): Add missing fdasd_cleanup().
    (dasd_read, dasd_write): Use local anchor struct instead of a
    dynamically allocated one in DasdDiskSpecific.
    (dasd_read): Don't leak a PedConstraint in 2 error paths.
    (dasd_update_type): Pass in the used anchor as argument.

diff --git a/libparted/arch/linux.h b/libparted/arch/linux.h
index 3270367..391859b 100644
--- a/libparted/arch/linux.h
+++ b/libparted/arch/linux.h
@@ -18,10 +18,6 @@
 #ifndef PED_ARCH_LINUX_H_INCLUDED
 #define PED_ARCH_LINUX_H_INCLUDED
 
-#if defined __s390__ || defined__s390x__
-#  include <parted/fdasd.h>
-#endif
-
 #if HAVE_BLKID_BLKID_H
 #  include <blkid/blkid.h>
 #endif
@@ -35,8 +31,6 @@ struct _LinuxSpecific {
 	char*	dmtype;         /**< device map target type */
 #if defined __s390__ || defined __s390x__
 	unsigned int real_sector_size;
-	/* IBM internal dasd structure (i guess ;), required. */
-	struct fdasd_anchor *anchor;
 #endif
 #if USE_BLKID
         blkid_probe probe;
diff --git a/libparted/labels/dasd.c b/libparted/labels/dasd.c
index 93706ea..6c8de52 100644
--- a/libparted/labels/dasd.c
+++ b/libparted/labels/dasd.c
@@ -72,8 +72,6 @@ typedef struct {
 typedef struct {
 	unsigned int real_sector_size;
 	unsigned int format_type;
-	/* IBM internal dasd structure (i guess ;), required. */
-	struct fdasd_anchor *anchor;
 } DasdDiskSpecific;
 
 static int dasd_probe (const PedDevice *dev);
@@ -266,6 +264,8 @@ dasd_clobber (PedDevice* dev)
 	fdasd_recreate_vtoc(&anchor);
 	fdasd_write_labels(&anchor, arch_specific->fd);
 
+	fdasd_cleanup(&anchor);
+
 	return 1;
 }
 
@@ -282,6 +282,7 @@ dasd_read (PedDisk* disk)
 	partition_info_t *p;
 	LinuxSpecific* arch_specific;
 	DasdDiskSpecific* disk_specific;
+	struct fdasd_anchor anchor;
 
 	PDEBUG;
 
@@ -295,33 +296,30 @@ dasd_read (PedDisk* disk)
 	arch_specific = LINUX_SPECIFIC(dev);
 	disk_specific = disk->disk_specific;
 
-	disk_specific->anchor = ped_malloc(sizeof(fdasd_anchor_t));
-
 	PDEBUG;
 
-	fdasd_initialize_anchor(disk_specific->anchor);
+	fdasd_initialize_anchor(&anchor);
 
-	fdasd_get_geometry(disk_specific->anchor, arch_specific->fd);
+	fdasd_get_geometry(&anchor, arch_specific->fd);
 
 	/* check dasd for labels and vtoc */
-	if (fdasd_check_volume(disk_specific->anchor, arch_specific->fd))
+	if (fdasd_check_volume(&anchor, arch_specific->fd))
 		goto error_close_dev;
 
-	if ((disk_specific->anchor->geo.cylinders
-		* disk_specific->anchor->geo.heads) > BIG_DISK_SIZE)
-		disk_specific->anchor->big_disk++;
+	if ((anchor.geo.cylinders * anchor.geo.heads) > BIG_DISK_SIZE)
+		anchor.big_disk++;
 
 	ped_disk_delete_all (disk);
 
-	if (strncmp(disk_specific->anchor->vlabel->volkey,
+	if (strncmp(anchor.vlabel->volkey,
 				vtoc_ebcdic_enc ("LNX1", str, 4), 4) == 0) {
 		DasdPartitionData* dasd_data;
 
 		/* LDL format, old one */
 		disk_specific->format_type = 1;
 		start = 24;
-		end = (long long)(long long) disk_specific->anchor->geo.cylinders
-		      * (long long)disk_specific->anchor->geo.heads
+		end = (long long)(long long) anchor.geo.cylinders
+		      * (long long)anchor.geo.heads
 		      * (long long)disk->dev->hw_geom.sectors
 		      * (long long)disk_specific->real_sector_size
 		      / (long long)disk->dev->sector_size - 1;
@@ -339,13 +337,15 @@ dasd_read (PedDisk* disk)
 		if (!ped_disk_add_partition (disk, part, NULL))
 			goto error_close_dev;
 
+        	fdasd_cleanup(&anchor);
+
 		return 1;
 	}
 
 	/* CDL format, newer */
 	disk_specific->format_type = 2;
 
-	p = disk_specific->anchor->first;
+	p = anchor.first;
 	PDEBUG;
 
 	for (i = 1 ; i <= USABLE_PARTITIONS; i++) {
@@ -416,8 +416,10 @@ dasd_read (PedDisk* disk)
 		constraint_exact = ped_constraint_exact (&part->geom);
 		if (!constraint_exact)
 			goto error_close_dev;
-		if (!ped_disk_add_partition(disk, part, constraint_exact))
+		if (!ped_disk_add_partition(disk, part, constraint_exact)) {
+			ped_constraint_destroy(constraint_exact);
 			goto error_close_dev;
+		}
 		ped_constraint_destroy(constraint_exact);
 
 		if (p->fspace_trk > 0) {
@@ -440,8 +442,10 @@ dasd_read (PedDisk* disk)
 
 			if (!constraint_exact)
 				goto error_close_dev;
-			if (!ped_disk_add_partition(disk, part, constraint_exact))
+			if (!ped_disk_add_partition(disk, part, constraint_exact)) {
+				ped_constraint_destroy(constraint_exact);
 				goto error_close_dev;
+			}
 
 			ped_constraint_destroy (constraint_exact);
 		}
@@ -450,15 +454,17 @@ dasd_read (PedDisk* disk)
 	}
 
 	PDEBUG;
+	fdasd_cleanup(&anchor);
 	return 1;
 
 error_close_dev:
 	PDEBUG;
+	fdasd_cleanup(&anchor);
 	return 0;
 }
 
 static int
-dasd_update_type (const PedDisk* disk)
+dasd_update_type (const PedDisk* disk, struct fdasd_anchor *anchor)
 {
 	PedPartition* part;
 	LinuxSpecific* arch_specific;
@@ -526,7 +532,7 @@ dasd_update_type (const PedDisk* disk)
 				break;
 		}
 
-		disk_specific->anchor->vtoc_changed++;
+		anchor->vtoc_changed++;
 		vtoc_ebcdic_enc(p->f1->DS1DSNAM, p->f1->DS1DSNAM, 44);
 	}
 
@@ -542,6 +548,8 @@ dasd_write (const PedDisk* disk)
 	partition_info_t *p;
 	LinuxSpecific* arch_specific;
 	DasdDiskSpecific* disk_specific;
+	struct fdasd_anchor anchor;
+
 	PED_ASSERT(disk != NULL, return 0);
 	PED_ASSERT(disk->dev != NULL, return 0);
 
@@ -554,19 +562,18 @@ dasd_write (const PedDisk* disk)
 	if (disk_specific->format_type == 1)
 		return 1;
 
-	/* XXX re-initialize anchor? */
-	fdasd_initialize_anchor(disk_specific->anchor);
-	fdasd_get_geometry(disk_specific->anchor, arch_specific->fd);
+	/* initialize the anchor */
+	fdasd_initialize_anchor(&anchor);
+	fdasd_get_geometry(&anchor, arch_specific->fd);
 
 	/* check dasd for labels and vtoc */
-	if (fdasd_check_volume(disk_specific->anchor, arch_specific->fd))
+	if (fdasd_check_volume(&anchor, arch_specific->fd))
 		goto error;
 
-	if ((disk_specific->anchor->geo.cylinders
-		* disk_specific->anchor->geo.heads) > BIG_DISK_SIZE)
-		disk_specific->anchor->big_disk++;
+	if ((anchor.geo.cylinders * anchor.geo.heads) > BIG_DISK_SIZE)
+		anchor.big_disk++;
 
-	fdasd_recreate_vtoc(disk_specific->anchor);
+	fdasd_recreate_vtoc(&anchor);
 
 	for (i = 1; i <= USABLE_PARTITIONS; i++) {
 		unsigned int start, stop;
@@ -591,10 +598,10 @@ dasd_write (const PedDisk* disk)
 		type = dasd_data->type;
 		PDEBUG;
 
-		p = fdasd_add_partition(disk_specific->anchor, start, stop);
+		p = fdasd_add_partition(&anchor, start, stop);
 		if (!p) {
 			PDEBUG;
-			return 0;
+			goto error;
 		}
 		dasd_data->part_info = (void *) p;
 		p->type = dasd_data->system;
@@ -602,19 +609,21 @@ dasd_write (const PedDisk* disk)
 
 	PDEBUG;
 
-	if (!fdasd_prepare_labels(disk_specific->anchor, arch_specific->fd))
-		return 0;
+	if (!fdasd_prepare_labels(&anchor, arch_specific->fd))
+		goto error;
 
-	dasd_update_type(disk);
+	dasd_update_type(disk, &anchor);
 	PDEBUG;
 
-	if (!fdasd_write_labels(disk_specific->anchor, arch_specific->fd))
-		return 0;
+	if (!fdasd_write_labels(&anchor, arch_specific->fd))
+		goto error;
 
+	fdasd_cleanup(&anchor);
 	return 1;
 
 error:
 	PDEBUG;
+	fdasd_cleanup(&anchor);
 	return 0;
 }
 



More information about the Parted-commits mailing list