[Parted-commits] GNU Parted Official Repository: Changes to 'master'

Jim Meyering meyering at alioth.debian.org
Tue Feb 9 20:50:17 UTC 2010


 NEWS                                  |    7 ++++
 gnulib                                |    2 -
 libparted/labels/gpt.c                |   10 ++++-
 tests/Makefile.am                     |    1 
 tests/t0205-gpt-list-clobbers-pmbr.sh |   59 ++++++++++++++++++++++++++++++++++
 5 files changed, 75 insertions(+), 4 deletions(-)

New commits:
commit 7e1d447e000dd574333a1c9ca07a42e8e0ba4d8e
Author: Jim Meyering <meyering at redhat.com>
Date:   Sun Feb 7 20:22:53 2010 +0100

    build: update gnulib submodule to latest

diff --git a/gnulib b/gnulib
index 4c52807..1d27f2a 160000
--- a/gnulib
+++ b/gnulib
@@ -1 +1 @@
-Subproject commit 4c52807f41f238cf0e352317b2dc54f9ba0f0c4f
+Subproject commit 1d27f2ae7983295480d2313d3b2a631f9962840a

commit 927693992b6655d99faa88f550872b0ad8000e99
Author: Jim Meyering <meyering at redhat.com>
Date:   Tue Feb 9 12:32:36 2010 +0100

    doc: NEWS: mention the install-related bug fix
    
    * NEWS (Bug fixes): Mention the fix.

diff --git a/NEWS b/NEWS
index 7b4994d..e6a491c 100644
--- a/NEWS
+++ b/NEWS
@@ -7,6 +7,8 @@ GNU parted NEWS                                    -*- outline -*-
   gpt: read-only operation could clobber MBR part of hybrid GPT+MBR table
   [bug introduced in parted-2.1]
 
+  "make install" no longer installs tests programs named disk and label
+
 
 * Noteworthy changes in release 2.1 (2009-12-20) [stable]
 

commit 28be933ce317f954be1e39a50d8f42197d6e3c15
Author: Jim Meyering <meyering at redhat.com>
Date:   Sun Feb 7 20:31:11 2010 +0100

    gpt: read-only operation could clobber MBR part of hybrid GPT+MBR table
    
    * libparted/labels/gpt.c (gpt_read): Fix a bug introduced by me in
    commit 7f753b1b, "gpt: rewrite GPT header-reading code".
    Set write_back=0 in one more code path.
    * tests/Makefile.am (TESTS): Add t0205-gpt-list-clobbers-pmbr.sh.
    * tests/t0205-gpt-list-clobbers-pmbr.sh: New test.
    * NEWS (Bug fixes): Mention this.
    Reported by aix27249 in
    http://parted.alioth.debian.org/cgi-bin/trac.cgi/ticket/250

diff --git a/NEWS b/NEWS
index ea6caa1..7b4994d 100644
--- a/NEWS
+++ b/NEWS
@@ -2,6 +2,11 @@ GNU parted NEWS                                    -*- outline -*-
 
 * Noteworthy changes in release ?.? (????-??-??) [?]
 
+** Bug fixes
+
+  gpt: read-only operation could clobber MBR part of hybrid GPT+MBR table
+  [bug introduced in parted-2.1]
+
 
 * Noteworthy changes in release 2.1 (2009-12-20) [stable]
 
diff --git a/libparted/labels/gpt.c b/libparted/labels/gpt.c
index 9d9876c..ea96a3b 100644
--- a/libparted/labels/gpt.c
+++ b/libparted/labels/gpt.c
@@ -4,7 +4,7 @@
     original version by Matt Domsch <Matt_Domsch at dell.com>
     Disclaimed into the Public Domain
 
-    Portions Copyright (C) 2001-2003, 2005-2009 Free Software Foundation, Inc.
+    Portions Copyright (C) 2001-2003, 2005-2010 Free Software Foundation, Inc.
 
     EFI GUID Partition Table handling
     Per Intel EFI Specification v1.02
@@ -932,9 +932,9 @@ gpt_read (PedDisk *disk)
   if (primary_gpt && backup_gpt)
     {
       /* Both are valid.  */
+#ifndef DISCOVER_ONLY
       if (PED_LE64_TO_CPU (primary_gpt->AlternateLBA) < disk->dev->length - 1)
         {
-#ifndef DISCOVER_ONLY
           switch (ped_exception_throw
                   (PED_EXCEPTION_ERROR,
                    (PED_EXCEPTION_FIX | PED_EXCEPTION_CANCEL
@@ -954,8 +954,12 @@ gpt_read (PedDisk *disk)
               write_back = 0;
               break;
             }
-#endif /* !DISCOVER_ONLY */
         }
+      else
+	{
+	  write_back = 0;
+	}
+#endif /* !DISCOVER_ONLY */
       gpt = primary_gpt;
       pth_free (backup_gpt);
     }
diff --git a/tests/Makefile.am b/tests/Makefile.am
index 7bfb22e..38922f6 100644
--- a/tests/Makefile.am
+++ b/tests/Makefile.am
@@ -9,6 +9,7 @@ TESTS = \
   t0200-gpt.sh \
   t0201-gpt.sh \
   t0202-gpt-pmbr.sh \
+  t0205-gpt-list-clobbers-pmbr.sh \
   t0220-gpt-msftres.sh \
   t0250-gpt.sh \
   t0280-gpt-corrupt.sh \
diff --git a/tests/t0205-gpt-list-clobbers-pmbr.sh b/tests/t0205-gpt-list-clobbers-pmbr.sh
new file mode 100644
index 0000000..979a15e
--- /dev/null
+++ b/tests/t0205-gpt-list-clobbers-pmbr.sh
@@ -0,0 +1,59 @@
+#!/bin/sh
+# Ensure that printing a GPT partition table does not modify the pMBR.
+# Due to a bug in parted-2.1, "parted /dev/... print" would do just that.
+# Not a problem for most, but if you have a hybrid, e.g., gptsync'd
+# GPT/MBR table, merely listing the table with Parted-2.1 would clobber
+# the MBR part.
+
+# Copyright (C) 2010 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/>.
+
+if test "$VERBOSE" = yes; then
+  set -x
+  parted --version
+fi
+
+: ${srcdir=.}
+. $srcdir/t-lib.sh
+
+fail=0
+
+ss=$sector_size_
+n_sectors=400
+dev=dev-file
+
+dd if=/dev/null of=$dev bs=$ss seek=$n_sectors || fail=1
+parted -s $dev mklabel gpt                     || fail=1
+parted -s $dev mkpart p1 101s 150s             || fail=1
+parted -s $dev mkpart p2 151s 200s             || fail=1
+parted -s $dev mkpart p3 201s 250s             || fail=1
+
+parted -m -s $dev u s p                        || fail=1
+
+# Write non-NUL bytes all over the MBR, so we're likely to see any change.
+# However, be careful to leave the type of the first partition, 0xEE,
+# as well as the final two magic bytes.
+printf '%0450d\xee%059d\x55\xaa' 0 0 | dd of=$dev count=1 conv=notrunc || fail=1
+
+dd if=$dev of=before count=1 || fail=1
+
+chmod a-w $dev
+parted -m -s $dev u s p || fail=1
+
+dd if=$dev of=after count=1 || fail=1
+
+cmp before after || fail=1
+
+Exit $fail



More information about the Parted-commits mailing list