Blame SOURCES/0032-parted-fix-the-rescue-command.patch

7fd79c
From 0b996d3ebe95fdb6704f2c1d1a82574e07e86798 Mon Sep 17 00:00:00 2001
7fd79c
From: "Brian C. Lane" <bcl@redhat.com>
7fd79c
Date: Tue, 12 Apr 2016 16:13:44 -0700
7fd79c
Subject: [PATCH 32/36] parted: fix the rescue command
7fd79c
7fd79c
The rescue command often failed to locate a filesystem due to it
7fd79c
leaving cylinder alignment on, which snapped the allowed bounds
7fd79c
of the filesystem down to the next lower cylinder boundary,
7fd79c
causing the detected filesystem to be rejected due to not fitting.
7fd79c
7fd79c
(cherry picked from commit e09c30fb53179319ba1543813b5b4024e923b795)
7fd79c
---
7fd79c
 parted/parted.c          |  4 ++++
7fd79c
 tests/Makefile.am        |  1 +
7fd79c
 tests/t1701-rescue-fs.sh | 52 ++++++++++++++++++++++++++++++++++++++++++++++++
7fd79c
 3 files changed, 57 insertions(+)
7fd79c
 create mode 100644 tests/t1701-rescue-fs.sh
7fd79c
7fd79c
diff --git a/parted/parted.c b/parted/parted.c
7fd79c
index f8c81ca..18b778c 100644
7fd79c
--- a/parted/parted.c
7fd79c
+++ b/parted/parted.c
7fd79c
@@ -1472,6 +1472,10 @@ do_rescue (PedDevice** dev, PedDisk** diskp)
7fd79c
         disk = ped_disk_new (*dev);
7fd79c
         if (!disk)
7fd79c
                 goto error;
7fd79c
+        if (ped_disk_is_flag_available(disk, PED_DISK_CYLINDER_ALIGNMENT))
7fd79c
+                if (!ped_disk_set_flag(disk, PED_DISK_CYLINDER_ALIGNMENT,
7fd79c
+                                       0))
7fd79c
+                        goto error;
7fd79c
 
7fd79c
         if (!command_line_get_sector (_("Start?"), *dev, &start, NULL, NULL))
7fd79c
                 goto error_destroy_disk;
7fd79c
diff --git a/tests/Makefile.am b/tests/Makefile.am
7fd79c
index 001b9de..6a06dce 100644
7fd79c
--- a/tests/Makefile.am
7fd79c
+++ b/tests/Makefile.am
7fd79c
@@ -43,6 +43,7 @@ TESTS = \
7fd79c
   t1102-loop-label.sh \
7fd79c
   t1104-remove-and-add-partition.sh \
7fd79c
   t1700-probe-fs.sh \
7fd79c
+  t1701-rescue-fs.sh \
7fd79c
   t2200-dos-label-recog.sh \
7fd79c
   t2201-pc98-label-recog.sh \
7fd79c
   t2300-dos-label-extended-bootcode.sh \
7fd79c
diff --git a/tests/t1701-rescue-fs.sh b/tests/t1701-rescue-fs.sh
7fd79c
new file mode 100644
7fd79c
index 0000000..9b726cf
7fd79c
--- /dev/null
7fd79c
+++ b/tests/t1701-rescue-fs.sh
7fd79c
@@ -0,0 +1,52 @@
7fd79c
+#!/bin/sh
7fd79c
+# rescue ext4 file system
7fd79c
+
7fd79c
+# Copyright (C) 2008-2014 Free Software Foundation, Inc.
7fd79c
+
7fd79c
+# This program is free software; you can redistribute it and/or modify
7fd79c
+# it under the terms of the GNU General Public License as published by
7fd79c
+# the Free Software Foundation; either version 3 of the License, or
7fd79c
+# (at your option) any later version.
7fd79c
+
7fd79c
+# This program is distributed in the hope that it will be useful,
7fd79c
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
7fd79c
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
7fd79c
+# GNU General Public License for more details.
7fd79c
+
7fd79c
+# You should have received a copy of the GNU General Public License
7fd79c
+# along with this program.  If not, see <http://www.gnu.org/licenses/>.
7fd79c
+
7fd79c
+. "${srcdir=.}/init.sh"; path_prepend_ ../parted
7fd79c
+require_512_byte_sector_size_
7fd79c
+require_root_
7fd79c
+require_scsi_debug_module_
7fd79c
+
7fd79c
+# create memory-backed device
7fd79c
+scsi_debug_setup_ sector_size=$sector_size_ dev_size_mb=32 > dev-name ||
7fd79c
+  skip_ 'failed to create scsi_debug device'
7fd79c
+scsi_dev=$(cat dev-name)
7fd79c
+
7fd79c
+( mkfs.ext4 2>&1 | grep -i '^usage' ) > /dev/null \
7fd79c
+    || { warn_ "$ME: no ext4 support"; Exit $fail; }
7fd79c
+
7fd79c
+parted -s $scsi_dev mklabel msdos mkpart primary ext2 1m 100%
7fd79c
+mkfs.ext4 ${scsi_dev}1 || { warn_ $ME: mkfs.ext4 failed; fail=1; Exit $fail; }
7fd79c
+
7fd79c
+# remove the partition
7fd79c
+parted -s $scsi_dev rm 1 || fail=1
7fd79c
+
7fd79c
+# rescue the partition
7fd79c
+echo yes | parted ---pretend-input-tty $scsi_dev rescue 1m 100% > out 2>&1
7fd79c
+cat > exp <
7fd79c
+Information: A ext4 primary partition was found at 1049kB -> 33.6MB.  Do you want to add it to the partition table?
7fd79c
+Yes/No/Cancel? yes
7fd79c
+Information: You may need to update /etc/fstab.
7fd79c
+EOF
7fd79c
+# Transform the actual output, to avoid spurious differences when
7fd79c
+# $PWD contains a symlink-to-dir.  Also, remove the ^M      ...^M bogosity.
7fd79c
+# normalize the actual output
7fd79c
+mv out o2 && sed -e "s,
   *
,,g;s, $,," \
7fd79c
+                      -e "s,^.*/lt-parted: ,parted: ," o2 > out
7fd79c
+echo '' >> exp
7fd79c
+compare out exp || fail=1
7fd79c
+Exit $fail
7fd79c
-- 
7fd79c
2.5.5
7fd79c