[PATCH 2/2] When a partition changes name, update protectedPartitions (#497087)

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

 



I envisioned this while working on a fix for bug 496638 (as that fix
has the same issues), I haven't actually tried this, but
it is pretty clear this will be a real problem.

Steps to Reproduce:
1. Do an install with hd media, with the media being
   a logical partition for example sda6
2. Choose custom partitioning remove sda5
3. Now sda6 has become sda5 and thus can be happily edited

This patch fixes this as follows, when a partition changes name check
protecedPartitions for the old name and replace it with the new name if
necessary. This is done in Partition.updateName().
---
 storage/devices.py      |   23 ++++++++++++++++++++---
 storage/partitioning.py |    2 +-
 2 files changed, 21 insertions(+), 4 deletions(-)

diff --git a/storage/devices.py b/storage/devices.py
index 53c3d83..a2aa97c 100644
--- a/storage/devices.py
+++ b/storage/devices.py
@@ -1056,13 +1056,30 @@ class PartitionDevice(StorageDevice):
         else:
             StorageDevice.updateSysfsPath(self)
 
-    def updateName(self):
+    def updateName(self, storage=None):
         if self.partedPartition is None:
-            self._name = self.req_name
+            new_name = self.req_name
         else:
-            self._name = \
+            new_name = \
                 devicePathToName(self.partedPartition.getDeviceNodeName())
 
+        # If our name changed check if we are part of protectedPartitions
+        # or immutableDevices and update our name there.
+        if storage:
+            for i in range(len(storage.protectedPartitions)):
+                if storage.protectedPartitions[i] == self._name:
+                    storage.protectedPartitions[i] = new_name
+            # Why do we have this in 2 places ??
+            for i in range(len(storage.devicetree.protectedPartitions)):
+                if storage.devicetree.protectedPartitions[i] == self._name:
+                    storage.devicetree.protectedPartitions[i] = new_name
+
+            for i in range(len(storage.devicetree.immutableDevices)):
+                if storage.devicetree.immutableDevices[i][0] == self._name:
+                    storage.devicetree.immutableDevices[i][0] = new_name
+
+        self._name = new_name
+
     def dependsOn(self, dep):
         """ Return True if this device depends on dep. """
         if isinstance(dep, PartitionDevice) and dep.isExtended and self.isLogical:
diff --git a/storage/partitioning.py b/storage/partitioning.py
index 663d1f1..a9dffe5 100644
--- a/storage/partitioning.py
+++ b/storage/partitioning.py
@@ -572,7 +572,7 @@ def doPartitioning(storage, exclusiveDisks=None):
         # needed because of XXX hack below
         if part.isExtended:
             continue
-        part.updateName()
+        part.updateName(storage)
 
     # XXX hack -- if we created any extended partitions we need to add
     #             them to the tree now
-- 
1.6.2

_______________________________________________
Anaconda-devel-list mailing list
Anaconda-devel-list@xxxxxxxxxx
https://www.redhat.com/mailman/listinfo/anaconda-devel-list

[Index of Archives]     [Kickstart]     [Fedora Users]     [Fedora Legacy List]     [Fedora Maintainers]     [Fedora Desktop]     [Fedora SELinux]     [Big List of Linux Books]     [Yosemite News]     [Yosemite Photos]     [KDE Users]     [Fedora Tools]
  Powered by Linux