-----BEGIN PGP SIGNED MESSAGE----- Hash: SHA1 On 1/12/2012 12:18 PM, Phillip Susi wrote: > After looking at it carefully, it appears to me that before > Collin's patch, it made sure to leave a whole cylinder before the > first logical partition. After his patch, it only requires 2 > sectors, not a whole cylinder. > > It also appears that the constraint that this function generates > is only used when aligning the extended partition, so it only > matters for the purposes of align-check. It has no affect on this > test. > > The reason that BLKPG_ADD_PARTITION fails when the logical > partition starts on the immediately following sector is because > _blkpg_add_partition sets the length of the extended partition to > 2 sectors when it is added. It should not do this when there is a > logical partition that claims that second sector, and then this > would work fine. > > So what this test is really validating is that parted incorrectly > attempts to add overlapping partitions to the kernel, and that the > kernel fails that request. I think that the incorrect behavior > should be fixed and the test should validate that it works, not > that it fails. > > I'll work on a patch tonight.
I have patched parted to be able to correctly add the logical partition. Before I do anything with the test though, I want to ask what should be done. The test comment says: # Ensure that parted leaves at least 2 sectors between the beginning # of an extended partition and the first logical partition. # Before parted-2.3, it could be made to leave just one, and that # would cause trouble with the Linux kernel. So obviously when you wrote the test, you thought that parted was supposed to stop you from creating that logical partition. Parted never did this though. It happily lets you create that partition, writes it to the partition table, and then tries to inform the kernel about the logical partition, but it overlaps the extended partition and so the kernel refuses to add it. This is the error message that this test is actually checking. If you reboot ( or BLKRRPRT ), then the kernel recognizes the logical partition, and happily lets it overlap with the extended. If you try to install LILO to the extended partition, then it trounces on the boot sector of the logical partition. This is a bug in the kernel that should be fixed; the extended partition length should not be set to a length of 2 sectors if that second sector is claimed by a logical partition. So I see two possible ways to go: 1) Fix parted to *correctly* sync the logical partition to the kernel ( see attached patch ), and change this test to make sure that works 2) Fix parted to refuse to allow you to create that logical partition, and fix the test to look for that new error message. -----BEGIN PGP SIGNATURE----- Version: GnuPG v2.0.17 (MingW32) Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org/ iQEcBAEBAgAGBQJPDz2hAAoJEJrBOlT6nu75yUQH/AvO0m9xAbNPt0IVffs+goZg a5JO5dZ1yfM0Go3LpJUPHJO+hfl/wVe4xN3pxhMyMhxcy3SVPc2BMmjPLP46ogqu jpoMJ1DlZhk0FAiXxj95ymWp9DAJGGOzbBIFVoKjbx+QZaZAlWuBoftvBurex8Qn FWsmHavxw/YsHgQLtznyJ5N5i7ukplJhDdD1SU+Wl/grisdYCcGmxOO2GMbalZWS C6Iroql/VEJyPj3gRF/9T3i0DrdnljF6ImKRu61DfiTfKl9uag6oR3Jr4PPKbUKV sPmNvcdLnIDMoSZPTqlLNw9zK90MnWZyyiXwDuxfR7n0pSihzcN/0hEJtliH/vA= =YU7j -----END PGP SIGNATURE-----
>From 5e4ab9a30c67dddac16cc6377992fd836baa8809 Mon Sep 17 00:00:00 2001 From: Phillip Susi <[email protected]> Date: Thu, 12 Jan 2012 14:53:56 -0500 Subject: [PATCH] libparted: handle logical partitions starting immediately after the EBR _blkpg_add_partition() set the length of the extended partition to 2 sectors to allow LILO to be installed there, beacuse the linux kernel does this. If a logical partition used that second sector, adding it would fail beacuse of the overlap. Now _blkpg_add_partition() will limit the length to only the first sector if the second is used by a logical partition. --- libparted/arch/linux.c | 10 +++++++++- 1 files changed, 9 insertions(+), 1 deletions(-) diff --git a/libparted/arch/linux.c b/libparted/arch/linux.c index e2c4139..781cd50 100644 --- a/libparted/arch/linux.c +++ b/libparted/arch/linux.c @@ -2369,8 +2369,16 @@ _blkpg_add_partition (PedDisk* disk, const PedPartition *part) memset (&linux_part, 0, sizeof (linux_part)); linux_part.start = part->geom.start * disk->dev->sector_size; /* see fs/partitions/msdos.c:msdos_partition(): "leave room for LILO" */ - if (part->type & PED_PARTITION_EXTENDED) + if (part->type & PED_PARTITION_EXTENDED) { linux_part.length = part->geom.length == 1 ? 512 : 1024; + PedPartition *walk; + /* if the second sector is claimed by a logical partition, + then there's just no room for lilo, so don't try to use it */ + for (walk = part->part_list; walk; walk = walk->next) { + if (walk->geom.start == part->geom.start+1) + linux_part.length = 512; + } + } else linux_part.length = part->geom.length * disk->dev->sector_size; linux_part.pno = part->num; -- 1.7.5.4
0001-libparted-handle-logical-partitions-starting-immedia.patch.sig
Description: Binary data

