#!/bin/sh # This script loads a specified kernel module (e.g. windrvr6). # To reload the kernel module on each boot, run the script from the # /etc/rc.d/rc.local file on the target Linux platform. if test -z "$1" ; then echo "Usage: $0 [use_udev(yes|no|auto)]" exit 1 fi module_base_name=`basename $1 | sed 's/\.o//' | sed 's/\.ko//'` use_udev=$2 usb_module_base_name=$module_base_name"_usb" has_usb_module=0 modules_dir="/lib/modules/`uname -r`/kernel/drivers/misc" if [ ! -d $modules_dir ] ; then modules_dir="/lib/modules/misc" fi if [ -d $modules_dir ] ; then has_usb_module=`ls $modules_dir | grep -cw $usb_module_base_name` fi if test -z "$2" ; then use_udev="auto"; fi if test "$use_udev" = "auto" ; then is_udevd=`ps -ef | grep udevd` major_num=`uname -r | cut -d "." -f2` minor_num=`uname -r | cut -d "." -f3 | cut -d "-" -f1` if [ ! "$is_udevd" ] ; then use_udev="no"; elif [ "$major_num$minor_num" -ge "613" ] ; then use_udev="no"; else use_udev="yes"; fi; fi #remove old module(s) need_remove=`/sbin/lsmod | grep -cw $module_base_name` if [ $need_remove -ne 0 ] ; then /sbin/rmmod $module_base_name || exit 1 fi if [ $has_usb_module -ne 0 ] ; then need_usb_remove=`/sbin/lsmod | grep -cw $usb_module_base_name` if [ $need_usb_remove -ne 0 ] ; then /sbin/rmmod $usb_module_base_name || exit 1 fi fi if test $use_udev = "no" ; then #remove stale nodes rm -f /dev/$module_base_name fi #rebuild dependency tree to include windriver's module(s) /sbin/depmod if [ $has_usb_module -ne 0 ] ; then /sbin/modprobe $usb_module_base_name || exit 1 fi /sbin/modprobe $module_base_name || exit 1 if test $use_udev = "no" ; then major=`grep -w $module_base_name /proc/devices | cut -f1 -d" "` mknod /dev/$module_base_name c $major 0 fi