[parted-devel] [PATCH 2/6] libparted: handle busy extended partition

Petr Uzel petr.uzel at suse.cz
Mon Oct 15 08:31:51 UTC 2012


When parted encounters busy partition during its loop for informing
the kernel about partition changes, it tries to compare geometry
of the to-be created partition with the geometry of the existing
partition (reported by the kernel). If these geometries match, there is
nothing more to do for parted.

However, this fails for msdos extended partitions, because kernel always
reports size of extended partition to be 2s, no matter how big it
actually is (to avoid having overlapping partitions in the kernel's
representation of partition table). This makes the comparison of
geometries to fail for extended partitions, so they need to be handled
specially.

Steps to reproduce:
modprobe scsi_debug
parted -s /dev/sdX mklabel msdos
parted -s /dev/sdX mkpart extended 1M -- -1
exec 3>/dev/sdX1  # make sdX1 busy
parted -s /dev/sdX mkpart logical ext2 2M 4M

* libparted/arch/linux.c (_disk_sync_part_table): Do not check size
of extended partition.

Signed-off-by: Petr Uzel <petr.uzel at suse.cz>
---
 libparted/arch/linux.c |    7 ++++---
 1 file changed, 4 insertions(+), 3 deletions(-)

diff --git a/libparted/arch/linux.c b/libparted/arch/linux.c
index e2c4139..96a6b37 100644
--- a/libparted/arch/linux.c
+++ b/libparted/arch/linux.c
@@ -2614,9 +2614,10 @@ _disk_sync_part_table (PedDisk* disk)
                                 if (!_kernel_get_partition_start_and_length(part,
                                                                 &start, &length))
                                         goto cleanup;
-                                if (start == part->geom.start
-				    && length == part->geom.length)
-                                        ok[i - 1] = 1;
+				if (start == part->geom.start
+				    && (length == part->geom.length
+					|| part->type == PED_PARTITION_EXTENDED))
+						ok[i - 1] = 1;
                                 /* If the new partition is unchanged and the
 				   existing one was not removed because it was
 				   in use, then reset the error flag and do not
-- 
1.7.10.4




More information about the parted-devel mailing list