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

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