From 5021bbdc6ee892890c2c6fede806b9ad6a6a9378 Mon Sep 17 00:00:00 2001 From: "Brian C. Lane" Date: Tue, 20 Mar 2012 17:25:23 -0700 Subject: [PATCH 03/89] tests: add t0301-overwrite-gpt-pmbr.sh Make sure parted checks the PMBR before the GPT partition table. * NEWS: Update with new GPT behavior. * tests/overwrite-gpt-pmbr.sh: New test. * tests/Makefile.am (TESTS): Add it. --- NEWS | 5 +++++ tests/Makefile.am | 1 + tests/t0301-overwrite-gpt-pmbr.sh | 44 +++++++++++++++++++++++++++++++++++++++ 3 files changed, 50 insertions(+) create mode 100755 tests/t0301-overwrite-gpt-pmbr.sh diff --git a/NEWS b/NEWS index 3bef20e..3969c44 100644 --- a/NEWS +++ b/NEWS @@ -2,6 +2,11 @@ GNU parted NEWS -*- outline -*- * Noteworthy changes in release ?.? (????-??-??) [?] +** Bug Fixes + + libparted: treat a disk with no pMBR as an msdos-labeled disk + even when it has valid GPT headers. + * Noteworthy changes in release 3.1 (2012-03-02) [stable] diff --git a/tests/Makefile.am b/tests/Makefile.am index 1b37fd9..1264812 100644 --- a/tests/Makefile.am +++ b/tests/Makefile.am @@ -28,6 +28,7 @@ TESTS = \ t0250-gpt.sh \ t0280-gpt-corrupt.sh \ t0300-dos-on-gpt.sh \ + t0301-overwrite-gpt-pmbr.sh \ t0400-loop-clobber-infloop.sh \ t0500-dup-clobber.sh \ t0501-duplicate.sh \ diff --git a/tests/t0301-overwrite-gpt-pmbr.sh b/tests/t0301-overwrite-gpt-pmbr.sh new file mode 100755 index 0000000..e7edb66 --- /dev/null +++ b/tests/t0301-overwrite-gpt-pmbr.sh @@ -0,0 +1,44 @@ +#!/bin/sh +# Test creating a msdos partition over a GPT partition with +# fdisk which doesn't remove the GPT partitions, only the PMBR + +# Copyright (C) 2009-2012 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 . + +. "${srcdir=.}/init.sh"; path_prepend_ ../parted + +ss=$sector_size_ +dev=loop-file + +# Create a GPT partition table. +dd if=/dev/null of=$dev bs=$ss seek=80 2> /dev/null || framework_failure +parted -s $dev mklabel gpt > out 2>&1 || framework_failure_ +compare /dev/null out || framework_failure_ + +# Create an MSDOS partition table in another file. +dd if=/dev/null of=m bs=$ss seek=80 2> /dev/null || framework_failure +parted -s m mklabel msdos > out 2>&1 || framework_failure_ +compare /dev/null out || framework_failure_ + +# Transplant the MSDOS MBR into the GPT-formatted image. +dd if=m of=$dev bs=$ss count=1 conv=notrunc || framework_failure_ + +# Now, try to create a GPT partition table in $dev. +# Before, parted would prompt, asking about the apparent inconsistency. +parted -s $dev mklabel gpt > out 2>&1 || fail=1 +# expect no output +compare /dev/null out || fail=1 + +Exit $fail -- 1.8.5.3