Blame SOURCES/0095-parted-Preserve-resizepart-End-when-prompted-for-bus.patch

b268e8
From b764430104af815296a5919888e397373746a21d Mon Sep 17 00:00:00 2001
b268e8
From: "Brian C. Lane" <bcl@redhat.com>
b268e8
Date: Mon, 31 Aug 2020 16:40:07 -0700
b268e8
Subject: [PATCH 95/97] parted: Preserve resizepart End when prompted for busy
b268e8
 partition
b268e8
b268e8
Resizing busy partitions is allowed, but the user is prompted, which
b268e8
erases the cmdline. It is annoying to have to re-end the ending location
b268e8
after answering Yes. This saves the word and pushes it back onto the
b268e8
cmdline after the user agrees to resize the busy partition.
b268e8
b268e8
(cherry picked from commit 691dabc930a6d544dfd8da787cddd159bab34b1e)
b268e8
b268e8
Resolves: rhbz#1861804
b268e8
---
b268e8
 parted/parted.c | 15 +++++++++++++++
b268e8
 1 file changed, 15 insertions(+)
b268e8
b268e8
diff --git a/parted/parted.c b/parted/parted.c
b268e8
index 4552741..64fdd54 100644
b268e8
--- a/parted/parted.c
b268e8
+++ b/parted/parted.c
b268e8
@@ -1542,6 +1542,7 @@ do_resizepart (PedDevice** dev, PedDisk** diskp)
b268e8
         PedConstraint*          constraint;
b268e8
         int rc = 0;
b268e8
         char*                   end_input = NULL;
b268e8
+        char*                   end_size = NULL;
b268e8
 
b268e8
         if (!disk) {
b268e8
                 disk = ped_disk_new (*dev);
b268e8
@@ -1557,9 +1558,23 @@ do_resizepart (PedDevice** dev, PedDisk** diskp)
b268e8
 
b268e8
         if (!command_line_get_partition (_("Partition number?"), disk, &part))
b268e8
                 goto error;
b268e8
+
b268e8
+        /* Save the optional End value if the partition is busy. */
b268e8
+        if (ped_partition_is_busy(part)) {
b268e8
+            if (command_line_get_word_count())
b268e8
+                end_size = command_line_pop_word();
b268e8
+        }
b268e8
+
b268e8
+        /* If the partition is busy this may clear the command_line and prompt the user */
b268e8
         if (!_partition_warn_busy (part))
b268e8
                 goto error;
b268e8
 
b268e8
+        /* Push the End value back onto the command_line, if it exists */
b268e8
+        if (end_size) {
b268e8
+            command_line_push_word(end_size);
b268e8
+            free(end_size);
b268e8
+        }
b268e8
+
b268e8
         start = part->geom.start;
b268e8
         end = oldend = part->geom.end;
b268e8
         if (!command_line_get_sector (_("End?"), *dev, &end, &range_end, &end_input))
b268e8
-- 
b268e8
2.31.1
b268e8