sd-device: make sd_device_new_from_subsystem_sysname() stricter
authorYu Watanabe <watanabe.yu+github@gmail.com>
Sun, 25 Aug 2024 21:24:24 +0000 (06:24 +0900)
committerYu Watanabe <watanabe.yu+github@gmail.com>
Tue, 27 Aug 2024 20:26:08 +0000 (05:26 +0900)
commitcd7c71154cd62d3f50c07ce387edd9c20aebd7bc
tree51d9dc6203fd6b1451dad4a7238e77b989fff5dc
parent1ff0164be5978b824d2213bc546dac66619e1a48
sd-device: make sd_device_new_from_subsystem_sysname() stricter

As workarounded by fc0cbed2db860d163d59d04c32fa6ec30bd0606f, the pair of
subsystem and sysname is not unique. For examples,
- /sys/bus/gpio and /sys/class/gpio, both have gpiochip%N. However, these point to different devpaths.
- /sys/bus/mdio_bus and /sys/class/mdio_bus,
- /sys/bus/mei and /sys/class/mei,
- /sys/bus/typec and /sys/class/typec, and so on.

Let's refuse to provide sd_device object in such cases.
src/libsystemd/sd-device/sd-device.c
src/libsystemd/sd-device/test-sd-device.c