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="scullc"
  3 device="scullc"
  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 # remove stale nodes
 14 rm -f /dev/${device}? 
 15 
 16 # invoke insmod with all arguments we got
 17 # and use a pathname, as newer modutils don't look in . by default
 18 /sbin/insmod -f ./$module.ko $* || exit 1
 19 
 20 major=`cat /proc/devices | awk "\\$2==\"$module\" {print \\$1}"`
 21 
 22 mknod /dev/${device}0 c $major 0
 23 mknod /dev/${device}1 c $major 1
 24 mknod /dev/${device}2 c $major 2
 25 mknod /dev/${device}3 c $major 3
 26 ln -sf ${device}0  /dev/${device}
 27 
 28 # give appropriate group/permissions
 29 chgrp $group /dev/${device}[0-3]
 30 chmod $mode  /dev/${device}[0-3]
  This page was automatically generated by the LXR engine.