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 
  3 function make_minors {
  4     let part=1
  5     while (($part < $minors)); do
  6         let minor=$part+$2
  7         mknod $1$part b $major $minor
  8         let part=$part+1
  9     done
 10 }
 11 
 12 
 13 # FIXME: This isn't handling minors (partitions) at all.
 14 module="sbull"
 15 device="sbull"
 16 mode="664"
 17 chardevice="sbullr"
 18 minors=16
 19 
 20 # Group: since distributions do it differently, look for wheel or use staff
 21 if grep '^staff:' /etc/group > /dev/null; then
 22     group="staff"
 23 else
 24     group="wheel"
 25 fi
 26 
 27 # invoke insmod with all arguments we got
 28 # and use a pathname, as newer modutils don't look in . by default
 29 /sbin/insmod -f ./$module.ko $* || exit 1
 30 
 31 major=`cat /proc/devices | awk "\\$2==\"$module\" {print \\$1}"`
 32 
 33 # Remove stale nodes and replace them, then give gid and perms
 34 
 35 rm -f /dev/${device}[a-d]* /dev/${device}
 36 
 37 mknod /dev/${device}a b $major 0
 38 make_minors /dev/${device}a 0
 39 mknod /dev/${device}b b $major 16
 40 make_minors /dev/${device}b 16
 41 mknod /dev/${device}c b $major 32
 42 make_minors /dev/${device}c 32
 43 mknod /dev/${device}d b $major 48
 44 make_minors /dev/${device}d 48
 45 ln -sf ${device}a /dev/${device}
 46 chgrp $group /dev/${device}[a-d]*
 47 chmod $mode  /dev/${device}[a-d]*
  This page was automatically generated by the LXR engine.