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

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

 



Hi,

On 01/29/2010 01:29 AM, David Lehman wrote:
On Thu, 2010-01-28 at 14:11 -1000, David Cantrell wrote:
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

Updated patch:

Ack.


Nack, but it would seem I'm too late. The problem is that
the new incarnation of the patch still uses /sys prefixed
paths in one place: udev_get_device(), but in various
places in the devicetree we call udev_get_device()
(through udev_get_block_device) to get information from parents
which are not yet in the tree (ie when we scan a partition
before its disk).

All these calls are broken now, as all those pass
in a path without /sys at the front and the new
udev_get_device() wants it with /sys in front.

The proper thing to do seems to remove the /sys
in front in udev_enumerate_devices(), so that we
use sysfs paths without /sys in front consistently
everywhere.

I'll do a patch to fix this up.

Regards,

Hans



diff --git a/baseudev.py b/baseudev.py
index 0eb66b8..5ba1011 100644
- --- a/baseudev.py
+++ b/baseudev.py
@@ -31,29 +31,19 @@ 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)

   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
           dev["symlinks"] = dev["DEVLINKS"]
- -        dev["sysfs_path"] = sysfs_path
+        dev["sysfs_path"] = sysfs_path[4:]


On Thu, 28 Jan 2010, David Lehman wrote:

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


- --
David Cantrell<dcantrell@xxxxxxxxxx>
Red Hat / Honolulu, HI

-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.10 (GNU/Linux)

iEYEARECAAYFAktiJ7oACgkQ5hsjjIy1VkluUACghUu+kSiLdDSGoNAAK8/NMwTG
vREAnj4AL71628BtjEiB9lW1/+EoU/iK
=vDla
-----END PGP SIGNATURE-----

_______________________________________________
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

_______________________________________________
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