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

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

 



> > +        else:
> > +            if udev_device_get_name(dev) == os.path.basename(devspec):
> > +                ret = dev
> > +                break
> > +
> 
> I believe this should be:
> 
>              if udev_device_get_name(dev) == devices.devicePathToName(devspec):
> 
> Or maybe we should try both ? What is for example the devspec for a
> cciss device is it cciss/c0d0p1 or just c0d0p1, the udev and devicetree name is
> cciss/c0d0p1, so if the devicespec can be a devicetree name we need
> to also compare to devices.devicePathToName(devspec):

I used basename to avoid circular import issues, since udev is imported
by almost every module in storage. Easily enough worked around by
importing devices from inside the function.

The new patch looks like this:

diff --git a/storage/udev.py b/storage/udev.py
index 5c17a34..af3ee12 100644
--- a/storage/udev.py
+++ b/storage/udev.py
@@ -29,6 +29,29 @@ from errors import *
 import logging
 log = logging.getLogger("storage")
 
+def udev_resolve_devspec(devspec):
+    if not devspec:
+        return None
+
+    import devices as _devices
+    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) ==
_devices.devicePathToName(devspec):
+                ret = dev
+                break
+
+    del _devices
+    if ret:
+        return udev_device_get_name(dev)
 
 def udev_get_block_devices():
     udev_settle(timeout=30)



Dave

> 
> 
> 
> > +    if ret:
> > +        return udev_device_get_name(dev)
> >
> >   def udev_get_block_devices():
> >       udev_settle(timeout=30)
> 
> Regards,
> 
> Hans
> 
> _______________________________________________
> Anaconda-devel-list mailing list
> Anaconda-devel-list@xxxxxxxxxx
> https://www.redhat.com/mailman/listinfo/anaconda-devel-list

_______________________________________________
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