Red Hat Bugzilla – Bug 1297512
udev_enumerate_scan_devices() does not scan all devices
Last modified: 2018-02-14 18:06:21 EST
Description of problem:
udev_enumerate_scan_devices() yields a list of devices which does not include
some devices that can be found by other libudev methods.
Version-Release number of selected component (if applicable):
Steps to Reproduce:
1. Locate a disk device.
2. Use udev_device_get_parent to recursively discover the ancestors of the device until an ancestor is located that belongs to no subsystem.
3. Note that this devices is not among the devices that udev_enumerate_scan_devices yields.
Easy to find a device that is not in the list of devices yielded by udev_enumerate_scan_devices.
Just to be clear and consistent. Is udev_enumerate_scan_devices defined to yield only those devices that belong to some subsystem, and it's just the docs that are are not precise in stating this? Is it an error for a device to not belong to a subsystem? Should libudev not yield a parent that has no subsystem? Some code somewhere is wrong...but whose and where?
This also has consequences for procedures which filter on the list of devices, for instance, the results of udev_enumerate_add_match_subsystem and udev_enumerate_add_nomatch_subsystem
would be expected to be complements, and thus to add up to all devices, but they don't. AFAIK, their union is equal to the result of udev_enumerate_scan_devices().
Created attachment 1113645 [details]
Very simple illustrative reproducer
I notice that there has been a bit of thrashing around this code at least as early as last August, systemd commit 9a9c7dc2cbbe3c26cfbbcb02475d95ff3afe507e.