[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
bug#16231: [PATCH 3/9] libparted: remove all old partitions, even if new
From: |
Phillip Susi |
Subject: |
bug#16231: [PATCH 3/9] libparted: remove all old partitions, even if new label allows less |
Date: |
Fri, 2 May 2014 21:50:45 -0400 |
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.
---
NEWS | 3 +++
libparted/arch/linux.c | 11 +++++++++--
2 files changed, 12 insertions(+), 2 deletions(-)
diff --git a/NEWS b/NEWS
index 1233f1c..093314b 100644
--- a/NEWS
+++ b/NEWS
@@ -23,6 +23,9 @@ GNU parted NEWS -*-
outline -*-
** Bug Fixes
+ libparted: remove all old partitions, even if new label does not allow
+ as many.
+
libparted: fat and ntfs boot sectors were misdetected as dos
partition tables instead of being treated as a loop label.
diff --git a/libparted/arch/linux.c b/libparted/arch/linux.c
index ced06a3..4cbe49b 100644
--- a/libparted/arch/linux.c
+++ b/libparted/arch/linux.c
@@ -2823,9 +2823,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;
@@ -2876,6 +2877,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)
--
1.9.1
- bug#16231: [PATCH 0/9] Refactored loop fixes, Phillip Susi, 2014/05/02
- bug#16231: [PATCH 2/9] libparted: remove old partitions *first* before adding new ones, Phillip Susi, 2014/05/02
- bug#16231: [PATCH 9/9] tests: test loop labels, Phillip Susi, 2014/05/02
- bug#16231: [PATCH 3/9] libparted: remove all old partitions, even if new label allows less,
Phillip Susi <=
- bug#16231: [PATCH 1/9] libparted: don't detect fat and ntfs boot sectors as dos MBR, Phillip Susi, 2014/05/02
- bug#16231: [PATCH 6/9] partprobe: do not skip loop labels, Phillip Susi, 2014/05/02
- bug#16231: [PATCH 7/9] libparted: give correct partition device name on loop labels, Phillip Susi, 2014/05/02
- bug#16231: [PATCH 5/9] libparted: don't create partition on loop label, Phillip Susi, 2014/05/02
- bug#16231: [PATCH 8/9] libparted: don't trash filesystem when writing loop label, Phillip Susi, 2014/05/02
- bug#16231: [PATCH 4/9] libparted: fix loop labels to not vanish, Phillip Susi, 2014/05/02
- bug#16231: [PATCH 0/9] Refactored loop fixes, Brian C. Lane, 2014/05/07