2000-09-10 20:50:05 +04:00
|
|
|
# $NetBSD: rc.lkm,v 1.6 2000/09/10 16:50:05 jdolecek Exp $
|
1997-01-05 14:47:53 +03:00
|
|
|
#
|
2000-05-26 21:46:16 +04:00
|
|
|
# this script loads or unloads LKMs (loadable kernel modules).
|
1997-01-05 14:47:53 +03:00
|
|
|
|
2000-05-26 21:46:16 +04:00
|
|
|
if [ -s /etc/lkm.conf ]; then
|
|
|
|
case "$1" in
|
|
|
|
start)
|
|
|
|
(while read path options entry postinstall output when; do
|
2000-09-10 20:50:05 +04:00
|
|
|
flags=''
|
2000-05-26 21:46:16 +04:00
|
|
|
|
|
|
|
case $path in
|
|
|
|
\#*|"")
|
|
|
|
continue
|
|
|
|
;;
|
|
|
|
/*)
|
|
|
|
;;
|
|
|
|
*)
|
|
|
|
if [ -f "/lkm/$path" ]; then
|
|
|
|
path="/lkm/$path"
|
|
|
|
elif [ -f "/usr/lkm/$path" ]; then
|
|
|
|
path="/usr/lkm/$path"
|
|
|
|
else
|
|
|
|
echo "couldn't find module $path"
|
|
|
|
fi
|
|
|
|
;;
|
|
|
|
esac
|
|
|
|
|
|
|
|
case $options in
|
|
|
|
-)
|
|
|
|
;;
|
|
|
|
*)
|
2000-09-10 20:50:05 +04:00
|
|
|
flags="$flags $options"
|
2000-05-26 21:46:16 +04:00
|
|
|
;;
|
|
|
|
esac
|
|
|
|
|
|
|
|
case $entry in
|
|
|
|
-)
|
|
|
|
;;
|
|
|
|
*)
|
2000-09-10 20:50:05 +04:00
|
|
|
flags="$flags -e $entry"
|
2000-05-26 21:46:16 +04:00
|
|
|
;;
|
|
|
|
esac
|
|
|
|
|
|
|
|
case $postinstall in
|
|
|
|
-)
|
|
|
|
;;
|
|
|
|
*)
|
2000-09-10 20:50:05 +04:00
|
|
|
flags="$flags -p $postinstall"
|
2000-05-26 21:46:16 +04:00
|
|
|
;;
|
|
|
|
esac
|
|
|
|
|
|
|
|
case $output in
|
|
|
|
-)
|
|
|
|
;;
|
|
|
|
*)
|
|
|
|
if [ "$output" = TEMP ]; then
|
2000-09-10 20:50:05 +04:00
|
|
|
flags="$flags -o /tmp/lkm.$$"
|
2000-05-26 21:46:16 +04:00
|
|
|
else
|
2000-09-10 20:50:05 +04:00
|
|
|
flags="$flags -o $output"
|
2000-05-26 21:46:16 +04:00
|
|
|
fi
|
|
|
|
;;
|
|
|
|
esac
|
|
|
|
|
|
|
|
case $when in
|
|
|
|
-)
|
|
|
|
when=BEFORENET
|
|
|
|
;;
|
|
|
|
[A-Z]*)
|
|
|
|
;;
|
|
|
|
*)
|
|
|
|
echo "invalid \"when\" field in /etc/lkm.conf - $path not loaded!"
|
|
|
|
continue
|
|
|
|
;;
|
|
|
|
esac
|
|
|
|
|
2000-09-10 20:50:05 +04:00
|
|
|
if [ "$when" != "$lkmstage" ]; then
|
2000-05-26 21:46:16 +04:00
|
|
|
continue
|
1997-01-05 14:47:53 +03:00
|
|
|
fi
|
2000-05-26 21:46:16 +04:00
|
|
|
|
2000-09-10 20:50:05 +04:00
|
|
|
# try to find out booted kernel via sysctl
|
|
|
|
# if supported
|
|
|
|
booted_kernel=`/sbin/sysctl -n machdep.booted_kernel 2>/dev/null`
|
|
|
|
if [ ! -z "$booted_kernel" -a -r "$booted_kernel" ];
|
|
|
|
then
|
|
|
|
flags="-A $booted_kernel $flags"
|
|
|
|
fi
|
|
|
|
|
2000-05-26 21:46:16 +04:00
|
|
|
echo -n "`basename $path .o`: "
|
2000-09-10 20:50:05 +04:00
|
|
|
modload $flags $path
|
2000-05-26 21:46:16 +04:00
|
|
|
rm -f /tmp/lkm.$$
|
|
|
|
done) < /etc/lkm.conf
|
|
|
|
;;
|
|
|
|
stop)
|
|
|
|
(while read path options entry postinstall output when; do
|
|
|
|
case $path in
|
|
|
|
\#*|"")
|
|
|
|
continue
|
|
|
|
;;
|
|
|
|
/*)
|
|
|
|
name=${path##*/}
|
|
|
|
name=${name%.o}
|
|
|
|
;;
|
|
|
|
*)
|
|
|
|
name=${path%.o}
|
|
|
|
;;
|
|
|
|
esac
|
1997-01-05 14:47:53 +03:00
|
|
|
|
2000-09-10 20:50:05 +04:00
|
|
|
if [ "$when" = "$lkmstage" ]; then
|
2000-05-26 21:46:16 +04:00
|
|
|
modunload -n ${name}
|
1998-12-29 19:29:23 +03:00
|
|
|
fi
|
2000-05-26 21:46:16 +04:00
|
|
|
done) < /etc/lkm.conf
|
|
|
|
;;
|
|
|
|
esac
|
|
|
|
fi
|