Remove support for old volatile udev rules below /dev/.udev

Udev stopped supporting volatile udev rules in /dev/.udev/rules.d in
udev 176, released 2012-01-11 [1].  The oldest supported distributions
use much more recent combined systemd and udev releases.

    Distro            EOL        udevadm -V
    Debian 9          2022-Jun   232
    RHEL / CentOS 7   2024-Jun   219
    Ubuntu 18.04 LTS  2023-Apr   237

Now udev only reads volatile rules from /run/udev/ruled.d [2].  Simplify
the code a little.

[1] udev 176 NEWS
    https://git.kernel.org/pub/scm/linux/hotplug/udev.git/tree/NEWS?h=176
    "A writable /run directory (ususally tmpfs) is required now for a
    fully functional udev, there is no longer a fallback to /dev/.udev."
[2] man 7 udev
    "RULES FILES
    The udev rules are read from the files located in the system rules
    directory /usr/lib/udev/rules.d, the volatile runtime directory
    /run/udev/rules.d and the local administration directory
    /etc/udev/rules.d."
This commit is contained in:
Mike Fleetwood 2022-01-08 10:45:31 +00:00 committed by Curtis Gedak
parent 8640f91a4f
commit 2cfca5b38a
1 changed files with 9 additions and 14 deletions

View File

@ -179,26 +179,21 @@ fi
# start Linux Software RAID array members and Bcache devices. # start Linux Software RAID array members and Bcache devices.
# #
# Udev stores volatile / temporary runtime rules in directory /run/udev/rules.d. # Udev stores volatile / temporary runtime rules in directory /run/udev/rules.d.
# Older versions use /dev/.udev/rules.d instead, and even older versions don't # Volatile / temporary rules are used to override default rules from
# have such a directory at all. Volatile / temporary rules are use to override # /lib/udev/rules.d. (Permanent local administrative rules in directory
# default rules from /lib/udev/rules.d. (Permanent local administrative rules # /etc/udev/rules.d override all others). See udev(7) manual page for details.
# in directory /etc/udev/rules.d override all others). See udev(7) manual page
# from various versions of udev for details.
# #
# Default udev rules containing mdadm to incrementally start array members are # Default udev rules containing mdadm to incrementally start array members are
# found in 64-md-raid.rules and/or 65-md-incremental.rules, depending on the # found in 64-md-raid.rules and/or 65-md-incremental.rules, depending on the
# distribution and age. The rules may be commented out or not exist at all. # distribution and age. The rules may be commented out or not exist at all.
# #
UDEV_TEMP_RULES='' # List of temporary override rules files. UDEV_TEMP_RULES='' # List of temporary override rules files.
for udev_temp_d in /run/udev /dev/.udev; do if test -d /run/udev; then
if test -d "$udev_temp_d"; then test ! -d /run/udev/rules.d && mkdir /run/udev/rules.d
test ! -d "$udev_temp_d/rules.d" && mkdir "$udev_temp_d/rules.d"
udev_mdadm_rules=`egrep -l '^[^#].*mdadm (-I|--incremental)' /lib/udev/rules.d/*.rules 2> /dev/null` udev_mdadm_rules=`egrep -l '^[^#].*mdadm (-I|--incremental)' /lib/udev/rules.d/*.rules 2> /dev/null`
udev_bcache_rules=`ls /lib/udev/rules.d/*bcache*.rules 2> /dev/null` udev_bcache_rules=`ls /lib/udev/rules.d/*bcache*.rules 2> /dev/null`
UDEV_TEMP_RULES=`echo $udev_mdadm_rules $udev_bcache_rules | sed 's,/lib/udev,/run/udev,g'` UDEV_TEMP_RULES=`echo $udev_mdadm_rules $udev_bcache_rules | sed 's,/lib/udev,/run/udev,g'`
break
fi fi
done
for rule in $UDEV_TEMP_RULES; do for rule in $UDEV_TEMP_RULES; do
touch "$rule" touch "$rule"
done done