aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTom Gundersen <teg@jklm.no>2011-05-09 22:15:43 +0200
committerTom Gundersen <teg@jklm.no>2011-05-19 14:33:35 +0200
commit99d64f5789f01243903be4b32078ec38bdce75fa (patch)
tree6034a2900ef36d6040f03ac02556c76a7491cd18
parent417ab8ce6c830042375da4ded4374a9f30a5387e (diff)
downloadinitscripts-99d64f5789f01243903be4b32078ec38bdce75fa.tar.xz
udev: generate blacklist on boot
udev will read /etc/modprobe.d/*.conf and blacklist all modules that are listed as blacklist <module> We parse rc.conf at boot and generate such a .conf file. It cannot be written to /etc this early, so we save it to /run. A symlink exists in /etc to get the desired functionality. With this patch (and an analogous one in mkinitcpio) load-modules.sh can be removed from the udev package without loss of significant functionality. Setting MOD_AUTOLOAD will then no longer take effect, nor will kernel parameters. Thouhgh, kernel parameters might still affect the initramfs as the implementation is independent. Original-idea-by: Benjamen Richer <br@waldteufel-online.net> Based-on-patch-by: David Reisner <d@falconindy.com> Signed-off-by: Tom Gundersen <teg@jklm.no>
-rw-r--r--Makefile5
-rwxr-xr-xmodprobe-blacklist25
-rw-r--r--rc.conf2
-rwxr-xr-xrc.sysinit3
4 files changed, 32 insertions, 3 deletions
diff --git a/Makefile b/Makefile
index 4e9f88d..ad8a058 100644
--- a/Makefile
+++ b/Makefile
@@ -1,5 +1,5 @@
VER := $(shell git describe)
-DIRS := /etc/rc.d /etc/conf.d /etc/rc.d/functions.d /etc/cron.hourly /sbin
+DIRS := /etc/rc.d /etc/conf.d /etc/rc.d/functions.d /etc/cron.hourly /sbin /etc/modprobe.d
minilogd: minilogd.o
@@ -12,7 +12,8 @@ install: minilogd installdirs
install -m755 -t $(DESTDIR)/etc/cron.hourly adjtime
install -m644 -t $(DESTDIR)/etc/rc.d functions
install -m755 -t $(DESTDIR)/etc/rc.d hwclock network netfs
- install -m755 -t $(DESTDIR)/sbin minilogd rc.d
+ install -m755 -t $(DESTDIR)/sbin minilogd rc.d modprobe-blacklist
+ ln -s /run/initscripts/modprobe-blacklist.conf $(DESTDIR)/etc/modprobe.d/arch-blacklist.conf
clean:
rm -f minilogd minilogd.o
diff --git a/modprobe-blacklist b/modprobe-blacklist
new file mode 100755
index 0000000..8af5d90
--- /dev/null
+++ b/modprobe-blacklist
@@ -0,0 +1,25 @@
+#!/bin/bash
+#
+# /etc/rc.gen-modules-list
+#
+
+. /etc/rc.conf
+
+declare -a blacklist
+for mod in "${MODULES[@]}"; do
+ case $mod in
+ !*) blacklist+=("${mod:1}") ;;
+ *) ;;
+ esac
+done
+
+# create new module blacklist in /run/initscripts, there should be a symlink in /etc/modprobe.d/ pointing here
+if [[ $blacklist ]]; then
+ /bin/mkdir -p /run/initscripts
+ echo "# Autogenerated from rc.conf at boot, do not edit" > /run/initscripts/modprobe-blacklist.conf
+ (( ${#blacklist[@]} )) && printf 'blacklist %s\n' "${blacklist[@]}" >> /run/initscripts/modprobe-blacklist.conf
+fi
+
+unset blacklist
+
+# vim: set noet ts=2 sw=2:
diff --git a/rc.conf b/rc.conf
index f09b413..89ea27e 100644
--- a/rc.conf
+++ b/rc.conf
@@ -36,7 +36,7 @@ VERBOSE="3"
# MOD_AUTOLOAD: Allow autoloading of modules at boot and when needed
# MODULES: Modules to load at boot-up. Prefix with a ! to blacklist.
#
-MOD_AUTOLOAD="yes"
+MOD_AUTOLOAD="yes" # (DEPRECATED) always leave at "yes"
MODULES=()
# Udev settle timeout (default to 30)
diff --git a/rc.sysinit b/rc.sysinit
index d0003ab..2250546 100755
--- a/rc.sysinit
+++ b/rc.sysinit
@@ -83,6 +83,9 @@ if [[ $HWCLOCK_PARAMS ]]; then
fi
fi
+# parse rc.conf and create the blacklist file for use by modprobe
+status "Creating UDev blacklist" /sbin/modprobe-blacklist
+
status "Starting UDev Daemon" /sbin/udevd --daemon
run_hook sysinit_udevlaunched