[PATCH 3/7] Include file-backed loop devices in the device tree.

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

 



---
 pyanaconda/storage/devicetree.py |   25 ++++++++++++++++++++++---
 pyanaconda/storage/udev.py       |    5 +++++
 2 files changed, 27 insertions(+), 3 deletions(-)

diff --git a/pyanaconda/storage/devicetree.py b/pyanaconda/storage/devicetree.py
index 6e2bed5..8353f1e 100644
--- a/pyanaconda/storage/devicetree.py
+++ b/pyanaconda/storage/devicetree.py
@@ -574,9 +574,8 @@ class DeviceTree(object):
             return True
 
         if name.startswith("loop"):
-            # ignore loop devices unless they're backed by a disk image file
-            backing_file = devicelibs.loop.get_backing_file(name)
-            return (backing_file not in self.diskImages.values())
+            # ignore loop devices unless they're backed by a file
+            return (not devicelibs.loop.get_backing_file(name))
 
         # FIXME: check for virtual devices whose slaves are on the ignore list
 
@@ -871,6 +870,23 @@ class DeviceTree(object):
         self._addDevice(device)
         return device
 
+    def addUdevLoopDevice(self, info):
+        name = udev_device_get_name(info)
+        log_method_call(self, name=name)
+        sysfs_path = udev_device_get_sysfs_path(info)
+        sys_file = "/sys/%s/loop/backing_file" % sysfs_path
+        backing_file = open(sys_file).read().strip()
+        file_device = self.getDeviceByName(backing_file)
+        if not file_device:
+            file_device = FileDevice(backing_file, exists=True)
+            self._addDevice(file_device)
+        device = LoopDevice(name,
+                            parents=[file_device],
+                            sysfsPath=sysfs_path,
+                            exists=True)
+        self._addDevice(device)
+        return device
+
     def addUdevDevice(self, info):
         name = udev_device_get_name(info)
         log_method_call(self, name=name, info=info)
@@ -909,6 +925,9 @@ class DeviceTree(object):
         if device:
             # we successfully looked up the device. skip to format handling.
             pass
+        elif udev_device_is_loop(info):
+            log.debug("%s is a loop device" % name)
+            device = self.addUdevLoopDevice(info)
         elif udev_device_is_multipath_member(info):
             device = self.addUdevDiskDevice(info)
         elif udev_device_is_dm(info) and udev_device_is_dm_mpath(info):
diff --git a/pyanaconda/storage/udev.py b/pyanaconda/storage/udev.py
index 39be2d7..ce366ed 100644
--- a/pyanaconda/storage/udev.py
+++ b/pyanaconda/storage/udev.py
@@ -260,6 +260,11 @@ def udev_device_is_partition(info):
     has_start = os.path.exists("/sys/%s/start" % info['sysfs_path'])
     return info.get("DEVTYPE") == "partition" or has_start
 
+def udev_device_is_loop(info):
+    """ Return True if the device is a configured loop device. """
+    return (udev_device_get_name(info).startswith("loop") and
+            os.path.isdir("/sys/%s/loop" % info['sysfs_path']))
+
 def udev_device_get_serial(udev_info):
     """ Get the serial number/UUID from the device as reported by udev. """
     return udev_info.get("ID_SERIAL_RAW", udev_info.get("ID_SERIAL_SHORT", udev_info.get("ID_SERIAL")))
-- 
1.7.3.3

_______________________________________________
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