diff options
-rw-r--r-- | Makefile | 1 | ||||
-rw-r--r-- | hooks/udev | 8 | ||||
-rw-r--r-- | install/udev | 28 | ||||
-rwxr-xr-x | load-modules.sh | 51 |
4 files changed, 88 insertions, 0 deletions
@@ -22,6 +22,7 @@ install: all install -D -m755 init ${DESTDIR}/lib/initcpio/init install -D -m755 init_functions ${DESTDIR}/lib/initcpio/init_functions install -D -m644 functions ${DESTDIR}/lib/initcpio/functions + install -D -m644 load-modules.sh ${DESTDIR}/lib/initcpio/udev/load-modules.sh install -d ${DESTDIR}/lib/initcpio/hooks install -d ${DESTDIR}/lib/initcpio/install diff --git a/hooks/udev b/hooks/udev new file mode 100644 index 0000000..57a90f7 --- /dev/null +++ b/hooks/udev @@ -0,0 +1,8 @@ +# vim: set ft=sh: +run_hook () +{ + msg -n ":: Triggering uevents..." + /sbin/udevadm trigger + /sbin/udevadm settle + msg "done." +} diff --git a/install/udev b/install/udev new file mode 100644 index 0000000..986dc58 --- /dev/null +++ b/install/udev @@ -0,0 +1,28 @@ +# vim:set ft=sh: + +install () +{ + MODULES="" + BINARIES="" + FILES=" /etc/udev/udev.conf" + SCRIPT="udev" + add_binary /sbin/udevd + add_binary /sbin/udevadm + for rules in 50-firmware.rules 50-udev-default.rules 60-persistent-storage.rules 80-drivers.rules; do + add_file /lib/udev/rules.d/${rules} + done + for tool in firmware.sh; do + add_file /lib/udev/${tool} + done + add_file /lib/initcpio/udev/load-modules.sh /lib/udev/load-modules.sh +} + +help () +{ +cat <<HELPEOF + This hook will use udev to create your root device node + and detect the needed modules for your root device. It + is also required for firmware loading in initramfs. + It is recommended to use this hook. +HELPEOF +} diff --git a/load-modules.sh b/load-modules.sh new file mode 100755 index 0000000..21767ca --- /dev/null +++ b/load-modules.sh @@ -0,0 +1,51 @@ +#! /bin/sh +# Implement blacklisting for udev-loaded modules +# Includes module checking +# - Aaron Griffin & Tobias Powalowski for Archlinux +[ $# -ne 1 ] && exit 1 + +MODPROBE="/sbin/modprobe" +RESOLVEALIAS="/bin/resolve-modalias" +USEBLACKLIST="--use-blacklist" +REPLACE="/bin/replace" +MODDEPS="/bin/moddeps" + +if [ -f /proc/cmdline ]; then + for cmd in $(cat /proc/cmdline); do + case $cmd in + disablemodules=*) eval $cmd ;; + load_modules=off) exit ;; + esac + done + #parse cmdline entries of the form "disablemodules=x,y,z" + if [ -n "${disablemodules}" ]; then + BLACKLIST="$(${REPLACE} ${disablemodules} ',')" + fi +fi + +# sanitize the module names +BLACKLIST="$(${REPLACE} "${BLACKLIST}" '-' '_')" + +if [ -n "${BLACKLIST}" ] ; then + # Try to find all modules for the alias + mods="$($RESOLVEALIAS /lib/modules/$(uname -r)/modules.alias $1)" + # If no modules could be found, try if the alias name is a module name + # In that case, omit the --use-blacklist parameter to imitate normal modprobe behaviour + [ -z "${mods}" ] && $MODPROBE -qni $1 && mods="$1" && USEBLACKLIST="" + [ -z "${mods}" ] && exit + for mod in ${mods}; do + deps="$(${MODDEPS} ${mod})" + [ $? -ne 0 ] && continue + # If the module or any of its dependencies is blacklisted, don't load it + for dep in $deps; do + for blackmod in ${BLACKLIST}; do + [ "${blackmod}" = "${dep}" ] && continue 3 + done + done + $MODPROBE $USEBLACKLIST ${mod} + done +else + $MODPROBE $1 +fi + +# vim: set et ts=4: |