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 # $Id: scull_load,v 1.4 2004/11/03 06:19:49 rubini Exp $
  3 module="scull"
  4 device="scull"
  5 mode="664"
  6 
  7 # Group: since distributions do it differently, look for wheel or use staff
  8 if grep -q '^staff:' /etc/group; then
  9     group="staff"
 10 else
 11     group="wheel"
 12 fi
 13 
 14 # invoke insmod with all arguments we got
 15 # and use a pathname, as insmod doesn't look in . by default
 16 /sbin/insmod ./$module.ko $* || exit 1
 17 
 18 # retrieve major number
 19 major=$(awk "\$2==\"$module\" {print \$1}" /proc/devices)
 20 
 21 # Remove stale nodes and replace them, then give gid and perms
 22 # Usually the script is shorter, it's scull that has several devices in it.
 23 
 24 rm -f /dev/${device}[0-3]
 25 mknod /dev/${device}0 c $major 0
 26 mknod /dev/${device}1 c $major 1
 27 mknod /dev/${device}2 c $major 2
 28 mknod /dev/${device}3 c $major 3
 29 ln -sf ${device}0 /dev/${device}
 30 chgrp $group /dev/${device}[0-3] 
 31 chmod $mode  /dev/${device}[0-3]
 32 
 33 rm -f /dev/${device}pipe[0-3]
 34 mknod /dev/${device}pipe0 c $major 4
 35 mknod /dev/${device}pipe1 c $major 5
 36 mknod /dev/${device}pipe2 c $major 6
 37 mknod /dev/${device}pipe3 c $major 7
 38 ln -sf ${device}pipe0 /dev/${device}pipe
 39 chgrp $group /dev/${device}pipe[0-3] 
 40 chmod $mode  /dev/${device}pipe[0-3]
 41 
 42 rm -f /dev/${device}single
 43 mknod /dev/${device}single  c $major 8
 44 chgrp $group /dev/${device}single
 45 chmod $mode  /dev/${device}single
 46 
 47 rm -f /dev/${device}uid
 48 mknod /dev/${device}uid   c $major 9
 49 chgrp $group /dev/${device}uid
 50 chmod $mode  /dev/${device}uid
 51 
 52 rm -f /dev/${device}wuid
 53 mknod /dev/${device}wuid  c $major 10
 54 chgrp $group /dev/${device}wuid
 55 chmod $mode  /dev/${device}wuid
 56 
 57 rm -f /dev/${device}priv
 58 mknod /dev/${device}priv  c $major 11
 59 chgrp $group /dev/${device}priv
 60 chmod $mode  /dev/${device}priv
 61 
 62 
 63 
 64 
 65 
 66 
  This page was automatically generated by the LXR engine.