udev_enumerate_scan_devices() broken when used with udev_enumerate_add_match_parent() (#1295979)

Resolves: #1295979
This commit is contained in:
Jan Synacek 2016-01-07 14:10:06 +01:00
parent 69066a593d
commit 4993dcdfa0
2 changed files with 56 additions and 0 deletions

View File

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

View File

@ -106,6 +106,7 @@ Patch0070: 0055-logind-release-VT-positions-when-closing-sessions.patch
Patch0071: 0071-nspawn-Don-t-pass-uid-mount-option-for-devpts.patch
Patch0072: 0072-journalctl-make-sure-journalctl-f-t-unmatched-blocks.patch
Patch0073: 0073-journalctl-don-t-print-No-entries-in-quiet-mode.patch
Patch0074: 0074-sd-device-fix-enumeration-of-devices-without-subsyst.patch
Patch997: 0001-Re-apply-walters-unit-patch-for-F23-systemd-v222.patch
Patch998: 0001-Revert-core-mount-add-dependencies-to-dynamically-mo-v222.patch
@ -850,6 +851,7 @@ getent passwd systemd-journal-upload >/dev/null 2>&1 || useradd -r -l -g systemd
- Terminal multiplexers (tmux, screen) are broken in systemd-nspawn containers (#1282626)
- Regression: journalctl -f broken (again) with initially empty filter result (#1292805)
- Journalctl says "no entries" even when told to be quiet (#1293062)
- udev_enumerate_scan_devices() broken when used with udev_enumerate_add_match_parent() (#1295979)
* Tue Jan 5 2016 Jan Synáček <jsynacek@redhat.com> - 222-11
- re-apply patches that were removed by mistake (#1263208)