[PATCH 2/3] Collect DASD kernel parameter information during device tree scan (#526354).

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

 



Expand the DASDDevice class to hold the device bus ID and flags that are
passed at boot time.  Add udev functions to return the bus ID and flag
values for DASD devices.  When building the device tree, read the DASD
information and pass that to the DASDDevice object.
---
 storage/devices.py    |    9 ++++-----
 storage/devicetree.py |   10 ++++++++++
 storage/udev.py       |   30 ++++++++++++++++++++++++++++++
 3 files changed, 44 insertions(+), 5 deletions(-)

diff --git a/storage/devices.py b/storage/devices.py
index 5f9d068..7d31b26 100644
--- a/storage/devices.py
+++ b/storage/devices.py
@@ -3156,11 +3156,10 @@ class DASDDevice(DiskDevice):
     """ A mainframe DASD. """
     _type = "dasd"
 
-    def __init__(self, device, size=None, major=None, minor=None,
-                 parents=None, sysfsPath=''):
-        DiskDevice.__init__(self, device, size=size,
-                            major=major, minor=minor,
-                            parents=parents, sysfsPath=sysfsPath)
+    def __init__(self, device, **kwargs):
+        self.busid = kwargs.get('busid')
+        self.opts = kwargs.get('opts')
+        DiskDevice.__init__(self, device, kwargs)
 
 
 class NFSDevice(StorageDevice, NetworkStorageDevice):
diff --git a/storage/devicetree.py b/storage/devicetree.py
index d355804..cff7591 100644
--- a/storage/devicetree.py
+++ b/storage/devicetree.py
@@ -1192,6 +1192,16 @@ class DeviceTree(object):
             kwargs["exists"]  = True
         elif udev_device_is_dasd(info):
             diskType = DASDDevice
+            kwargs["busid"] = udev_device_get_dasd_bus_id(info)
+            kwargs["opts"] = {"ro": udev_device_get_dasd_flag(info,
+                                                              "readonly"),
+                              "diag": udev_device_get_dasd_flag(info,
+                                                                "use_diag"),
+                              "erplog": udev_device_get_dasd_flag(info,
+                                                                  "erplog"),
+                              "failfast": udev_device_get_dasd_flag(info,
+                                                                    "failfast")
+                             }
             log.debug("%s is a dasd device" % name)
         else:
             diskType = DiskDevice
diff --git a/storage/udev.py b/storage/udev.py
index d051157..aeb9062 100644
--- a/storage/udev.py
+++ b/storage/udev.py
@@ -165,6 +165,36 @@ def udev_device_is_dasd(info):
     else:
         return False
 
+def udev_device_get_dasd_bus_id(info):
+    """ Return the CCW bus ID of the dasd device. """
+    ccwdevices = "/sys/bus/ccw/devices"
+
+    if not os.path.isdir(ccwdevices):
+        return None
+
+    for busid in os.listdir(ccwdevices):
+        if info.get("DEVTYPE") != "disk":
+            continue
+
+        buspath = "%s/%s/block/%s" % (ccwdevices, busid, info.get("DEVNAME"),)
+        dasd = os.path.realpath(buspath)
+
+        if os.path.isdir(dasd):
+            return busid
+
+    return None
+
+def udev_device_get_dasd_flag(info, flag=None):
+    """ Return the specified flag for the dasd device. """
+    if flag is None:
+        return None
+
+    path = "/sys" + info.get("sysfs_path") + "/device/" + flag
+    if not os.path.isfile(path):
+        return None
+
+    return bool(open(path, 'r').read().strip())
+
 def udev_device_is_cdrom(info):
     """ Return True if the device is an optical drive. """
     # FIXME: how can we differentiate USB drives from CD-ROM drives?
-- 
1.6.2.5

_______________________________________________
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