[PATCH 1/3] Add function storage.udev.udev_resolve_devspec.

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

 



This function resolves an arbitrary device specification (name, path, uuid,
or label) to a device name. It returns None if there is a failure.
---
 storage/udev.py |   21 +++++++++++++++++++++
 1 files changed, 21 insertions(+), 0 deletions(-)

diff --git a/storage/udev.py b/storage/udev.py
index 5c17a34..ebd2f27 100644
--- a/storage/udev.py
+++ b/storage/udev.py
@@ -29,6 +29,27 @@ from errors import *
 import logging
 log = logging.getLogger("storage")
 
+def udev_resolve_devspec(devspec):
+    if not devspec:
+        return None
+
+    ret = None
+    for dev in udev_get_block_devices():
+        if devspec.startswith("LABEL="):
+            if udev_device_get_label(dev) == devspec[6:]:
+                ret = dev
+                break
+        elif devspec.startswith("UUID="):
+            if udev_device_get_uuid(dev) == devspec[5:]:
+                ret = dev
+                break
+        else:
+            if udev_device_get_name(dev) == os.path.basename(devspec):
+                ret = dev
+                break
+
+    if ret:
+        return udev_device_get_name(dev)
 
 def udev_get_block_devices():
     udev_settle(timeout=30)
-- 
1.6.0.6

_______________________________________________
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