interfaces/builtin: fix custom-device udev KERNEL values (#13178)
* interfaces/builtin: fix custom-device udev KERNEL values
Previously, the handling of udev tagging rules was modified to allow
device paths in subdirectories of `/dev/`. As part of this work,
checks were put in place to ensure that all KERNEL values, including
default rules, must be basenames of a device path.
That work can be found in two previous commits:
- b1df21de4719da0644ce7528d9bc9cd46dbf99c1
- 12ca6af3a000b30552abb33377724379faf4aab8
The former allows either full paths (stripped of leading `/dev/`) or
basenames, while the latter switches this requirement so that all values
must be basenames. The commit message of the latter indicates that
KERNEL values which are not basenames violate the udev spec -- this is
incorrect.
For some devices, the udev KERNEL value must be the full path of the
device, stripped of leading `/dev/`, while for other devices, the udev
KERNEL value must be the basename of the device path. If an explicit
udev tagging rule is not given, it is unclear which of these is the
case.
This commit changes udev tagging handling to emit two rules for each
device path in a subdirectory of `/dev/` which is not given as the
kernel value of an explicit udev rule in the "udev-tagging" section:
one using the full device path following `/dev/`, and one using the
basename of the device path.
If there are device paths of the form /dev/bar and /dev/foo/bar, then
default rules will be generated for both KERNEL=="bar" and
KERNEL=="foo/bar". If there are explicit rules for either, the default
rule for the other (if it has no explicit rule) will still be emitted.
Signed-off-by: Oliver Calder <email address hidden>
* interfaces/builtin: custom-device removed unused helpers
Signed-off-by: Oliver Calder <email address hidden>
* interfaces/builtin: custom-device refactored default rule generation
Signed-off-by: Oliver Calder <email address hidden>
* interfaces/builtin: custom-device refactored udev-tagging rule validation
Signed-off-by: Oliver Calder <email address hidden>
* interfaces/builtin: custom-device improve unit tests for devices with shared basename
Signed-off-by: Oliver Calder <email address hidden>
* interfaces/builtin: custom-device add log message when basename rule applies to non-basename device
Signed-off-by: Oliver Calder <email address hidden>
---------
Signed-off-by: Oliver Calder <email address hidden>