Most sysfs path handling code expects / uses sysfs path's without the /sys prefix (as udev does internally). There were 4 functions which were exceptions to this: udev_enumerate_devices udev_enumerate_block_devices udev_get_device udev_get_block_device These expected resp. returned sysfs path's with /sys prefix. This inconsistency causes the backtrace in bug 516168. Rather then applying a simple fix for this, this patch makes the sysfs path usage consistent everywhere, to avoid issues like this in the future. This patch adjust the above 4 functions and all callers. --- baseudev.py | 9 ++++----- isys/isys.py | 2 +- livecd.py | 2 +- storage/deviceaction.py | 2 +- storage/devices.py | 2 +- storage/devicetree.py | 7 +++---- 6 files changed, 11 insertions(+), 13 deletions(-) diff --git a/baseudev.py b/baseudev.py index f441bce..af63c76 100644 --- a/baseudev.py +++ b/baseudev.py @@ -35,15 +35,15 @@ def udev_enumerate_devices(deviceClass="block"): link_ref = os.readlink(full_path) real_path = os.path.join(top_dir, link_ref) sysfs_path = os.path.normpath(real_path) - devices.append(sysfs_path) + devices.append(sysfs_path[4:]) return devices def udev_get_device(sysfs_path): - if not os.path.exists(sysfs_path): + if not os.path.exists("/sys%s" % sysfs_path): log.debug("%s does not exist" % sysfs_path) return None - db_entry = sysfs_path[4:].replace("/", "\\x2f") + db_entry = sysfs_path.replace("/", "\\x2f") db_root = "/dev/.udev/db" db_path = os.path.normpath("%s/%s" % (db_root, db_entry)) if not os.access(db_path, os.R_OK): @@ -53,8 +53,7 @@ def udev_get_device(sysfs_path): entry = open(db_path).read() dev = udev_parse_entry(entry) if dev.has_key("name"): - # XXX why do we do this? is /sys going to move during installation? - dev['sysfs_path'] = sysfs_path[4:] # strip off the leading '/sys' + dev['sysfs_path'] = sysfs_path dev = udev_parse_uevent_file(dev) # now add in the contents of the uevent file since they're handy diff --git a/isys/isys.py b/isys/isys.py index 13ba807..79959d0 100755 --- a/isys/isys.py +++ b/isys/isys.py @@ -599,7 +599,7 @@ def getNetDevDesc(dev): if dev == device_props['Interface']: # This is the sysfs path (for now). udev_path = device_props['Udi'] - dev = udev_get_device(udev_path) + dev = udev_get_device(udev_path[4:]) if dev is None: log.debug("weird, we have a None dev with path %s" % path) diff --git a/livecd.py b/livecd.py index bb3abc7..d8b2f0b 100644 --- a/livecd.py +++ b/livecd.py @@ -246,7 +246,7 @@ class LiveCDCopyBackend(backend.AnacondaBackend): iutil.notify_kernel("/sys%s" %rootDevice.sysfsPath) storage.udev.udev_settle() rootDevice.updateSysfsPath() - info = storage.udev.udev_get_block_device("/sys%s" % rootDevice.sysfsPath) + info = storage.udev.udev_get_block_device(rootDevice.sysfsPath) rootDevice.format.uuid = storage.udev.udev_device_get_uuid(info) log.info("reset the rootdev (%s) to have a uuid of %s" %(rootDevice.sysfsPath, rootDevice.format.uuid)) diff --git a/storage/deviceaction.py b/storage/deviceaction.py index 61e9aa4..838b500 100644 --- a/storage/deviceaction.py +++ b/storage/deviceaction.py @@ -274,7 +274,7 @@ class ActionCreateFormat(DeviceAction): # Get the UUID now that the format is created udev_settle() self.device.updateSysfsPath() - info = udev_get_block_device("/sys%s" % self.device.sysfsPath) + info = udev_get_block_device(self.device.sysfsPath) self.device.format.uuid = udev_device_get_uuid(info) def cancel(self): diff --git a/storage/devices.py b/storage/devices.py index 3073a1d..3b4de0b 100644 --- a/storage/devices.py +++ b/storage/devices.py @@ -2591,7 +2591,7 @@ class MDRaidArrayDevice(StorageDevice): self.setup() udev_settle() self.updateSysfsPath() - info = udev_get_block_device("/sys%s" % self.sysfsPath) + info = udev_get_block_device(self.sysfsPath) self.uuid = udev_device_get_md_uuid(info) for member in self.devices: member.mdUuid = self.uuid diff --git a/storage/devicetree.py b/storage/devicetree.py index 02fc40e..0dec5e0 100644 --- a/storage/devicetree.py +++ b/storage/devicetree.py @@ -972,7 +972,7 @@ class DeviceTree(object): else: # we haven't scanned the slave yet, so do it now path = os.path.normpath("%s/%s" % (dir, slave_name)) - new_info = udev_get_block_device(os.path.realpath(path)) + new_info = udev_get_block_device(os.path.realpath(path)[4:]) if new_info: self.addUdevDevice(new_info) if self.getDeviceByName(dev_name) is None: @@ -1034,7 +1034,7 @@ class DeviceTree(object): else: # we haven't scanned the slave yet, so do it now path = os.path.normpath("%s/%s" % (dir, slave_name)) - new_info = udev_get_block_device(os.path.realpath(path)) + new_info = udev_get_block_device(os.path.realpath(path)[4:]) if new_info: self.addUdevDevice(new_info) if self.getDeviceByName(dev_name) is None: @@ -1083,8 +1083,7 @@ class DeviceTree(object): if disk is None: # create a device instance for the disk - path = os.path.dirname(os.path.realpath(sysfs_path)) - new_info = udev_get_block_device(path) + new_info = udev_get_block_device(os.path.dirname(sysfs_path)) if new_info: self.addUdevDevice(new_info) disk = self.getDeviceByName(disk_name) -- 1.6.2.2 _______________________________________________ Anaconda-devel-list mailing list Anaconda-devel-list@xxxxxxxxxx https://www.redhat.com/mailman/listinfo/anaconda-devel-list