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

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



-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

On Tue, 4 May 2010, Hans de Goede wrote:

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.

I'm ok with that, but I'm probably not the best person to implement it as I
don't know what all needs to be included in the 'settle' operation or not.


---
  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):


- -- David Cantrell <dcantrell redhat com>
Red Hat / Honolulu, HI

-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.10 (GNU/Linux)

iEYEARECAAYFAkvgM0EACgkQ5hsjjIy1VknGvgCfb9q1E4L+sVfwD6Vw/8CV4fgS
VDoAoODUYT4RNP9O2BDzkQkJLY048mCG
=WHq0
-----END PGP SIGNATURE-----


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