Re: [PATCH 3/7] Make storage.devices.deviceNameToDiskByPath() more robust.

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

 



Ack


On 10/08/2009 09:28 AM, David Cantrell wrote:
Have deviceNameToDiskByPath() return the full device path rather than
just the basename path.  Have it check to see if the entry in
/dev/disk/by-path is actually a symlink, then readlink that.  Otherwise
just take the basename of the entry.  Also fix a problem where passing
it a full device path would not match (e.g., '/dev/dasdb1').  Take the
basename of deviceName and match that against the readlink() value.
---
  storage/devices.py |   12 ++++++++++--
  1 files changed, 10 insertions(+), 2 deletions(-)

diff --git a/storage/devices.py b/storage/devices.py
index 348d2fd..9d257e2 100644
--- a/storage/devices.py
+++ b/storage/devices.py
@@ -154,10 +154,18 @@ def deviceNameToDiskByPath(deviceName=None):
      if not os.path.isdir(bypath):
          return ""

+    deviceName = os.path.basename(deviceName)
+
      for path in os.listdir(bypath):
-        target = os.path.basename(os.readlink(bypath + '/' + path))
+        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 path
+            return entry

      return ""


_______________________________________________
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