#!/bin/sh # insmod wrapper for loadmap trickery # usage: # 1) rename insmod to insmod-real # 2) copy or symlink this script to insmod # # then the script will dump all module loadmaps to $MAPDIR # # requires: # getopt, basename, date # you might have to copy them to your root filesystem # ####################################################################### # destination directory MAPDIR=/lib/modules/loadmaps # the real thing INSMOD=/sbin/insmod-real ####################################################################### OPTS="" ARGS="" MAP="" DEST="" CALLED="$0 $*" set -- `getopt fkmpsxXvo: $*` || exit 1 while [ "$1" != "" ]; do case $1 in -f | -k | -p | -x | -X | -v) # pass throuth OPTS="$OPTS $1"; shift ;; -o) # pass throuth with arg, note name OPTS="$OPTS $1 $2"; DEST="$2"; shift; shift;; -m) # note this, no file but stdout for loadmap OPTS="$OPTS $1"; MAP="nofile"; shift ;; -s) # skip - no syslog becauce we want dump to a file shift;; --) # grab module name for loadmap filename MOD=$2; shift; shift;; *=*) # some module arg ARGS="$ARGS $1"; shift;; *) # Huh? echo "insmod-wrapper: what the heck is '$1' ???" echo "command line: $CALLED" exit 1;; esac done if [ "$MAP" = "nofile" ]; then # -m on command line -- dump loadmap to stdout (to make it # work like people expect from docs) $INSMOD $OPTS $MOD $ARGS else # dump it to our directory [ "$DEST" = "" ] && DEST="`basename $MOD .o`" DESTFILE="$MAPDIR/$DEST" echo "orig : $CALLED" > $DESTFILE echo "calling : $INSMOD $OPTS -m $MOD $ARGS" >> $DESTFILE echo "timestamp: `date`" >> $DESTFILE echo "--" >> $DESTFILE $INSMOD $OPTS -m $MOD $ARGS >> $DESTFILE fi