- libparted: Remove fdasd geometry code from alloc_metadata (#1244833) (bcl)
- parted: Display details of partition alignment failure (#726856) (bcl) - docs: Add list of filesystems for fs-type (#1311596) (bcl) - Use disk geometry as basis for ext2 sector sizes. (Steven.Lang) - parted: fix the rescue command (psusi)
This commit is contained in:
parent
3c4e97cf6e
commit
6ad4b6c092
106
0032-parted-fix-the-rescue-command.patch
Normal file
106
0032-parted-fix-the-rescue-command.patch
Normal file
@ -0,0 +1,106 @@
|
||||
From 0b996d3ebe95fdb6704f2c1d1a82574e07e86798 Mon Sep 17 00:00:00 2001
|
||||
From: "Brian C. Lane" <bcl@redhat.com>
|
||||
Date: Tue, 12 Apr 2016 16:13:44 -0700
|
||||
Subject: [PATCH 32/36] parted: fix the rescue command
|
||||
|
||||
The rescue command often failed to locate a filesystem due to it
|
||||
leaving cylinder alignment on, which snapped the allowed bounds
|
||||
of the filesystem down to the next lower cylinder boundary,
|
||||
causing the detected filesystem to be rejected due to not fitting.
|
||||
|
||||
(cherry picked from commit e09c30fb53179319ba1543813b5b4024e923b795)
|
||||
---
|
||||
parted/parted.c | 4 ++++
|
||||
tests/Makefile.am | 1 +
|
||||
tests/t1701-rescue-fs.sh | 52 ++++++++++++++++++++++++++++++++++++++++++++++++
|
||||
3 files changed, 57 insertions(+)
|
||||
create mode 100644 tests/t1701-rescue-fs.sh
|
||||
|
||||
diff --git a/parted/parted.c b/parted/parted.c
|
||||
index f8c81ca..18b778c 100644
|
||||
--- a/parted/parted.c
|
||||
+++ b/parted/parted.c
|
||||
@@ -1472,6 +1472,10 @@ do_rescue (PedDevice** dev, PedDisk** diskp)
|
||||
disk = ped_disk_new (*dev);
|
||||
if (!disk)
|
||||
goto error;
|
||||
+ if (ped_disk_is_flag_available(disk, PED_DISK_CYLINDER_ALIGNMENT))
|
||||
+ if (!ped_disk_set_flag(disk, PED_DISK_CYLINDER_ALIGNMENT,
|
||||
+ 0))
|
||||
+ goto error;
|
||||
|
||||
if (!command_line_get_sector (_("Start?"), *dev, &start, NULL, NULL))
|
||||
goto error_destroy_disk;
|
||||
diff --git a/tests/Makefile.am b/tests/Makefile.am
|
||||
index 001b9de..6a06dce 100644
|
||||
--- a/tests/Makefile.am
|
||||
+++ b/tests/Makefile.am
|
||||
@@ -43,6 +43,7 @@ TESTS = \
|
||||
t1102-loop-label.sh \
|
||||
t1104-remove-and-add-partition.sh \
|
||||
t1700-probe-fs.sh \
|
||||
+ t1701-rescue-fs.sh \
|
||||
t2200-dos-label-recog.sh \
|
||||
t2201-pc98-label-recog.sh \
|
||||
t2300-dos-label-extended-bootcode.sh \
|
||||
diff --git a/tests/t1701-rescue-fs.sh b/tests/t1701-rescue-fs.sh
|
||||
new file mode 100644
|
||||
index 0000000..9b726cf
|
||||
--- /dev/null
|
||||
+++ b/tests/t1701-rescue-fs.sh
|
||||
@@ -0,0 +1,52 @@
|
||||
+#!/bin/sh
|
||||
+# rescue ext4 file system
|
||||
+
|
||||
+# Copyright (C) 2008-2014 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
|
||||
+# the Free Software Foundation; either version 3 of the License, or
|
||||
+# (at your option) any later version.
|
||||
+
|
||||
+# This program is distributed in the hope that it will be useful,
|
||||
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
+# GNU General Public License for more details.
|
||||
+
|
||||
+# You should have received a copy of the GNU General Public License
|
||||
+# along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
+
|
||||
+. "${srcdir=.}/init.sh"; path_prepend_ ../parted
|
||||
+require_512_byte_sector_size_
|
||||
+require_root_
|
||||
+require_scsi_debug_module_
|
||||
+
|
||||
+# create memory-backed device
|
||||
+scsi_debug_setup_ sector_size=$sector_size_ dev_size_mb=32 > dev-name ||
|
||||
+ skip_ 'failed to create scsi_debug device'
|
||||
+scsi_dev=$(cat dev-name)
|
||||
+
|
||||
+( mkfs.ext4 2>&1 | grep -i '^usage' ) > /dev/null \
|
||||
+ || { warn_ "$ME: no ext4 support"; Exit $fail; }
|
||||
+
|
||||
+parted -s $scsi_dev mklabel msdos mkpart primary ext2 1m 100%
|
||||
+mkfs.ext4 ${scsi_dev}1 || { warn_ $ME: mkfs.ext4 failed; fail=1; Exit $fail; }
|
||||
+
|
||||
+# remove the partition
|
||||
+parted -s $scsi_dev rm 1 || fail=1
|
||||
+
|
||||
+# rescue the partition
|
||||
+echo yes | parted ---pretend-input-tty $scsi_dev rescue 1m 100% > out 2>&1
|
||||
+cat > exp <<EOF
|
||||
+Information: A ext4 primary partition was found at 1049kB -> 33.6MB. Do you want to add it to the partition table?
|
||||
+Yes/No/Cancel? 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, $,," \
|
||||
+ -e "s,^.*/lt-parted: ,parted: ," o2 > out
|
||||
+echo '' >> exp
|
||||
+compare out exp || fail=1
|
||||
+Exit $fail
|
||||
--
|
||||
2.5.5
|
||||
|
30
0033-Use-disk-geometry-as-basis-for-ext2-sector-sizes.patch
Normal file
30
0033-Use-disk-geometry-as-basis-for-ext2-sector-sizes.patch
Normal file
@ -0,0 +1,30 @@
|
||||
From ac501e86dd95baa6f426cdd1395f2fe2a9c4e92a Mon Sep 17 00:00:00 2001
|
||||
From: Steven Lang <Steven.Lang@hgst.com>
|
||||
Date: Thu, 8 Jan 2015 17:22:02 -0800
|
||||
Subject: [PATCH 33/36] Use disk geometry as basis for ext2 sector sizes.
|
||||
|
||||
When creating the geom for probed ext2 based filesystems, the
|
||||
size was being reported in 512 byte sectors, regardless of what
|
||||
the actual sector size of the device is.
|
||||
|
||||
(cherry picked from commit d15a596a4436a08b9ad9db35729740b6314d536b)
|
||||
---
|
||||
libparted/fs/ext2/interface.c | 2 +-
|
||||
1 file changed, 1 insertion(+), 1 deletion(-)
|
||||
|
||||
diff --git a/libparted/fs/ext2/interface.c b/libparted/fs/ext2/interface.c
|
||||
index 890a47b..a90c592 100644
|
||||
--- a/libparted/fs/ext2/interface.c
|
||||
+++ b/libparted/fs/ext2/interface.c
|
||||
@@ -41,7 +41,7 @@ _ext2_generic_probe (PedGeometry* geom, int expect_ext_ver)
|
||||
struct ext2_super_block *sb = (struct ext2_super_block *)(sb_v + 1024);
|
||||
|
||||
if (EXT2_SUPER_MAGIC(*sb) == EXT2_SUPER_MAGIC_CONST) {
|
||||
- PedSector block_size = 1 << (EXT2_SUPER_LOG_BLOCK_SIZE(*sb) + 1);
|
||||
+ PedSector block_size = (EXT2_MIN_BLOCK_SIZE << (EXT2_SUPER_LOG_BLOCK_SIZE(*sb))) / geom->dev->sector_size;
|
||||
PedSector block_count = EXT2_SUPER_BLOCKS_COUNT(*sb);
|
||||
PedSector group_blocks = EXT2_SUPER_BLOCKS_PER_GROUP(*sb);
|
||||
PedSector group_nr = EXT2_SUPER_BLOCK_GROUP_NR(*sb);
|
||||
--
|
||||
2.5.5
|
||||
|
29
0034-docs-Add-list-of-filesystems-for-fs-type-1311596.patch
Normal file
29
0034-docs-Add-list-of-filesystems-for-fs-type-1311596.patch
Normal file
@ -0,0 +1,29 @@
|
||||
From d1d40cda51078a5dd8843d8c54e7e112fa028518 Mon Sep 17 00:00:00 2001
|
||||
From: "Brian C. Lane" <bcl@redhat.com>
|
||||
Date: Mon, 29 Feb 2016 16:47:18 -0800
|
||||
Subject: [PATCH 34/36] docs: Add list of filesystems for fs-type (#1311596)
|
||||
|
||||
Add the most common filesystem types to the parted manpage.
|
||||
|
||||
Resolves: rhbz#1311596
|
||||
(cherry picked from commit c9f50a36aee0a4c373b5e1bd3069aeb18fac055d)
|
||||
---
|
||||
doc/C/parted.8 | 2 ++
|
||||
1 file changed, 2 insertions(+)
|
||||
|
||||
diff --git a/doc/C/parted.8 b/doc/C/parted.8
|
||||
index 5304375..a45f42f 100644
|
||||
--- a/doc/C/parted.8
|
||||
+++ b/doc/C/parted.8
|
||||
@@ -76,6 +76,8 @@ should be one of "aix", "amiga", "bsd", "dvh", "gpt", "loop", "mac", "msdos",
|
||||
.B mkpart \fIpart-type\fP \fI[fs-type]\fP \fIstart\fP \fIend\fP
|
||||
Make a \fIpart-type\fP partition for filesystem \fIfs-type\fP (if specified),
|
||||
beginning at \fIstart\fP and ending at \fIend\fP (by default in megabytes).
|
||||
+\fIfs-type\fP can be one of "btrfs", "ext2", "ext3", "ext4", "fat16", "fat32",
|
||||
+"hfs", "hfs+", "linux-swap", "ntfs", "reiserfs", or "xfs".
|
||||
\fIpart-type\fP should be one of "primary", "logical", or "extended".
|
||||
.TP
|
||||
.B name \fIpartition\fP \fIname\fP
|
||||
--
|
||||
2.5.5
|
||||
|
145
0035-parted-Display-details-of-partition-alignment-failur.patch
Normal file
145
0035-parted-Display-details-of-partition-alignment-failur.patch
Normal file
@ -0,0 +1,145 @@
|
||||
From a7d850a3b39b160dcc23e12491cb2cc7c056cd01 Mon Sep 17 00:00:00 2001
|
||||
From: "Brian C. Lane" <bcl@redhat.com>
|
||||
Date: Wed, 28 Oct 2015 11:57:22 -0700
|
||||
Subject: [PATCH 35/36] parted: Display details of partition alignment failure
|
||||
(#726856)
|
||||
|
||||
When alignment for a new partition fails it isn't always obvious why it
|
||||
failed. This adds printing the reason for the failure, in the form of:
|
||||
|
||||
start % grain != offset
|
||||
|
||||
This modifies align-check in interactive mode to print the alignment the
|
||||
error details if it isn't aligned. Script mode behavior is unchanged.
|
||||
|
||||
Also cleanup pointer usage and handle asprintf failure by using a constant
|
||||
string in the error report - "unknown (malloc failure)".
|
||||
|
||||
(cherry picked from commit 1726dbb4cd2dc4b19fe8d3c4b94e172fc0bd2c7c)
|
||||
---
|
||||
parted/parted.c | 64 +++++++++++++++++++++++++++++++++++++++++++++------------
|
||||
1 file changed, 51 insertions(+), 13 deletions(-)
|
||||
|
||||
diff --git a/parted/parted.c b/parted/parted.c
|
||||
index 18b778c..06f9971 100644
|
||||
--- a/parted/parted.c
|
||||
+++ b/parted/parted.c
|
||||
@@ -183,7 +183,8 @@ static TimerContext timer_context;
|
||||
static int _print_list ();
|
||||
static void _done (PedDevice* dev, PedDisk *diskp);
|
||||
static bool partition_align_check (PedDisk const *disk,
|
||||
- PedPartition const *part, enum AlignmentType a_type);
|
||||
+ PedPartition const *part, enum AlignmentType a_type,
|
||||
+ char **align_err);
|
||||
|
||||
static void
|
||||
_timer_handler (PedTimer* timer, void* context)
|
||||
@@ -783,21 +784,27 @@ do_mkpart (PedDevice** dev, PedDisk** diskp)
|
||||
}
|
||||
}
|
||||
|
||||
+ char *align_err = NULL;
|
||||
if ((alignment == ALIGNMENT_OPTIMAL &&
|
||||
- !partition_align_check(disk, part, PA_OPTIMUM)) ||
|
||||
+ !partition_align_check(disk, part, PA_OPTIMUM, &align_err)) ||
|
||||
(alignment == ALIGNMENT_MINIMAL &&
|
||||
- !partition_align_check(disk, part, PA_MINIMUM))) {
|
||||
+ !partition_align_check(disk, part, PA_MINIMUM, &align_err))) {
|
||||
if (ped_exception_throw(
|
||||
PED_EXCEPTION_WARNING,
|
||||
(opt_script_mode
|
||||
? PED_EXCEPTION_OK
|
||||
: PED_EXCEPTION_IGNORE_CANCEL),
|
||||
_("The resulting partition is not properly "
|
||||
- "aligned for best performance.")) ==
|
||||
+ "aligned for best performance: %s"),
|
||||
+ align_err ? align_err : _("unknown (malloc failed)")) ==
|
||||
PED_EXCEPTION_CANCEL) {
|
||||
+ if (align_err)
|
||||
+ free(align_err);
|
||||
/* undo partition addition */
|
||||
goto error_remove_part;
|
||||
}
|
||||
+ if (align_err)
|
||||
+ free(align_err);
|
||||
}
|
||||
} else {
|
||||
ped_exception_leave_all();
|
||||
@@ -1629,10 +1636,18 @@ do_select (PedDevice** dev, PedDisk** diskp)
|
||||
offset and alignment requirements. Also return true if there is
|
||||
insufficient kernel support to determine DISK's alignment requirements.
|
||||
Otherwise, return false. A_TYPE selects whether to check for minimal
|
||||
- or optimal alignment requirements. */
|
||||
+ or optimal alignment requirements.
|
||||
+
|
||||
+ If align_err is not NULL a string describing why the check failed
|
||||
+ will be allocated and returned. It is up to the caller to free this.
|
||||
+ Pass NULL if no error description is needed.
|
||||
+
|
||||
+ If allocating the error string fails *align_err will be set to NULL, the
|
||||
+ caller should always check for this.
|
||||
+*/
|
||||
static bool
|
||||
partition_align_check (PedDisk const *disk, PedPartition const *part,
|
||||
- enum AlignmentType a_type)
|
||||
+ enum AlignmentType a_type, char **align_err)
|
||||
{
|
||||
PED_ASSERT (part->disk == disk);
|
||||
PedDevice const *dev = disk->dev;
|
||||
@@ -1641,10 +1656,20 @@ partition_align_check (PedDisk const *disk, PedPartition const *part,
|
||||
? ped_device_get_minimum_alignment (dev)
|
||||
: ped_device_get_optimum_alignment (dev));
|
||||
if (pa == NULL)
|
||||
- return true;
|
||||
+ return true;
|
||||
|
||||
PED_ASSERT (pa->grain_size != 0);
|
||||
bool ok = (part->geom.start % pa->grain_size == pa->offset);
|
||||
+
|
||||
+ /* If it isn't aligned and the caller wants an explanation,
|
||||
+ show them the math. */
|
||||
+ if (!ok && align_err) {
|
||||
+ if (asprintf(align_err,
|
||||
+ "%llds %% %llds != %llds",
|
||||
+ part->geom.start, pa->grain_size, pa->offset) < 0) {
|
||||
+ *align_err = NULL;
|
||||
+ }
|
||||
+ }
|
||||
free (pa);
|
||||
return ok;
|
||||
}
|
||||
@@ -1665,12 +1690,25 @@ do_align_check (PedDevice **dev, PedDisk** diskp)
|
||||
if (!command_line_get_partition (_("Partition number?"), *diskp, &part))
|
||||
goto error;
|
||||
|
||||
- bool aligned = partition_align_check (*diskp, part, align_type);
|
||||
- if (!opt_script_mode)
|
||||
- printf(aligned ? _("%d aligned\n") : _("%d not aligned\n"), part->num);
|
||||
-
|
||||
- if (opt_script_mode)
|
||||
- return aligned ? 1 : 0;
|
||||
+ char *align_err = NULL;
|
||||
+ bool aligned = partition_align_check (*diskp, part, align_type, &align_err);
|
||||
+
|
||||
+ /* Don't print the error in script mode */
|
||||
+ if (opt_script_mode) {
|
||||
+ if (align_err)
|
||||
+ free(align_err);
|
||||
+ return aligned ? 1 : 0;
|
||||
+ }
|
||||
+
|
||||
+ if (aligned)
|
||||
+ printf(_("%d aligned\n"), part->num);
|
||||
+ else
|
||||
+ printf(_("%d not aligned: %s\n"),
|
||||
+ part->num,
|
||||
+ align_err ? align_err : _("unknown (malloc failed)"));
|
||||
+
|
||||
+ if (align_err)
|
||||
+ free(align_err);
|
||||
|
||||
/* Always return 1 in interactive mode, to be consistent
|
||||
with the other modes. */
|
||||
--
|
||||
2.5.5
|
||||
|
@ -0,0 +1,49 @@
|
||||
From 02178bf3980410abdd57c9f1045ff27bc4f11d7e Mon Sep 17 00:00:00 2001
|
||||
From: "Brian C. Lane" <bcl@redhat.com>
|
||||
Date: Mon, 11 Apr 2016 15:10:51 -0700
|
||||
Subject: [PATCH 36/36] libparted: Remove fdasd geometry code from
|
||||
alloc_metadata (#1244833)
|
||||
|
||||
commit db20944f changed how the trailing_metadata_end is calculated in
|
||||
dasd_alloc_metadata, removing the need for setting up the anchor struct.
|
||||
But dasd_alloc_metadata can be called in various contexts, and the
|
||||
arch_specific->fd may or may not be valid during these calls. This can
|
||||
result in unpredictable crashes when it uses a stale fd and tries to run
|
||||
the file image code in fdasd_get_geometry instead of the device code.
|
||||
|
||||
The solution is to just drop the unneeded code, and to remember that
|
||||
arch_specific->fd should only be used when ped_device_open has first
|
||||
been called.
|
||||
|
||||
Resolves: rhbz#1244833
|
||||
(cherry picked from commit 9da2f460bebf9a8281fdd52536d3676b0914b8fd)
|
||||
---
|
||||
libparted/labels/dasd.c | 4 ----
|
||||
1 file changed, 4 deletions(-)
|
||||
|
||||
diff --git a/libparted/labels/dasd.c b/libparted/labels/dasd.c
|
||||
index bb32d66..f79a867 100644
|
||||
--- a/libparted/labels/dasd.c
|
||||
+++ b/libparted/labels/dasd.c
|
||||
@@ -948,7 +948,6 @@ dasd_alloc_metadata (PedDisk* disk)
|
||||
PedPartition* part = NULL; /* initialize solely to placate gcc */
|
||||
PedPartition* new_part2;
|
||||
PedSector trailing_meta_start, trailing_meta_end;
|
||||
- struct fdasd_anchor anchor;
|
||||
|
||||
PED_ASSERT (disk != NULL);
|
||||
PED_ASSERT (disk->dev != NULL);
|
||||
@@ -998,10 +997,7 @@ dasd_alloc_metadata (PedDisk* disk)
|
||||
backed up, then restored to a larger size disk, etc.
|
||||
*/
|
||||
trailing_meta_start = part->geom.end + 1;
|
||||
- fdasd_initialize_anchor(&anchor);
|
||||
- fdasd_get_geometry(disk->dev, &anchor, arch_specific->fd);
|
||||
trailing_meta_end = (long long) disk->dev->length - 1;
|
||||
- fdasd_cleanup(&anchor);
|
||||
if (trailing_meta_end >= trailing_meta_start) {
|
||||
new_part2 = ped_partition_new (disk,PED_PARTITION_METADATA,
|
||||
NULL, trailing_meta_start, trailing_meta_end);
|
||||
--
|
||||
2.5.5
|
||||
|
14
parted.spec
14
parted.spec
@ -4,7 +4,7 @@
|
||||
Summary: The GNU disk partition manipulation program
|
||||
Name: parted
|
||||
Version: 3.2
|
||||
Release: 18%{?dist}
|
||||
Release: 19%{?dist}
|
||||
License: GPLv3+
|
||||
Group: Applications/System
|
||||
URL: http://www.gnu.org/software/parted
|
||||
@ -45,6 +45,11 @@ Patch0028: 0028-tests-Fix-t1700-failing-on-a-host-with-a-4k-xfs-file.patch
|
||||
Patch0029: 0029-lib-fs-resize-Prevent-crash-resizing-FAT-with-very-d.patch
|
||||
Patch0030: 0030-tests-t3000-resize-fs.sh-Add-very-deep-directory.patch
|
||||
Patch0031: 0031-Use-BLKSSZGET-to-get-device-sector-size-in-_device_p.patch
|
||||
Patch0032: 0032-parted-fix-the-rescue-command.patch
|
||||
Patch0033: 0033-Use-disk-geometry-as-basis-for-ext2-sector-sizes.patch
|
||||
Patch0034: 0034-docs-Add-list-of-filesystems-for-fs-type-1311596.patch
|
||||
Patch0035: 0035-parted-Display-details-of-partition-alignment-failur.patch
|
||||
Patch0036: 0036-libparted-Remove-fdasd-geometry-code-from-alloc_meta.patch
|
||||
|
||||
Buildroot: %{_tmppath}/%{name}-%{version}-%{release}-root-%(%{__id_u} -n)
|
||||
BuildRequires: e2fsprogs-devel
|
||||
@ -181,6 +186,13 @@ fi
|
||||
|
||||
|
||||
%changelog
|
||||
* Tue Apr 12 2016 Brian C. Lane <bcl@redhat.com> 3.2-19
|
||||
- libparted: Remove fdasd geometry code from alloc_metadata (#1244833) (bcl)
|
||||
- parted: Display details of partition alignment failure (#726856) (bcl)
|
||||
- docs: Add list of filesystems for fs-type (#1311596) (bcl)
|
||||
- Use disk geometry as basis for ext2 sector sizes. (Steven.Lang)
|
||||
- parted: fix the rescue command (psusi)
|
||||
|
||||
* Tue Mar 29 2016 Brian C. Lane <bcl@redhat.com> 3.2-18
|
||||
- Use BLKSSZGET to get device sector size in _device_probe_geometry()
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user