Re: [PATCH 2/2] Use libudev's enumerate_devices function (#559394)

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

 



On Thu, 2010-01-28 at 13:31 -1000, David Cantrell wrote:
> From: Martin Gracik <mgracik@xxxxxxxxxx>
> 
> Do not list the directories in sys, but use the libudev's
> enumerate_devices function to get the sysfs paths.  Run /sbin/udevadm
> rather than just udevadm to ensure baseudev.py in an updates.img works.
> ---
>  baseudev.py |   20 +++++---------------
>  1 files changed, 5 insertions(+), 15 deletions(-)
> 
> diff --git a/baseudev.py b/baseudev.py
> index 0eb66b8..8a23825 100644
> --- a/baseudev.py
> +++ b/baseudev.py
> @@ -31,24 +31,14 @@ import logging
>  log = logging.getLogger("storage")
>  
>  def udev_enumerate_devices(deviceClass="block"):
> -    top_dir = "/sys/class/%s" % deviceClass
> -    devices = []
> -    for dev_name in os.listdir(top_dir):
> -        full_path = os.path.join(top_dir, dev_name)
> -        link_ref = os.readlink(full_path)
> -        real_path = os.path.join(top_dir, link_ref)
> -        sysfs_path = os.path.normpath(real_path)
> -        devices.append(sysfs_path[4:])
> -    return devices
> +    return global_udev.enumerate_devices(subsystem=deviceClass)

This part looks great.

>  
>  def udev_get_device(sysfs_path):
> -    if not os.path.exists("/sys%s" % sysfs_path):
> +    if not os.path.exists(sysfs_path):
>          log.debug("%s does not exist" % sysfs_path)
>          return None
>  
> -    # XXX we remove the /sys part when enumerating devices,
> -    # so we have to prepend it when creating the device
> -    dev = global_udev.create_device("/sys" + sysfs_path)
> +    dev = global_udev.create_device(sysfs_path)
>  
>      if dev:
>          dev["name"] = dev.sysname

This is going to cause lots of problems. You're changing the
'sysfs_path' value in the info dict to include the '/sys' prefix, which
is not what is expected by the devicetree and devices modules. Stuff
like this is all over the place:

storage/devicetree.py:1314: _p = "/sys/%s/%s" % (sysfs_path, protected)

So you'll want to hack it off when setting dev['sysfs_path'].

> @@ -90,11 +80,11 @@ def udev_settle():
>      # lots of disks, or with slow disks
>      argv = ["settle", "--timeout=300"]
>  
> -    iutil.execWithRedirect("udevadm", argv, stderr="/dev/null")
> +    iutil.execWithRedirect("/sbin/udevadm", argv, stderr="/dev/null")
>  
>  def udev_trigger(subsystem=None, action="add"):
>      argv = ["trigger", "--action=%s" % action]
>      if subsystem:
>          argv.append("--subsystem-match=%s" % subsystem)
>  
> -    iutil.execWithRedirect("udevadm", argv, stderr="/dev/null")
> +    iutil.execWithRedirect("/sbin/udevadm", argv, stderr="/dev/null")


Why are these necessary? Is there also a /usr/bin/udevadm somewhere? We
want the benefit of $PATH so we don't have to change our code if
something moves in the udev packaging.

Dave


_______________________________________________
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