From caace15bcab9c245b038c217af86a368b9f4488c Mon Sep 17 00:00:00 2001 From: Zeerix Date: Sat, 22 Jul 2017 08:30:33 +0200 Subject: [PATCH] Added automatic driver loading (#469) * Added automatic driver loading When the config file sets enable_autoload_drivers=1, the installer will enable driver loading on hotplug events using mdev.conf, and it will try to load drivers for already connected devices. * * Fixed modprobe for module aliases that contain whitespace * * Removed enable_autoload_drivers option, enabling it by default --- scripts/etc/init.d/rcS | 6 ++++++ scripts/etc/mdev.conf | 18 ++++++++++++++++++ 2 files changed, 24 insertions(+) create mode 100755 scripts/etc/mdev.conf diff --git a/scripts/etc/init.d/rcS b/scripts/etc/init.d/rcS index dfb14717..b5fbd365 100755 --- a/scripts/etc/init.d/rcS +++ b/scripts/etc/init.d/rcS @@ -296,6 +296,12 @@ echo # depmod needs to update modules.dep before using modprobe depmod -a + +# coldplug modules +echo "Loading drivers." +find /sys/ -name modalias -print0 | xargs -0 sort -u -z | xargs -0 modprobe -abq +echo "Finished loading drivers." + if [ "$drivers_to_load" != "" ] ; then echo "Loading additional drivers." for driver in $drivers_to_load diff --git a/scripts/etc/mdev.conf b/scripts/etc/mdev.conf new file mode 100755 index 00000000..f4db01a7 --- /dev/null +++ b/scripts/etc/mdev.conf @@ -0,0 +1,18 @@ +# mdev.conf +# +# Provide user, group, and mode information for devices. If a regex matches +# the device name provided by sysfs, use the appropriate user:group and mode +# instead of the default 0:0 660. +# +# Syntax: +# [-]devicename_regex user:group mode [=path]|[>path]|[!] [@|$|*cmd args...] +# [-]$ENVVAR=regex user:group mode [=path]|[>path]|[!] [@|$|*cmd args...] +# [-]@maj,min[-min2] user:group mode [=path]|[>path]|[!] [@|$|*cmd args...] +# +# [-]: do not stop on this match, continue reading mdev.conf +# =: move, >: move and create a symlink +# !: do not create device node +# @|$|*: run @cmd if $ACTION=add, $cmd if $ACTION=remove, *cmd in all cases + +# support module loading on hotplug +$MODALIAS=.* 0:0 660 @modprobe -b "$MODALIAS"