Hi guys, This is in regards to FS#18421. I am looking at ways to move our udev package closer to upstream. The biggest difference is currently our load-modules.sh script which filters out what modules to load. This adds significant overhead to boot, so I think it is the first thing that should go. The below patch generate a blacklist file at boot from rc.conf, which should be linked to by a softlink in /etc/modprobe.d/. This allows udev to figure out blacklisting by itself. Once this is in initscripts and a similar patch is in mkinitcpio, then we can ditch load-modules.sh. One thing to note: the attached patch does "blacklist <module>" (which allows modules to be pulled in as dependencies). We could also do "install <module> /bin/false" (which has the same effect as deleting the module altogether), if that is necessary. I chose to use blacklist as it looks to be the recommended way. Thoughts? Cheers, Tom
From 56e6e5684d40b66d810a3d7d424b5aabec6d660e Mon Sep 17 00:00:00 2001 From: Tom Gundersen <teg@jklm.no> Date: Mon, 9 May 2011 22:15:43 +0200 Subject: [PATCH] udev: generate blacklist on boot
/run/initscripts/modules-blacklist.conf +fi
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. While we are at it we also write the list of autoloaded. This is useful in case we ever want to move to using /etc/modules-load.d/*.conf for loading modules. With this patch load-modules.sh can be removed from the udev package without loss of functionality. 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> --- Makefile | 4 +++- rc.gen-module-lists | 32 ++++++++++++++++++++++++++++++++ rc.sysinit | 3 +++ 3 files changed, 38 insertions(+), 1 deletions(-) create mode 100755 rc.gen-module-lists diff --git a/Makefile b/Makefile index d3a1824..dfb2ff0 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 /etc/module-load.d minilogd: minilogd.o @@ -13,6 +13,8 @@ install: minilogd installdirs install -m755 -t $(DESTDIR)/etc/cron.hourly adjtime install -m755 -t $(DESTDIR)/etc/rc.d functions hwclock network netfs install -m755 -t $(DESTDIR)/sbin minilogd rc + ln -s /run/initscripts/modules-blacklist.conf $(DESTDIR)/etc/modprobe.d/arch-blacklist.conf + ln -s /run/initscripts/modules-load.conf $(DESTDIR)/etc/modules-load.d/arch-modules.conf clean: rm -f minilogd minilogd.o diff --git a/rc.gen-module-lists b/rc.gen-module-lists new file mode 100755 index 0000000..14f9619 --- /dev/null +++ b/rc.gen-module-lists @@ -0,0 +1,32 @@ +#!/bin/bash +# +# /etc/rc.gen-modules-list +# + +. /etc/rc.conf + +declare -a modules blacklist +for mod in "${MODULES[@]}"; do + case $mod in + !*) blacklist+=("${mod:1}") ;; + *) modules+=("$mod") ;; + 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/modules-blacklist.conf + (( ${#blacklist[@]} )) && printf 'blacklist %s\n' "${blacklist[@]}" + +# create new module list in /run/initscripts, there should be a symlink in /etc/modules-load.d/ pointing here +if [[ $modules ]]; then + /bin/mkdir -p /run/initscripts + echo "# Autogenerated from rc.conf at boot, do not edit" > /run/initscripts/modules-load.conf + printf '%s\n' "${modules[@]}" >> /run/initscripts/modules-load.conf +fi + +unset blacklist modules + +# vim: set noet ts=2 sw=2: diff --git a/rc.sysinit b/rc.sysinit index 1521299..4e45d7c 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 udev +status "Creating UDev blacklist" /etc/rc.gen-module-lists + status "Starting UDev Daemon" /sbin/udevd --daemon run_hook sysinit_udevlaunched -- 1.7.5.1