[Date Prev][Date Next] [Thread Prev][Thread Next]
[Thread Index]
[Date Index]
[Author Index]
Re: [PATCH 1/3] Add function storage.udev.udev_resolve_devspec.
- From: David Lehman <dlehman redhat com>
- To: Discussion of Development and Customization of the Red Hat Linux Installer <anaconda-devel-list redhat com>
- Subject: Re: [PATCH 1/3] Add function storage.udev.udev_resolve_devspec.
- Date: Wed, 01 Jul 2009 12:41:48 -0500
> > + 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 redhat com
> https://www.redhat.com/mailman/listinfo/anaconda-devel-list
[Date Prev][Date Next] [Thread Prev][Thread Next]
[Thread Index]
[Date Index]
[Author Index]