summaryrefslogtreecommitdiffstats
path: root/load-modules.sh
diff options
context:
space:
mode:
authorThomas Bächler <thomas@archlinux.org>2010-01-10 18:44:47 +0100
committerThomas Bächler <thomas@archlinux.org>2010-01-10 18:44:47 +0100
commita5b517dba551af7fd902464a5d866e2d5ce03508 (patch)
treeb247100ca238edb053017b27175b6076bfc1dc4a /load-modules.sh
parent3fceb27acec3c2039639c6f9d205da24b3b68619 (diff)
downloadmkinitcpio-a5b517dba551af7fd902464a5d866e2d5ce03508.tar.gz
mkinitcpio-a5b517dba551af7fd902464a5d866e2d5ce03508.tar.xz
Add udev hook, originated from the obsolete klibc-udev package
Diffstat (limited to 'load-modules.sh')
-rwxr-xr-xload-modules.sh51
1 files changed, 51 insertions, 0 deletions
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: