parted/SOURCES/0095-parted-Preserve-resizepart-End-when-prompted-for-bus.patch
2021-12-08 12:32:38 +00:00

58 lines
2.0 KiB
Diff

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