OSDN Git Service

libparted: fix snap radius so that it is using half (#665496)
authorBrian C. Lane <bcl@redhat.com>
Tue, 21 Jun 2011 17:44:15 +0000 (10:44 -0700)
committerJim Meyering <meyering@redhat.com>
Wed, 22 Jun 2011 19:56:05 +0000 (21:56 +0200)
The snap radius didn't match the documentation, it has been using +/-
unit size instead +/- 0.5 * unit (eg. 500KB for a MB unit). This caused
problems when specifying 1MB, 1GB, etc. as a partition start or end
resulting in partitions being created that were nowhere near the
specified size.

* libparted/unit.c (ped_unit_parse_custom): divide radius by 2
This addresses http://bugzilla.redhat.com/665496

libparted/unit.c

index dc4205b..c2921e3 100644 (file)
@@ -533,7 +533,7 @@ ped_unit_parse_custom (const char* str, const PedDevice* dev, PedUnit unit,
        }
 
        unit_size = ped_unit_get_size (dev, unit);
-       radius = ped_div_round_up (unit_size, dev->sector_size) - 1;
+       radius = (ped_div_round_up (unit_size, dev->sector_size) / 2) - 1;
        if (radius < 0)
                radius = 0;
        /* If the user specifies units in a power of 2, e.g., 4MiB, as in