Linux kernel & device driver programming

Cross-Referenced Linux and Device Driver Code

[ source navigation ] [ diff markup ] [ identifier search ] [ freetext search ] [ file search ]
Version: [ 2.6.11.8 ] [ 2.6.25 ] [ 2.6.25.8 ] [ 2.6.31.13 ] Architecture: [ i386 ]
  1 #!/bin/sh
  2 module="simple"
  3 device="simple"
  4 mode="664"
  5 
  6 # Group: since distributions do it differently, look for wheel or use staff
  7 if grep '^staff:' /etc/group > /dev/null; then
  8     group="staff"
  9 else
 10     group="wheel"
 11 fi
 12 
 13 # invoke insmod with all arguments we got
 14 # and use a pathname, as newer modutils don't look in . by default
 15 /sbin/insmod -f ./$module.ko $* || exit 1
 16 
 17 major=`cat /proc/devices | awk "\\$2==\"$module\" {print \\$1}"`
 18 
 19 # Remove stale nodes and replace them, then give gid and perms
 20 # Usually the script is shorter, it's simple that has several devices in it.
 21 
 22 rm -f /dev/${device}[rn]
 23 mknod /dev/${device}r c $major 0
 24 mknod /dev/${device}n c $major 1
 25 chgrp $group /dev/${device}[rn] 
 26 chmod $mode  /dev/${device}[rn]
  This page was automatically generated by the LXR engine.