import parted-3.2-39.el8

This commit is contained in:
CentOS Sources 2021-10-06 07:12:01 -04:00 committed by Stepan Oksanichenko
parent acadf44cba
commit f8a26a894a
8 changed files with 349 additions and 1 deletions

View File

@ -0,0 +1,31 @@
From da8572e6696c2593150af4ba6917dcfc142eebab Mon Sep 17 00:00:00 2001
From: "A. Wilcox" <AWilcox@Wilcox-Tech.com>
Date: Mon, 5 Aug 2019 09:05:00 -0700
Subject: [PATCH 91/97] libparted: Fix endian bug in bsd.c
You have to add 1 *before* doing the endian conversion, not after.
Signed-off-by: Brian C. Lane <bcl@redhat.com>
(cherry picked from commit d5827cf0606680b4c4e6bf25ac1a4af6e1092f3f)
Resolves: rhbz#1980105
---
libparted/labels/bsd.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/libparted/labels/bsd.c b/libparted/labels/bsd.c
index f253a32..1e79408 100644
--- a/libparted/labels/bsd.c
+++ b/libparted/labels/bsd.c
@@ -364,7 +364,7 @@ bsd_write (const PedDisk* disk)
max_part = i;
}
- label->d_npartitions = PED_CPU_TO_LE16 (max_part) + 1;
+ label->d_npartitions = PED_CPU_TO_LE16 (max_part + 1);
label->d_checksum = xbsd_dkcksum (label);
alpha_bootblock_checksum (bsd_specific->boot_code);
--
2.31.1

View File

@ -0,0 +1,36 @@
From 937325555fcbf1a8a23934171ea86251700de0fd Mon Sep 17 00:00:00 2001
From: Phillip Susi <psusi@ubuntu.com>
Date: Thu, 12 May 2016 21:38:51 -0400
Subject: [PATCH 92/97] Fix resizepart iec unit end sector
Fix resizepart to adjust the end to be -1 sector when using iec
power of 2 units so that the next partition can start immediately
following the new end, just like mkpart does.
(cherry picked from commit 247e3fc6cd8bca79b7c0362886ae9b5b06ba6f8c)
Related: rhbz#1861804
---
parted/parted.c | 5 ++++-
1 file changed, 4 insertions(+), 1 deletion(-)
diff --git a/parted/parted.c b/parted/parted.c
index c95fbbf..1733131 100644
--- a/parted/parted.c
+++ b/parted/parted.c
@@ -1561,8 +1561,11 @@ do_resizepart (PedDevice** dev, PedDisk** diskp)
start = part->geom.start;
end = oldend = part->geom.end;
- if (!command_line_get_sector (_("End?"), *dev, &end, &range_end, NULL))
+ char *end_input;
+ if (!command_line_get_sector (_("End?"), *dev, &end, &range_end, &end_input))
goto error;
+ _adjust_end_if_iec(&start, &end, range_end, end_input);
+ free(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.31.1

View File

@ -0,0 +1,28 @@
From 929a3bdd7a60912dd977ea79548b163a39b20568 Mon Sep 17 00:00:00 2001
From: "Brian C. Lane" <bcl@redhat.com>
Date: Tue, 23 Apr 2019 10:25:20 -0700
Subject: [PATCH 93/97] tests: Test incomplete resizepart command
(cherry picked from commit 679da92c54c75d7fca1fd825f1d42a750d115f2d)
Related: rhbz#1861804
---
tests/t3200-resize-partition.sh | 2 ++
1 file changed, 2 insertions(+)
diff --git a/tests/t3200-resize-partition.sh b/tests/t3200-resize-partition.sh
index 251b545..dcf1775 100755
--- a/tests/t3200-resize-partition.sh
+++ b/tests/t3200-resize-partition.sh
@@ -63,6 +63,8 @@ parted -m -s $dev u s p > out 2>&1 || fail=1
wait_for_dev_to_appear_ ${dev}1 || { warn_ "${dev}1 did not appear" fail=1; }
sleep 1
+# Running it without end should not core-dump or prompt
+parted -s $dev resizepart 1 > out 2> err || fail=1
# extend the filesystem to end on sector 4096
new_end=4096s
--
2.31.1

View File

@ -0,0 +1,38 @@
From 477968f0e73f2ec6b4427ab7c76fb6098699ec4e Mon Sep 17 00:00:00 2001
From: "Brian C. Lane" <bcl@redhat.com>
Date: Tue, 23 Apr 2019 13:52:25 -0700
Subject: [PATCH 94/97] Fix end_input usage in do_resizepart
It needs to be set to NULL, since it may not get set by the call to
command_line_get_sector
(cherry picked from commit ca845aeeddb17343c9289816833ca352f7c0d87b)
Related: rhbz#1861804
---
parted/parted.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/parted/parted.c b/parted/parted.c
index 1733131..4552741 100644
--- a/parted/parted.c
+++ b/parted/parted.c
@@ -1541,6 +1541,7 @@ do_resizepart (PedDevice** dev, PedDisk** diskp)
PedGeometry *range_end = NULL;
PedConstraint* constraint;
int rc = 0;
+ char* end_input = NULL;
if (!disk) {
disk = ped_disk_new (*dev);
@@ -1561,7 +1562,6 @@ do_resizepart (PedDevice** dev, PedDisk** diskp)
start = part->geom.start;
end = oldend = part->geom.end;
- char *end_input;
if (!command_line_get_sector (_("End?"), *dev, &end, &range_end, &end_input))
goto error;
_adjust_end_if_iec(&start, &end, range_end, end_input);
--
2.31.1

View File

@ -0,0 +1,57 @@
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

View File

@ -0,0 +1,89 @@
From 97113adc42f15ba04630c2808f14cd01aff22ed9 Mon Sep 17 00:00:00 2001
From: "Brian C. Lane" <bcl@redhat.com>
Date: Tue, 1 Sep 2020 14:51:54 -0700
Subject: [PATCH 96/97] tests: Add a test for resizepart on a busy partition
This makes sure that the resizepart on a busy partition with the size on
the cmdline will work.
(cherry picked from commit dfc611bd5126840d68493ad0e761511a71325af7)
Related: rhbz#1861804
---
tests/t3200-resize-partition.sh | 44 ++++++++++++++++++++++++++++++---
1 file changed, 40 insertions(+), 4 deletions(-)
diff --git a/tests/t3200-resize-partition.sh b/tests/t3200-resize-partition.sh
index dcf1775..2200977 100755
--- a/tests/t3200-resize-partition.sh
+++ b/tests/t3200-resize-partition.sh
@@ -2,7 +2,7 @@
# exercise the resize sub-command
# based on t3000-resize-fs.sh test
-# Copyright (C) 2009-2011 Free Software Foundation, Inc.
+# Copyright (C) 2009-2020 Free Software Foundation, Inc.
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
@@ -66,8 +66,8 @@ sleep 1
# Running it without end should not core-dump or prompt
parted -s $dev resizepart 1 > out 2> err || fail=1
-# extend the filesystem to end on sector 4096
-new_end=4096s
+# extend the filesystem to end on sector 2048
+new_end=2048s
parted -s $dev resizepart 1 $new_end > out 2> err || fail=1
# expect no output
compare /dev/null out || fail=1
@@ -77,9 +77,45 @@ compare /dev/null err || fail=1
parted -m -s $dev u s p > out 2>&1 || fail=1
sed -n 3p out > k && mv k out || fail=1
-printf "1:$default_start:$new_end:3073s:::$ms;\n" > exp || fail=1
+printf "1:$default_start:$new_end:1025s:::$ms;\n" > exp || fail=1
compare exp out || fail=1
+## Make sure resizing a busy partition works when user answers 'yes'
+# Format the partition and mount it for the busy check
+mkfs.ext4 "${dev}1" || skip_ mkfs.ext4 failed
+
+# be sure to unmount upon interrupt, failure, etc.
+cleanup_fn_() { umount "${dev}1" > /dev/null 2>&1; }
+
+mount_point=$(pwd)/mnt
+
+mkdir $mount_point || fail=1
+mount "${dev}1" "$mount_point" || fail=1
+
+# extend the filesystem to end on sector 4096
+new_end=4096s
+echo yes | parted ---pretend-input-tty $dev resizepart 1 $new_end > out 2>&1
+cat > exp <<EOF
+Warning: Partition ${dev}1 is being used. Are you sure you want to continue?
+Yes/No? yes
+Information: You may need to update /etc/fstab.
+
+EOF
+# Transform the actual output, to avoid spurious differences when
+# $PWD contains a symlink-to-dir. Also, remove the ^M ...^M bogosity.
+# normalize the actual output
+mv out o2 && sed -e "s, * ,,g;s, $,," o2 > out
+compare exp out || fail=1
+
+# print partition table
+parted -m -s $dev u s p > out 2>&1 || fail=1
+
+sed -n 3p out > k && mv k out || fail=1
+printf "1:$default_start:$new_end:3073s:ext2::$ms;\n" > exp || fail=1
+compare exp out || fail=1
+
+umount "${dev}1" || fail=1
+
# Remove the partition explicitly, so that mklabel doesn't evoke a warning.
parted -s $dev rm 1 || fail=1
--
2.31.1

View File

@ -0,0 +1,46 @@
From 9acf1c61938c83cf8f68613bacdf872a5f4db632 Mon Sep 17 00:00:00 2001
From: "Brian C. Lane" <bcl@redhat.com>
Date: Thu, 10 Jun 2021 15:55:59 -0700
Subject: [PATCH 97/97] parted: Fix memory leaks in do_resizepart
(cherry picked from commit 6c4050af2c6c0abdbe1d553fdf2f19a6b600e9d1)
Related: rhbz#1861804
---
parted/parted.c | 6 ++++--
1 file changed, 4 insertions(+), 2 deletions(-)
diff --git a/parted/parted.c b/parted/parted.c
index 64fdd54..d4db2b5 100644
--- a/parted/parted.c
+++ b/parted/parted.c
@@ -1572,7 +1572,6 @@ do_resizepart (PedDevice** dev, PedDisk** diskp)
/* 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;
@@ -1580,7 +1579,7 @@ do_resizepart (PedDevice** dev, PedDisk** diskp)
if (!command_line_get_sector (_("End?"), *dev, &end, &range_end, &end_input))
goto error;
_adjust_end_if_iec(&start, &end, range_end, end_input);
- free(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,
@@ -1606,6 +1605,9 @@ error_destroy_constraint:
error:
if (range_end != NULL)
ped_geometry_destroy (range_end);
+ free(end_input);
+ free(end_size);
+
return rc;
}
--
2.31.1

View File

@ -4,7 +4,7 @@
Summary: The GNU disk partition manipulation program
Name: parted
Version: 3.2
Release: 38%{?dist}
Release: 39%{?dist}
License: GPLv3+
Group: Applications/System
URL: http://www.gnu.org/software/parted
@ -112,6 +112,15 @@ Patch0088: 0088-linux.c-Use-sys-sysmacros.h-for-major-minor.patch
Patch0089: 0089-t6000-dm-Stop-using-private-lvm-root.patch
Patch0090: 0090-libparted-s390-Re-enabled-virtio-attached-DASD-heuri.patch
# Fix resizepart command
Patch0091: 0091-libparted-Fix-endian-bug-in-bsd.c.patch
Patch0092: 0092-Fix-resizepart-iec-unit-end-sector.patch
Patch0093: 0093-tests-Test-incomplete-resizepart-command.patch
Patch0094: 0094-Fix-end_input-usage-in-do_resizepart.patch
Patch0095: 0095-parted-Preserve-resizepart-End-when-prompted-for-bus.patch
Patch0096: 0096-tests-Add-a-test-for-resizepart-on-a-busy-partition.patch
Patch0097: 0097-parted-Fix-memory-leaks-in-do_resizepart.patch
Buildroot: %{_tmppath}/%{name}-%{version}-%{release}-root-%(%{__id_u} -n)
BuildRequires: gcc
BuildRequires: e2fsprogs-devel
@ -247,6 +256,20 @@ fi
%changelog
* Wed Jul 07 2021 Brian C. Lane <bcl@redhat.com> - 3.2-39
- tests: Add a test for resizepart on a busy partition (bcl)
Related: rhbz#1861804
- parted: Preserve resizepart End when prompted for busy partition (bcl)
Resolves: rhbz#1861804
- Fix end_input usage in do_resizepart (bcl)
Related: rhbz#1861804
- tests: Test incomplete resizepart command (bcl)
Related: rhbz#1861804
- Fix resizepart iec unit end sector (psusi)
Related: rhbz#1861804
- libparted: Fix endian bug in bsd.c (AWilcox)
Resolves: rhbz#1980105
* Thu Sep 26 2019 Brian C. Lane <bcl@redhat.com> - 3.2-38
- libparted: Re-enabled virtio-attached DASD heuristics on s390
Resolves: rhbz#1750663