[rhel6-branch 3/4] Allow DeviceFormat.cacheMajorminor to fail without an exception.

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

 



Think of LVMVolumeGroups for instance that have no major:minor to be
cached.

cherry-pick of 395dd39e3353cf8b403ca08e3b3ccc741391d398

Resolves: rhbz#731973
---
 storage/formats/__init__.py |   20 +++++++++++++++++---
 1 files changed, 17 insertions(+), 3 deletions(-)

diff --git a/storage/formats/__init__.py b/storage/formats/__init__.py
index 6307dcd..e9c904d 100644
--- a/storage/formats/__init__.py
+++ b/storage/formats/__init__.py
@@ -257,7 +257,7 @@ class DeviceFormat(object):
             log.warning("failed to notify kernel of change: %s" % e)
 
     def cacheMajorminor(self):
-        """ Cache the value of self.majorminor. 
+        """ Cache the value of self.majorminor.
 
             Once a device node of this format's device disappears (for instance
             after a teardown), it is no longer possible to figure out the value
@@ -265,7 +265,15 @@ class DeviceFormat(object):
             that happens for caching this.
         """
         self._majorminor = None
-        return self.majorminor # this does the caching
+        try:
+            self.majorminor # this does the caching
+        except StorageError:
+            # entirely possible there's no majorminor, for instance an
+            # LVMVolumeGroup has got no device node and no sysfs path.  In this
+            # case obviously, calling majorminor of this object later raises an
+            # exception.
+            pass
+        return self._majorminor
 
     def create(self, *args, **kwargs):
         log_method_call(self, device=self.device,
@@ -423,7 +431,13 @@ class DeviceFormat(object):
                 device = dm_node_from_name(self.device)
             except DMError:
                 device = self.device
-            sysfs_path = get_sysfs_path_by_name(device)
+
+            try:
+                sysfs_path = get_sysfs_path_by_name(device)
+            except RuntimeError:
+                raise StorageError("DeviceFormat.majorminor: "
+                                   "can not get majorminor for '%s'" % device)
+
             dev = udev_get_device(sysfs_path[4:])
             self._majorminor = "%03d%03d" %\
                 (udev_device_get_major(dev), udev_device_get_minor(dev))
-- 
1.7.6

_______________________________________________
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