|
|
4993dcd |
From f33ab8bf8d6bfd6de8da3dc305ca61be8e1d6747 Mon Sep 17 00:00:00 2001
|
|
|
4993dcd |
From: Maxim Mikityanskiy <maxtram95@gmail.com>
|
|
|
4993dcd |
Date: Sat, 22 Aug 2015 11:33:32 +0300
|
|
|
4993dcd |
Subject: [PATCH 4/4] sd-device: fix enumeration of devices without subsystem
|
|
|
4993dcd |
|
|
|
4993dcd |
Prior to commit c32eb440bab953a0169cd207dfef5cad16dfb340, libudev's
|
|
|
4993dcd |
function udev_enumerate_scan_devices() had behaved differently. If
|
|
|
4993dcd |
parent match was added with udev_enumerate_add_match_parent(),
|
|
|
4993dcd |
udev_enumerate_scan_devices() did not return error if some child devices
|
|
|
4993dcd |
had no subsystem symlink in sysfs. An example of such devices is USB
|
|
|
4993dcd |
endpoints /sys/bus/usb/devices/*/ep_*. If there was a parent match
|
|
|
4993dcd |
against USB device, old implementation of udev_enumerate_scan_devices()
|
|
|
4993dcd |
did not treat ep_* device directories without subsystem symlink as error
|
|
|
4993dcd |
and just ignored them, but new implementation returns -ENOENT (also
|
|
|
4993dcd |
ignoring these devices) though correctly enumerates all other matching
|
|
|
4993dcd |
devices.
|
|
|
4993dcd |
|
|
|
4993dcd |
To compare, you could look at 96df036fe3d25525a44f5efdb2fc8560e82e6cfd,
|
|
|
4993dcd |
in src/libudev/libudev-enumerate.c, function parent_add_child():
|
|
|
4993dcd |
|
|
|
4993dcd |
if (!match_subsystem(enumerate, udev_device_get_subsystem(dev)))
|
|
|
4993dcd |
goto nomatch;
|
|
|
4993dcd |
|
|
|
4993dcd |
udev_device_get_subsystem() was returning NULL, match_subsystem() was
|
|
|
4993dcd |
returning false, and USB endpoint device was ignored.
|
|
|
4993dcd |
|
|
|
4993dcd |
New parent_add_child() from src/libsystemd/sd-device/device-enumerator.c
|
|
|
4993dcd |
checks return value of sd_device_get_subsystem() and fails if subsystem
|
|
|
4993dcd |
was not found. Absence of subsystem symlink should not be really treated
|
|
|
4993dcd |
as error because all enumerations of children of USB devices will fail
|
|
|
4993dcd |
with -ENOENT. This new behavior also breaks system-config-printer.
|
|
|
4993dcd |
|
|
|
4993dcd |
So restore old behavior and treat absence of subsystem symlink as no
|
|
|
4993dcd |
match.
|
|
|
4993dcd |
---
|
|
|
4993dcd |
src/libsystemd/sd-device/device-enumerator.c | 2 ++
|
|
|
4993dcd |
1 file changed, 2 insertions(+)
|
|
|
4993dcd |
|
|
|
4993dcd |
diff --git a/src/libsystemd/sd-device/device-enumerator.c b/src/libsystemd/sd-device/device-enumerator.c
|
|
|
4993dcd |
index 7fd77e9..5eb37e1 100644
|
|
|
4993dcd |
--- a/src/libsystemd/sd-device/device-enumerator.c
|
|
|
4993dcd |
+++ b/src/libsystemd/sd-device/device-enumerator.c
|
|
|
4993dcd |
@@ -719,6 +719,8 @@ static int parent_add_child(sd_device_enumerator *enumerator, const char *path)
|
|
|
4993dcd |
return r;
|
|
|
4993dcd |
|
|
|
4993dcd |
r = sd_device_get_subsystem(device, &subsystem);
|
|
|
4993dcd |
+ if (r == -ENOENT)
|
|
|
4993dcd |
+ return 0;
|
|
|
4993dcd |
if (r < 0)
|
|
|
4993dcd |
return r;
|
|
|
4993dcd |
|
|
|
4993dcd |
--
|
|
|
4993dcd |
2.5.0
|
|
|
4993dcd |
|