examples/kerneltest/insert.sh
changeset 391 7802a7d5584f
equal deleted inserted replaced
390:31dc4ec8710c 391:7802a7d5584f
       
     1 #!/bin/sh
       
     2 
       
     3 module="canf_ktest"
       
     4 device="canf_ktest"
       
     5 mode="664"
       
     6 
       
     7 # insert neccessary modules
       
     8 /sbin/insmod ../../drivers/can_virtual_kernel/can_virtual.ko
       
     9 /sbin/insmod ../../src/canfestival.ko
       
    10 
       
    11 # insert module with all arguments we got
       
    12 # and use a pathname, as newer modutils don't look in . by default
       
    13 /sbin/insmod ./$module.ko $* || exit 1
       
    14 
       
    15 # remove stale nodes
       
    16 rm -f /dev/${device}
       
    17 
       
    18 # create device file
       
    19 major=$(awk "\$2==\"$device\" {print \$1; exit}" /proc/devices)
       
    20 mknod /dev/${device} c $major 0
       
    21 
       
    22 # give appropriate group/permissions, and change the group.
       
    23 # Not all distributions have staff, some have "wheel" instead.
       
    24 group="staff"
       
    25 grep -q '^staff:' /etc/group || group="wheel"
       
    26 chgrp $group /dev/${device}
       
    27 chmod $mode /dev/${device}