From 01900e056ec250836d15b5f5c3f59a8e1454b781 Mon Sep 17 00:00:00 2001 From: Phillip Susi Date: Mon, 4 Nov 2013 13:10:09 -0500 Subject: [PATCH 65/89] 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. --- NEWS | 4 ++++ libparted/unit.c | 2 +- 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/NEWS b/NEWS index 22e6109..9d0d931 100644 --- a/NEWS +++ b/NEWS @@ -13,6 +13,10 @@ GNU parted NEWS -*- outline -*- ** Bug Fixes + If a drive was 100 times an even multiple of two, sizes specified as + a percentage would trigger the exact placement rule and refuse to round + to the nearest half percent. + Avoid generating udev add/remove events for all unmodified partitions when writing a new table. 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.5.3