On 10/31/2013 6:10 AM, zhuyj wrote: > I checked the source code, and I found that it is difficult to modify. > Since 100% mean to use the whole disk, so sector is correct to be equal > to dev->length. And radius is equal to 0 since unit_size is power of 2. > So if we use 100% in the source code, it is difficult to avoid this > failure. > > Thus I made the following patch. The main object is to replace 100% with > -1. Finally, this failure can be avoided.
That only fixes it for 100%, other percentages will still get the incorrect treatment. This should be easily fixed:
From e3bc2d0c335ec786adbe71ea67ab4c827e9d6393 Mon Sep 17 00:00:00 2001 From: Phillip Susi <[email protected]> Date: Mon, 4 Nov 2013 13:10:09 -0500 Subject: [PATCH] libparted: make sure not to treat percentages as exact If 1% of the drive size worked out ot be an even power of two, it would trigger the exact placement. Add an exception for the percent units. --- libparted/unit.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/libparted/unit.c b/libparted/unit.c index e545985..ff479f1 100644 --- a/libparted/unit.c +++ b/libparted/unit.c @@ -548,7 +548,7 @@ ped_unit_parse_custom (const char* str, const PedDevice* dev, PedUnit unit, do not use 4MiB as the range. Rather, presume that they are specifying precisely the starting or ending number, and treat "4MiB" just as we would treat "4194304B". */ - if (is_power_of_2 (unit_size)) + if (is_power_of_2 (unit_size) && unit != PED_UNIT_PERCENT) radius = 0; *sector = num * unit_size / dev->sector_size; -- 1.8.1.2
signature.asc
Description: OpenPGP digital signature

