[PATCH 1/5] Try to handle devices which live in a subdir of /dev properly

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

 



This hopefully fixes cciss (will test once an anaconda with this in
has hit rawhide, so I can use rhts to test). This is the second version of
this patch, this time it also does the / -> ! translation for sysfs names.
---
 bootloader.py                    |    3 ++-
 iw/partition_gui.py              |    3 ---
 iw/upgrade_bootloader_gui.py     |    3 ++-
 storage/__init__.py              |   13 +++----------
 storage/devices.py               |   17 +++++++++++++++--
 textw/upgrade_bootloader_text.py |    3 ++-
 6 files changed, 24 insertions(+), 18 deletions(-)

diff --git a/bootloader.py b/bootloader.py
index b9d995e..53dba2b 100644
--- a/bootloader.py
+++ b/bootloader.py
@@ -28,6 +28,7 @@ import iutil
 import string
 from flags import flags
 from constants import *
+from storage.devices import devicePathToName
 
 import gettext
 _ = lambda x: gettext.ldgettext("anaconda", x)
@@ -125,7 +126,7 @@ def writeBootloader(anaconda):
         anaconda.id.bootloader.doUpgradeonly = 1
         if bootType == "GRUB":
             anaconda.id.bootloader.useGrubVal = 1
-            anaconda.id.bootloader.setDevice(theDev.split("/")[-1])
+            anaconda.id.bootloader.setDevice(devicePathToName(theDev))
         else:
             anaconda.id.bootloader.doUpgradeOnly = 0    
 
diff --git a/iw/partition_gui.py b/iw/partition_gui.py
index 24559ee..0105ef5 100644
--- a/iw/partition_gui.py
+++ b/iw/partition_gui.py
@@ -139,9 +139,6 @@ class DiskStripeSlice:
         rc = rc + "%Ld MB" % (self.partition.getSize(unit="MB"),)
         return rc
 
-    def getDeviceName(self):
-        return self.partition.getDeviceNodeName().split("/")[-1]
-
     def update(self):
         disk = self.parent.getDisk()
         (cylinders, heads, sectors) = disk.device.biosGeometry
diff --git a/iw/upgrade_bootloader_gui.py b/iw/upgrade_bootloader_gui.py
index 08f2403..f35ce0a 100644
--- a/iw/upgrade_bootloader_gui.py
+++ b/iw/upgrade_bootloader_gui.py
@@ -24,6 +24,7 @@ from iw_gui import *
 
 import gtk
 from booty import checkbootloader
+from storage.devices import devicePathToName
 
 from constants import *
 import gettext
@@ -61,7 +62,7 @@ class UpgradeBootloaderWindow (InstallWindow):
                 self.bl.useGrubVal = 1
             else:
                 self.bl.useGrubVal = 0
-            self.bl.setDevice(self.bootDev.split("/")[-1])
+            self.bl.setDevice(devicePathToName(self.bootDev))
 
     def _newToLibata(self, rootPath):
         # NOTE: any changes here need to be done in upgrade_bootloader_text too
diff --git a/storage/__init__.py b/storage/__init__.py
index 3d3ba15..7a9f93b 100644
--- a/storage/__init__.py
+++ b/storage/__init__.py
@@ -81,16 +81,9 @@ def storageInitialize(anaconda):
             elif devspec.startswith("UUID=") and udev_device_get_uuid(entry) == devspec[5:]:
                 storage.protectedPartitions = [udev_device_get_name(entry)]
                 break
-            else:
-                if devspec.startswith("/dev/"):
-                    dev = devspec[5:]
-                else:
-                    dev = devspec
-
-                name = udev_device_get_name(entry)
-                if name == dev:
-                    storage.protectedPartitions = [name]
-                    break
+            elif udev_device_get_name(entry) == devicePathToName(devspec):
+                storage.protectedPartitions = [udev_device_get_name(entry)]
+                break
 
         storage.reset()
 
diff --git a/storage/devices.py b/storage/devices.py
index f75463f..209ea4f 100644
--- a/storage/devices.py
+++ b/storage/devices.py
@@ -131,6 +131,18 @@ def get_device_majors():
 device_majors = get_device_majors()
 
 
+def devicePathToName(devicePath):
+    if devicePath.startswith("/dev/"):
+        name = devicePath[5:]
+    else:
+        name = devicePath
+
+    if name.startswith("mapper/"):
+        name = name[7:]
+
+    return name
+
+
 class Device(object):
     """ A generic device.
 
@@ -447,7 +459,8 @@ class StorageDevice(Device):
     def updateSysfsPath(self):
         """ Update this device's sysfs path. """
         log_method_call(self, self.name, status=self.status)
-        path = os.path.join("/sys", self.sysfsBlockDir, self.name)
+        sysfsName = self.name.replace("/", "!")
+        path = os.path.join("/sys", self.sysfsBlockDir, sysfsName)
         self.sysfsPath = os.path.realpath(path)[4:]
         log.debug("%s sysfsPath set to %s" % (self.name, self.sysfsPath))
 
@@ -1023,7 +1036,7 @@ class PartitionDevice(StorageDevice):
             # no need to clobber our name
         else:
             self._partedPartition = partition
-            self._name = partition.getDeviceNodeName().split("/")[-1]
+            self._name = devicePathToName(partition.getDeviceNodeName())
 
     partedPartition = property(lambda d: d._getPartedPartition(),
                                lambda d,p: d._setPartedPartition(p))
diff --git a/textw/upgrade_bootloader_text.py b/textw/upgrade_bootloader_text.py
index ab45075..20afec6 100644
--- a/textw/upgrade_bootloader_text.py
+++ b/textw/upgrade_bootloader_text.py
@@ -24,6 +24,7 @@ from constants_text import *
 from flags import flags
 import string
 from booty import checkbootloader
+from storage.devices import devicePathToName
 
 from constants import *
 import gettext
@@ -173,7 +174,7 @@ class UpgradeBootloaderWindow:
                     self.bl.useGrubVal = 1
                 else:
                     self.bl.useGrubVal = 0
-                self.bl.setDevice(self.bootDev.split("/")[-1])
+                self.bl.setDevice(devicePathToName(self.bootDev))
 
 
 
-- 
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