Re: [PATCH 3/4] Make deviceNameToDiskByPath check udev info instead of sysfs

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

 



Hi,

On 05/04/2010 06:46 AM, David Cantrell wrote:
Rather than scanning /dev/disk/by-path directly, check the udev database
for the PATH_ID or ID_PATH or whatever it's called that gives us the
devlink name that would appear in /dev/disk/by-path.  Sometimes the
links in /dev/disk/by-path do not appear because you have them already
in /dev/disk/by-id (or not, who knows?).  At any rate, stop checking the
/dev/disk/by-path directory manually and just ask udev.

Related: rhbz#560702

Hmm,

This makes deviceNameToDiskByPath use
udev_get_block_devices(), which does a udev_settle() and
a "modprobe scsi_wait_scan". Maybe we should give
udev_get_block_devices() a settle parameter which defaults to
True, and pass in False here ?

But that is something for another patch I guess. ACK.

Regards,

Hans


---
  storage/devices.py |   24 ++++++------------------
  1 files changed, 6 insertions(+), 18 deletions(-)

diff --git a/storage/devices.py b/storage/devices.py
index 399802b..5761d05 100644
--- a/storage/devices.py
+++ b/storage/devices.py
@@ -147,28 +147,16 @@ def devicePathToName(devicePath):


  def deviceNameToDiskByPath(deviceName=None):
-    bypath = '/dev/disk/by-path'
-
      if not deviceName:
          return ""
+    else:
+        deviceName = os.path.basename(deviceName)

-    if not os.path.isdir(bypath):
-        return ""
-
-    deviceName = os.path.basename(deviceName)
-
-    for path in os.listdir(bypath):
-        entry = bypath + '/' + path
-
-        if os.path.islink(entry):
-            target = os.path.basename(os.readlink(entry))
-        else:
-            target = os.path.basename(entry)
-
-        if target == deviceName:
-            return entry
+    for dev in udev_get_block_devices():
+        if udev_device_get_name(dev) == deviceName:
+            return udev_device_get_path(dev)

-    return ""
+    return deviceName


  class Device(object):

_______________________________________________
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