File libparted-remove-all-old-partitions-even-if-new-labe.patch of Package parted.30108
From: Phillip Susi <psusi@ubuntu.com>
Date: Sat, 26 Apr 2014 21:16:15 -0400
Subject: libparted: remove all old partitions, even if new label
allows less
References: bsc#501773, bsc#1092327
Patch-mainline: v3.2
Git-commit: dfdd8b0dd99b7fa990f40a3d3a225c5b3ef13c57
We were limiting partition sync operations to the lesser number allowed
by the device, or the label. This meant that when creating a new label
over an old label that had more partitions than the new one allows, the
higher partitions would not be removed. Use the greater of the two values
for the remove pass, and the lesser for the add.
Acked-by: Sebastian Parschauer <sparschauer@suse.de>
---
libparted/arch/linux.c | 11 +++++++++--
1 file changed, 9 insertions(+), 2 deletions(-)
--- a/libparted/arch/linux.c
+++ b/libparted/arch/linux.c
@@ -2810,9 +2810,10 @@ _disk_sync_part_table (PedDisk* disk)
get_partition_start_and_length = _kernel_get_partition_start_and_length;
}
- /* lpn = largest partition number. */
+ /* lpn = largest partition number.
+ * for remove pass, use greater of device or label limit */
if (ped_disk_get_max_supported_partition_count(disk, &lpn))
- lpn = PED_MIN(lpn, part_range);
+ lpn = PED_MAX(lpn, part_range);
else
lpn = part_range;
@@ -2863,6 +2864,12 @@ _disk_sync_part_table (PedDisk* disk)
if (!ok[i - 1] && errnums[i - 1] == ENXIO)
ok[i - 1] = 1; /* it already doesn't exist */
}
+ /* lpn = largest partition number.
+ * for add pass, use lesser of device or label limit */
+ if (ped_disk_get_max_supported_partition_count(disk, &lpn))
+ lpn = PED_MIN(lpn, part_range);
+ else
+ lpn = part_range;
for (i = 1; i <= lpn; i++) {
PedPartition *part = ped_disk_get_partition (disk, i);
if (!part)