Hi,

I noticed that resizepart seems to behave in a somewhat inconsistent
manner wrt. mkpart. For example, if I resize a partition with
"resizepart 2 100MiB" and then "mkpart primary ext4 100MiB 200MiB"
will overlap by one sector. The attached patch tries to make
resizepart do the same adjustment with IEC units as mkpart.

Let me know what you think.

Cheers,
From 79e5e08764514e921f4a7955b3a9c8eb783a9b38 Mon Sep 17 00:00:00 2001
From: Will Newton <[email protected]>
Date: Mon, 17 Jul 2017 18:22:37 +0100
Subject: [PATCH] parted: Adjust resizepart end if using IEC units

Do the same adjustment for the end argument to resizepart that
we do for the arguments to mkpart if they are specified in IEC
units. This makes the behaviour of the two commands more
consistent.

Signed-off-by: Will Newton <[email protected]>
---
 parted/parted.c | 5 ++++-
 1 file changed, 4 insertions(+), 1 deletion(-)

diff --git a/parted/parted.c b/parted/parted.c
index c471d49..0237fb0 100644
--- a/parted/parted.c
+++ b/parted/parted.c
@@ -1564,10 +1564,13 @@ do_resizepart (PedDevice** dev, PedDisk** diskp)
         if (!_partition_warn_busy (part))
                 goto error;
 
+	char *end_input;
+	PedSector dummy_start;
         start = part->geom.start;
         end = oldend = part->geom.end;
-        if (!command_line_get_sector (_("End?"), *dev, &end, &range_end, NULL))
+        if (!command_line_get_sector (_("End?"), *dev, &end, &range_end, &end_input))
                 goto error;
+        _adjust_end_if_iec(&dummy_start, &end, range_end, end_input);
         /* Do not move start of the partition */
         constraint = constraint_from_start_end_fixed_start (*dev, start, range_end);
         if (!ped_disk_set_partition_geom (disk, part, constraint,
-- 
2.9.4

Reply via email to