OSDN Git Service

tests: add test for GPT PMBR pmbr_boot flag
authorBrian C. Lane <bcl@redhat.com>
Wed, 1 Feb 2012 21:11:59 +0000 (13:11 -0800)
committerJim Meyering <meyering@redhat.com>
Thu, 2 Feb 2012 15:01:32 +0000 (16:01 +0100)
* tests/t0209-gpt-pmbr_boot.sh: New test
* tests/Makefile.am: Add new test
* NEWS: Add information about the GPT PMBR pmbr_boot flag

NEWS
tests/Makefile.am
tests/t0209-gpt-pmbr_boot.sh [new file with mode: 0755]

diff --git a/NEWS b/NEWS
index 484034b..0bfcf6a 100644 (file)
--- a/NEWS
+++ b/NEWS
@@ -79,6 +79,23 @@ GNU parted NEWS                                    -*- outline -*-
   this patch, parted and dmraid will both create duplicate partition devices
   named /dev/mapper/foo1 and /dev/mapper/foop1.
 
+  Add the ability to set the boot flag on the GPT PMBR. This is needed
+  for some BIOS systems that refuse to boot from GPT unless this is set.
+  disk_set and disk_toggle commands can be used to set the pmbr_boot
+  flag on the disk.
+
+  The flag is also displayed in a new line, 'Disk Flags:' like this:
+
+    Model:  (file)
+    Disk /home/bcl/disk.img: 4295MB
+    Sector size (logical/physical): 512B/512B
+    Partition Table: gpt
+    Disk Flags: pmbr_boot
+
+  Using -m the flags are added after the model name field:
+
+    /root/disk.img:4295MB:file:512:512:gpt::pmbr_boot;
+
 ** Build-related
 
   "make dist" no longer builds .tar.gz files.
index 17486e2..a7a1633 100644 (file)
@@ -20,6 +20,7 @@ TESTS = \
   t0206-gpt-print-with-corrupt-primary-clobbers-pmbr.sh \
   t0207-IEC-binary-notation.sh \
   t0208-mkpart-end-in-IEC.sh \
+  t0209-gpt-pmbr_boot.sh \
   t0210-gpt-resized-partition-entry-array.sh \
   t0211-gpt-rewrite-header.sh \
   t0212-gpt-many-partitions.sh \
diff --git a/tests/t0209-gpt-pmbr_boot.sh b/tests/t0209-gpt-pmbr_boot.sh
new file mode 100755 (executable)
index 0000000..b15cc9c
--- /dev/null
@@ -0,0 +1,38 @@
+#!/bin/sh
+# Ensure that pmbr_boot flag can be set
+
+# Copyright (C) 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 <http://www.gnu.org/licenses/>.
+
+. "${srcdir=.}/init.sh"; path_prepend_ ../parted
+
+N=2M
+dev=loop-file
+# create a file large enough to hold a GPT partition table
+dd if=/dev/null of=$dev bs=1 seek=$N || framework_failure
+
+# create a GPT partition table
+parted -s $dev mklabel gpt > out 2>&1 || fail=1
+# expect no output
+compare out /dev/null || fail=1
+
+# Set the pmbr_boot flag on the PMBR
+parted -s $dev disk_set pmbr_boot on
+
+# Check to see if the flag is set
+parted -m -s $dev u s p > out 2> err || fail=1
+grep "$dev:.*:gpt::pmbr_boot;" out || { cat out; fail=1; }
+
+Exit $fail