OSDN Git Service

libparted: avoid unwarranted failed assertion during mklabel
authorJim Meyering <meyering@redhat.com>
Sun, 26 Feb 2012 17:04:37 +0000 (18:04 +0100)
committerJim Meyering <meyering@redhat.com>
Sun, 26 Feb 2012 17:04:37 +0000 (18:04 +0100)
This could happen when running "parted -s $dev mklabel $type" for
nearly any $type, assuming the underlying disk's sector size is
larger than 512 bytes.  This particular failure was noticed by
running tests/t9050-partition-table-types.sh with a simulated
sector size of 1024, as is done as part of a top-level "make check",
but so far, this failure has shown up only on RHEL-6.2.
That test attempts to exercise an ugly part of partition table
creation: during creation, parted checks for an existing
partition table by iterating through its list of known types and
attempting to read the disk, looking for a preexisting table.
Knowing this, the test takes all pairs of partition table types,
<A,B> and first creates a type of type A, and then creates on top
of that (erasing the original) a table of type B.
* libparted/labels/mac.c (_disk_analyse_ghost_size): Remove bogus
assertion.  If the number of the sector with a matching signature
is too large, simply reject it by returning 0.
* NEWS (Bug fixes): Mention this.

NEWS
libparted/labels/mac.c

diff --git a/NEWS b/NEWS
index fc93e98..50d9126 100644 (file)
--- a/NEWS
+++ b/NEWS
@@ -71,6 +71,9 @@ GNU parted NEWS                                    -*- outline -*-
   of partitions the device can hold.  With this change, parted now correctly
   informs kernel about new partitions on partitionable MD RAID devices.
 
+  libparted: creating a new partition table on a device with an existing
+  mac partition table could result in a failed assertion.
+
 ** Changes in behavior
 
   Floppy drives are no longer scanned on linux: they cannot be partitioned
index 41ea398..1f59a1a 100644 (file)
@@ -704,8 +704,7 @@ _disk_analyse_ghost_size (PedDisk* disk)
                if (_rawpart_check_signature (buf)
                    && !_rawpart_is_void (buf)) {
                        mac_disk_data->ghost_size = i;
-                       PED_ASSERT (i <= disk->dev->sector_size / 512);
-                       found = 1;
+                       found = (i <= disk->dev->sector_size / 512);
                        break;
                }
        }