back
DEV=$1
if test -e "$1"; then
     DEVPATH=$1
else
     # find sysfs device directory for device
     DEVPATH=$(find /sys/class -name "$1" | head -1)
     test -z "$DEVPATH" && DEVPATH=$(find /sys/block -name "$1" | head -1)
     test -z "$DEVPATH" && DEVPATH=$(find /sys/bus -name "$1" | head -1)
     if ! test -e "$DEVPATH"; then
          echo "no device found"
          exit 1
     fi
fi
echo "looking at sysfs device: $DEVPATH"
if test -L "$DEVPATH"; then
     # resolve class device link to device directory
     DEVPATH=$(readlink -f $DEVPATH)
     echo "resolve link to: $DEVPATH"
fi
if test -d "$DEVPATH"; then
     # resolve old-style "device" link to the parent device
     PARENT="$DEVPATH";
     while test "$PARENT" != "/"; do
          if test -L "$PARENT/device"; then
               DEVPATH=$(readlink -f $PARENT/device)
               echo "follow 'device' link to parent: $DEVPATH"
               break
          fi
          PARENT=$(dirname $PARENT)
     done
fi
while test "$DEVPATH" != "/"; do
     DRIVERPATH=
     DRIVER=
     MODULEPATH=
     MODULE=
     if test -e $DEVPATH/driver; then
          DRIVERPATH=$(readlink -f $DEVPATH/driver)
          DRIVER=$(basename $DRIVERPATH)
          echo -n "found driver: $DRIVER"
          if test -e $DRIVERPATH/module; then
               MODULEPATH=$(readlink -f $DRIVERPATH/module)
               MODULE=$(basename $MODULEPATH)
               echo -n " from module: $MODULE"
          fi
          echo
     fi
     DEVPATH=$(dirname $DEVPATH)
done
  

Un ultimo metodo per vedere quali moduli sono necessari per il nostro sistema, sempre nel caso si abbia un sistema già installato, è quello di saggiare l'output del comando lsmod, semplicemente osservando i moduli attualmente inclusi.

Per vedere come implementare questi moduli nel kernel vi rimando ai capitoli successivi. Siamo pronti? Andiamo allora a crearci il nostro nuovo kernel!

back