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

[PATCH] In the filter UI, also ignore devices that do not report a size (#594803).



We need to throw these devices out of the list before testing whether to display
the filter UI or not.  Otherwise, these devices will make the filter UI appear
but will not be included in the overall count so it will appear that there's no
point in having the UI displayed.

With this fix, we can remove the later CCISS size check.

Based on a patch from notting.
---
 iutil.py         |   14 ++++++++++++++
 iw/filter_gui.py |   15 +++++++++++----
 2 files changed, 25 insertions(+), 4 deletions(-)

diff --git a/iutil.py b/iutil.py
index a568ff7..52eb204 100644
--- a/iutil.py
+++ b/iutil.py
@@ -1058,3 +1058,17 @@ def parseNfsUrl(nfsurl):
         else:
             host = s[0]
     return (options, host, path)
+
+def get_sysfs_attr(path, attr):
+    if not attr:
+        log.debug("get_sysfs_attr() called with attr=None")
+        return None
+
+    attribute = "/sys%s/%s" % (path, attr)
+    attribute = os.path.realpath(attribute)
+
+    if not os.path.isfile(attribute):
+        log.warning("%s is not a valid attribute" % (attribute,))
+        return None
+
+    return open(attribute, "r").read().strip()
diff --git a/iw/filter_gui.py b/iw/filter_gui.py
index a85cd1f..9cf843a 100644
--- a/iw/filter_gui.py
+++ b/iw/filter_gui.py
@@ -23,6 +23,7 @@ import collections
 import gtk, gobject
 import gtk.glade
 import gui
+import iutil
 import parted
 import _ped
 from DeviceSelector import *
@@ -398,6 +399,15 @@ class NotebookPage(object):
 class FilterWindow(InstallWindow):
     windowTitle = N_("Device Filter")
 
+    def _device_size_is_nonzero(self, info):
+        path = udev_device_get_sysfs_path(info)
+        size = iutil.get_sysfs_attr(path, "size")
+
+        if not size:
+            return False
+
+        return True
+
     def getNext(self):
         # All pages use the same store, so we only need to use the first one.
         # However, we do need to make sure all paths from multipath devices
@@ -572,6 +582,7 @@ class FilterWindow(InstallWindow):
         # The device list could be really long, so we really only want to
         # iterate over it the bare minimum of times.  Dividing this list up
         # now means fewer elements to iterate over later.
+        singlepaths = filter(lambda info: self._device_size_is_nonzero(info), singlepaths)
         (raids, nonraids) = self.split_list(lambda d: isRAID(d) and not isCCISS(d),
                                             singlepaths)
 
@@ -676,10 +687,6 @@ class FilterWindow(InstallWindow):
             except (_ped.IOException, _ped.DeviceException):
                 continue
             d["XXX_SIZE"] = int(partedDevice.getSize())
-            # cciss controllers, without any sets defined, show up as a 0 size
-            # blockdev, ignore these
-            if d["XXX_SIZE"] == 0:
-                continue
 
             # This isn't so great, but iSCSI and s390 devices have an ID_PATH
             # that contains a lot of useful identifying info, so that should be
-- 
1.7.0.1


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