[PATCH 2/3] Add a function that determines which devices match a given shell glob.

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

 



This is handy for large configurations so you can specify:

    clearpart --drives=sda?

Instead of:

    clearpart --drives=sdaa,sdab,sdac,sdad,sdae,sdaf,...

All shell globs are supported here, and all the DEVLINKS are checked against
the glob.  This means you can use /dev/disk/by-path paths without knowing
the whole big thing.
---
 storage/udev.py |   19 +++++++++++++++++++
 1 files changed, 19 insertions(+), 0 deletions(-)

diff --git a/storage/udev.py b/storage/udev.py
index a29ddba..6351b22 100644
--- a/storage/udev.py
+++ b/storage/udev.py
@@ -57,6 +57,25 @@ def udev_resolve_devspec(devspec):
     if ret:
         return udev_device_get_name(ret)
 
+def udev_resolve_glob(glob):
+    import fnmatch
+    ret = []
+
+    if not glob:
+        return ret
+
+    for dev in udev_get_block_devices():
+        name = udev_device_get_name(dev)
+
+        if fnmatch.fnmatch(name, glob):
+            ret.append(name)
+        else:
+            for link in dev["symlinks"]:
+                if fnmatch.fnmatch("/dev/" + link, glob):
+                    ret.append(name)
+
+    return ret
+
 def udev_get_block_devices():
     udev_settle(timeout=30)
     entries = []
-- 
1.6.5.1

_______________________________________________
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