[parted-devel] [PATCH] Really duplicate the disk instead of readd every partition

Otavio Salvador otavio at ossystems.com.br
Thu Aug 30 12:53:28 UTC 2007


To avoid possible differences between the original disk layout and the
duplicated one, a raw copy is done. Has been identified a case[1] where
extended partitions had their positions changed due this.

 1. http://bugs.debian.org/294520

This patch has been produced by Samuel Thibault <samuel.thibault at ens-lyon.org>
---
 libparted/disk.c |   17 +++++++++--------
 1 files changed, 9 insertions(+), 8 deletions(-)

diff --git a/libparted/disk.c b/libparted/disk.c
index e2e55c3..34b1677 100644
--- a/libparted/disk.c
+++ b/libparted/disk.c
@@ -223,23 +223,24 @@ static int
 _add_duplicate_part (PedDisk* disk, PedPartition* old_part)
 {
 	PedPartition*	new_part;
-	PedConstraint*	constraint_exact;
+	int ret;
 
 	new_part = disk->type->ops->partition_duplicate (old_part);
 	if (!new_part)
 		goto error;
 	new_part->disk = disk;
 
-	constraint_exact = ped_constraint_exact (&new_part->geom);
-	if (!constraint_exact)
+	_disk_push_update_mode (disk);
+	ret = _disk_raw_add (disk, new_part);
+	_disk_pop_update_mode (disk);
+	if (!ret)
 		goto error_destroy_new_part;
-	if (!ped_disk_add_partition (disk, new_part, constraint_exact))
-       		goto error_destroy_constraint_exact;
-	ped_constraint_destroy (constraint_exact);
+#ifdef DEBUG
+	if (!_disk_check_sanity (disk))
+		goto error_destroy_new_part;
+#endif
 	return 1;
 
-error_destroy_constraint_exact:
-	ped_constraint_destroy (constraint_exact);
 error_destroy_new_part:
 	ped_partition_destroy (new_part);
 error:
-- 
1.5.3.rc4




More information about the parted-devel mailing list