summaryrefslogtreecommitdiffstats
path: root/abs/core-testing/udev/load-modules.sh
diff options
context:
space:
mode:
authorCecil Hugh Watson <knoppmyth@gmail.com>2008-11-30 06:03:49 (GMT)
committerCecil Hugh Watson <knoppmyth@gmail.com>2008-11-30 06:03:49 (GMT)
commitdad9cc7a179efa966154cc5b945f2f6c4da7f477 (patch)
tree3d3292b1d5ce29c464c4e952991531699ff9cecf /abs/core-testing/udev/load-modules.sh
parentf78fc8e0364cb99bf0b3c2fc941ba85c2fe5944f (diff)
downloadlinhes_pkgbuild-dad9cc7a179efa966154cc5b945f2f6c4da7f477.zip
linhes_pkgbuild-dad9cc7a179efa966154cc5b945f2f6c4da7f477.tar.gz
linhes_pkgbuild-dad9cc7a179efa966154cc5b945f2f6c4da7f477.tar.bz2
Updated udev to latest (130).
Diffstat (limited to 'abs/core-testing/udev/load-modules.sh')
-rwxr-xr-xabs/core-testing/udev/load-modules.sh78
1 files changed, 49 insertions, 29 deletions
diff --git a/abs/core-testing/udev/load-modules.sh b/abs/core-testing/udev/load-modules.sh
index 861b942..a42d376 100755
--- a/abs/core-testing/udev/load-modules.sh
+++ b/abs/core-testing/udev/load-modules.sh
@@ -1,4 +1,4 @@
-#! /bin/bash
+#!/bin/bash
# Implement blacklisting for udev-loaded modules
[ $# -ne 1 ] && exit 1
@@ -7,20 +7,22 @@
# grab modules from rc.conf
BLACKLIST="${MOD_BLACKLIST[@]}"
+MODPROBE="/sbin/modprobe"
+LOGGER="/usr/bin/logger"
+RESOLVEALIAS="/bin/resolve-modalias"
+USEBLACKLIST="--use-blacklist"
if [ -f /proc/cmdline ]; then
for cmd in $(cat /proc/cmdline); do
case $cmd in
- *=*) eval $cmd ;;
+ disablemodules=*) eval $cmd ;;
+ load_modules=off) exit ;;
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
@@ -30,31 +32,49 @@ for mod in ${MODULES[@]}; do
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
+ if [ -n "${BLACKLIST}" ]; then
+ # If an alias name is on the blacklist, load no modules for this device
+ if echo "${BLACKLIST}" | /bin/grep -q -e " $1 " -e "^$1 " -e " $1\$"; then
+ $LOGGER -p info -t "$(basename $0)" "Not loading module alias '$1' because it is blacklisted"
+ exit
fi
- /sbin/modprobe $1
-else
- #/usr/bin/logger -p info \
- echo \
- "udev load-modules: autoloading is disabled, not loading $1"
+ #sanitize the blacklist
+ BLACKLIST="$(echo "$BLACKLIST" | sed -e 's|-|_|g')"
+ # 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}" ] && $LOGGER -p info -t "$(basename $0)" "'$1' is not a valid module or alias name"
+ for mod in ${mods}; do
+ # Find the module and all its dependencies
+ deps="$($MODPROBE -i --show-depends ${mod})"
+ [ $? -ne 0 ] && continue
+
+ #sanitize the module names
+ deps="$(echo "$deps" | sed \
+ -e "s#^insmod /lib.*/\(.*\)\.ko.*#\1#g" \
+ -e 's|-|_|g')"
+
+ # If the module or any of its dependencies is blacklisted, don't load it
+ for dep in $deps; do
+ if echo "${BLACKLIST}" | /bin/grep -q -e " ${dep} " -e "^${dep} " -e " ${dep}\$"; then
+ if [ "${dep}" = "${mod}" ]; then
+ $LOGGER -p info -t "$(basename $0)" "Not loading module '${mod}' for alias '$1' because it is blacklisted"
+ else
+ $LOGGER -p info -t "$(basename $0)" "Not loading module '${mod}' for alias '$1' because its dependency '${dep}' is blacklisted"
+ fi
+ continue 2
+ fi
+ done
+ # modprobe usually uses the "blacklist" statements from modprobe.conf only to blacklist all aliases
+ # of a module, but not the module itself. We use --use-blacklist here so that modprobe also blacklists
+ # module names if we resolved alias names manually above
+ $MODPROBE $USEBLACKLIST ${mod}
+ done
+ else
+ $MODPROBE $1
+ fi
fi
# vim: set et ts=4: