[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]

[PATCH] Clear partitions' metadata when 'clearpart --initlabel' used. (#783841)



---
 pyanaconda/storage/devicetree.py   |   26 +-------------------------
 pyanaconda/storage/partitioning.py |   11 +++++++----
 2 files changed, 8 insertions(+), 29 deletions(-)

diff --git a/pyanaconda/storage/devicetree.py b/pyanaconda/storage/devicetree.py
index 9400539..25331c2 100644
--- a/pyanaconda/storage/devicetree.py
+++ b/pyanaconda/storage/devicetree.py
@@ -1114,27 +1114,6 @@ class DeviceTree(object):
                 pass
             return
 
-        # if the disk contains protected partitions we will not wipe the
-        # disklabel even if clearpart --initlabel was specified
-        if not self.clearPartDisks or device.name in self.clearPartDisks:
-            initlabel = self.reinitializeDisks
-            sysfs_path = udev_device_get_sysfs_path(info)
-            for protected in self.protectedDevNames:
-                # check for protected partition
-                _p = "/sys/%s/%s" % (sysfs_path, protected)
-                if os.path.exists(os.path.normpath(_p)):
-                    initlabel = False
-                    break
-
-                # check for protected partition on a device-mapper disk
-                disk_name = re.sub(r'p\d+$', '', protected)
-                if disk_name != protected and disk_name == device.name:
-                    initlabel = False
-                    break
-        else:
-            initlabel = False
-
-
         if self._cleanup:
             initcb = lambda: False
         elif self.zeroMbr:
@@ -1158,13 +1137,10 @@ class DeviceTree(object):
         labelType = self.platform.bestDiskLabelType(device)
 
         try:
-            # XXX if initlabel is True we don't ever instantiate a format
-            #     for the original disklabel, so we will only have a
-            #     DeviceFormat instance to destroy.
             format = getFormat("disklabel",
                                device=device.path,
                                labelType=labelType,
-                               exists=not initlabel)
+                               exists=True)
         except InvalidDiskLabelError:
             # if we have a cb function use it. else we ignore the device.
             if initcb is not None and initcb():
diff --git a/pyanaconda/storage/partitioning.py b/pyanaconda/storage/partitioning.py
index b00d5a4..49faa78 100644
--- a/pyanaconda/storage/partitioning.py
+++ b/pyanaconda/storage/partitioning.py
@@ -511,13 +511,16 @@ def clearPartitions(storage, bootloader=None):
     # now remove any empty extended partitions
     removeEmptyExtendedPartitions(storage)
 
-    # make sure that the the boot device has the correct disklabel type if
-    # we're going to completely clear it.
+    # make sure that the the boot device, along with any other disk we are
+    # supposed to reinitialize, has the correct disklabel type if we're going
+    # to completely clear it.
+    boot_drive = getattr(bootloader, "stage1_drive", None)
     for disk in storage.partitioned:
-        if not bootloader or not bootloader.stage1_drive:
+        if not boot_drive and not storage.config.reinitializeDisks:
             break
 
-        if disk != bootloader.stage1_drive:
+        if not storage.config.reinitializeDisks and \
+           (boot_drive is not None and disk != boot_drive):
             continue
 
         if storage.config.clearPartType != CLEARPART_TYPE_ALL or \
-- 
1.7.8.4


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]