summaryrefslogtreecommitdiffstats
path: root/abs/core/udev/load-modules.sh
diff options
context:
space:
mode:
Diffstat (limited to 'abs/core/udev/load-modules.sh')
-rwxr-xr-xabs/core/udev/load-modules.sh60
1 files changed, 60 insertions, 0 deletions
diff --git a/abs/core/udev/load-modules.sh b/abs/core/udev/load-modules.sh
new file mode 100755
index 0000000..861b942
--- /dev/null
+++ b/abs/core/udev/load-modules.sh
@@ -0,0 +1,60 @@
+#! /bin/bash
+# Implement blacklisting for udev-loaded modules
+
+[ $# -ne 1 ] && exit 1
+
+. /etc/rc.conf
+
+# grab modules from rc.conf
+BLACKLIST="${MOD_BLACKLIST[@]}"
+
+if [ -f /proc/cmdline ]; then
+ for cmd in $(cat /proc/cmdline); do
+ case $cmd in
+ *=*) eval $cmd ;;
+ esac
+ done
+ #parse cmdline entries of the form "disablemodules=x,y,z"
+ if [ -n "$disablemodules" ]; then
+ BLACKLIST="$BLACKLIST $(echo $disablemodules | sed 's|,| |g')"
+ fi
+ if [ "$load_modules" == "off" ]; then
+ MOD_AUTOLOAD="no"
+ fi
+fi
+
+#MODULES entries in rc.conf that begin with ! are blacklisted
+for mod in ${MODULES[@]}; do
+ if [ "${mod}" != "${mod#!}" ]; then
+ BLACKLIST="$BLACKLIST ${mod#!}"
+ fi
+done
+
+
+if [ "$MOD_AUTOLOAD" = "yes" -o "$MOD_AUTOLOAD" = "YES" ]; then
+ if [ -n "$BLACKLIST" ]; then
+ depmods="$(/sbin/modprobe -i --show-depends $1)"
+ if [ $? -ne 0 ]; then
+ /usr/bin/logger -p info "cannot find module $1"
+ exit 1
+ fi
+
+ #sanitize our module names
+ depmods="$(echo "$depmods" | sed \
+ -e "s#^insmod /lib.*/\(.*\)\.ko.*#\1#g" \
+ -e 's|-|_|g')"
+
+ for mod in $depmods; do
+ if echo $BLACKLIST | /bin/grep "\<$mod\>" 2>&1 >/dev/null; then
+ /usr/bin/logger -p info "udev load-modules: $1 is blacklisted"
+ exit 1
+ fi
+ done
+ fi
+ /sbin/modprobe $1
+else
+ #/usr/bin/logger -p info \
+ echo \
+ "udev load-modules: autoloading is disabled, not loading $1"
+fi
+# vim: set et ts=4: