Blame SOURCES/0012-tests-Make-sure-the-extended-partition-length-is-cor.patch

0cb0b9
From 822439e4eaa4bb758d9058022154973cd690eca7 Mon Sep 17 00:00:00 2001
0cb0b9
From: "Brian C. Lane" <bcl@redhat.com>
0cb0b9
Date: Fri, 5 Jun 2015 13:46:29 -0700
0cb0b9
Subject: [PATCH] tests: Make sure the extended partition length is correct
0cb0b9
 (#1135493)
0cb0b9
0cb0b9
parted tells the kernel the wrong length when reporting a resize of an
0cb0b9
extended partition. Make sure the length is 2 for 512b sectors and 1
0cb0b9
sector for larger.
0cb0b9
0cb0b9
(cherry picked from commit 31b5bfa4cd0b2e2944af22466e7b7d88ad94c4c9)
0cb0b9
---
0cb0b9
 tests/Makefile.am                     |  1 +
0cb0b9
 tests/t2320-dos-extended-noclobber.sh | 48 +++++++++++++++++++++++++++++++++++
0cb0b9
 2 files changed, 49 insertions(+)
0cb0b9
 create mode 100644 tests/t2320-dos-extended-noclobber.sh
0cb0b9
0cb0b9
diff --git a/tests/Makefile.am b/tests/Makefile.am
0cb0b9
index ce8391d..001b9de 100644
0cb0b9
--- a/tests/Makefile.am
0cb0b9
+++ b/tests/Makefile.am
0cb0b9
@@ -47,6 +47,7 @@ TESTS = \
0cb0b9
   t2201-pc98-label-recog.sh \
0cb0b9
   t2300-dos-label-extended-bootcode.sh \
0cb0b9
   t2310-dos-extended-2-sector-min-offset.sh \
0cb0b9
+  t2320-dos-extended-noclobber.sh \
0cb0b9
   t2400-dos-hfs-partition-type.sh \
0cb0b9
   t2500-probe-corrupt-hfs.sh \
0cb0b9
   t3000-resize-fs.sh \
0cb0b9
diff --git a/tests/t2320-dos-extended-noclobber.sh b/tests/t2320-dos-extended-noclobber.sh
0cb0b9
new file mode 100644
0cb0b9
index 0000000..6f3dfff
0cb0b9
--- /dev/null
0cb0b9
+++ b/tests/t2320-dos-extended-noclobber.sh
0cb0b9
@@ -0,0 +1,48 @@
0cb0b9
+#!/bin/sh
0cb0b9
+# Ensure that the extended partition reports the correct length
0cb0b9
+# after adding another partition.
0cb0b9
+
0cb0b9
+# Copyright (C) 2015 Free Software Foundation, Inc.
0cb0b9
+
0cb0b9
+# This program is free software; you can redistribute it and/or modify
0cb0b9
+# it under the terms of the GNU General Public License as published by
0cb0b9
+# the Free Software Foundation; either version 3 of the License, or
0cb0b9
+# (at your option) any later version.
0cb0b9
+
0cb0b9
+# This program is distributed in the hope that it will be useful,
0cb0b9
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
0cb0b9
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
0cb0b9
+# GNU General Public License for more details.
0cb0b9
+
0cb0b9
+# You should have received a copy of the GNU General Public License
0cb0b9
+# along with this program.  If not, see <http://www.gnu.org/licenses/>.
0cb0b9
+
0cb0b9
+. "${srcdir=.}/init.sh"; path_prepend_ ../parted
0cb0b9
+
0cb0b9
+require_root_
0cb0b9
+require_scsi_debug_module_
0cb0b9
+
0cb0b9
+# create memory-backed device
0cb0b9
+ss=$sector_size_
0cb0b9
+scsi_debug_setup_ sector_size=$ss dev_size_mb=10 > dev-name ||
0cb0b9
+  skip_ 'failed to create scsi_debug device'
0cb0b9
+scsi_dev=$(cat dev-name)
0cb0b9
+
0cb0b9
+# Create a DOS label with an extended partition and a primary partition
0cb0b9
+parted -s $scsi_dev mklabel msdos || fail=1
0cb0b9
+parted -s $scsi_dev mkpart extended 1 5 > out 2>&1 || fail=1
0cb0b9
+parted -s $scsi_dev mkpart primary 5 10 > out 2>&1 || fail=1
0cb0b9
+
0cb0b9
+# Make sure the size of the extended partition is correct.
0cb0b9
+# 2 sectors for 512b and 1 sector for larger. /sys/.../size is in
0cb0b9
+# 512b blocks so convert accordingly.
0cb0b9
+dev=${scsi_dev#/dev/}
0cb0b9
+ext_len=$(cat /sys/block/$dev/${dev}1/size)
0cb0b9
+if [ $ss -eq 512 ]; then
0cb0b9
+    expected_len=2
0cb0b9
+else
0cb0b9
+    expected_len=$((ss / 512))
0cb0b9
+fi
0cb0b9
+[ $ext_len -eq $expected_len ] || fail=1
0cb0b9
+
0cb0b9
+Exit $fail
0cb0b9
-- 
0cb0b9
2.4.3
0cb0b9