udev: support '-=' operator for SYMLINK
authorFranck Bui <fbui@suse.com>
Tue, 17 Jan 2023 05:30:48 +0000 (14:30 +0900)
committerYu Watanabe <watanabe.yu+github@gmail.com>
Tue, 17 Jan 2023 05:39:24 +0000 (14:39 +0900)
commitaeefa4d248279a259cdf53036e4bd4ff5dfa1525
tree312217e889d944e1b46a6453f0ace41ac557e249
parent841dfd3dc0dd370a21f190a5b7b870db1c95f7e6
udev: support '-=' operator for SYMLINK

For some (corner) cases, it might be desirable to disable the generation of
some persistent storage symlinks that 60-persistent-storage.rules creates.

For example on big setups with a high number of partitions which uses the same
label name, this can result in a noticeable slow-down in the (re)start of the
udevd as there are many contenders for the symlink /dev/disk/by-partlabel.

However it's currently pretty hard to overwrite just some specific part of the
rule file. Indeed one need to copy and modify the whole rule file in /etc but
will lost any upcoming updates/fixes that the distro might release in the
future.

With this simple patch, one can now disable the generation of the
"by-partlabel" symlinks (for example) with the following single rule:

$ cat /etc/udev/rules.d/99-no-by-partlabel.rules
ENV{ID_PART_ENTRY_NAME}=="?*", SYMLINK-="disk/by-partlabel/$env{ID_PART_ENTRY_NAME}"

Closes #24607.
src/libsystemd/sd-device/device-private.h
src/libsystemd/sd-device/sd-device.c
src/udev/udev-rules.c