Merge branch 'master' of git://repo.or.cz/buildroot
[buildroot.git] / package / ltt / S27tracer
blob3dee49211b8ad78fe8aa69b7361e2a24607a372c
1 #!/bin/sh
3 # Load tracer module and create tracer device node.
6 MODULE="tracer"
7 MAIN_DEVICE="tracer"
8 USER_DEVICE="tracerU"
9 GROUP="root"
10 MODE="664"
12 start() {
13 if [ -e /dev/${MAIN_DEVICE} -o -e /dev/${USER_DEVICE} ]
14 then
15 # tell the user about what we are doing
16 echo "Deleting old tracer nodes: /dev/tracer and /dev/tracerU"
18 # remove stale nodes
19 rm -f /dev/${MAIN_DEVICE}
20 rm -f /dev/${USER_DEVICE}
23 # look for the major number
24 MAJOR=`/bin/grep " ${MODULE}$" /proc/devices | cut -d" " -f1`
26 # does the device exist?
27 if [ ${MAJOR} ]
28 then
29 echo "Found tracer device with major number:" ${MAJOR}
30 else
31 echo "Loading tracer kernel module: "
32 # invoke modprobe
33 /sbin/modprobe ${MODULE}
34 MAJOR=`/bin/grep " ${MODULE}$" /proc/devices | cut -d" " -f1`
35 if [ ${MAJOR} ]
36 then
37 echo "Found tracer device with major number:" ${MAJOR}
38 else
39 echo "Did not find tracer device ... /dev entries not created ..."
40 exit 1
44 # tell the user about what we are doing
45 echo "Creating new tracer nodes: /dev/tracer and /dev/tracerU"
47 # create the character special file
48 /bin/mknod /dev/${MAIN_DEVICE} c ${MAJOR} 0
49 /bin/mknod /dev/${USER_DEVICE} c ${MAJOR} 1
51 # set permissions and ownership
52 /bin/chgrp ${GROUP} /dev/${MAIN_DEVICE}
53 /bin/chmod ${MODE} /dev/${MAIN_DEVICE}
54 /bin/chgrp ${GROUP} /dev/${USER_DEVICE}
55 /bin/chmod ${MODE} /dev/${USER_DEVICE}
57 stop() {
58 # tell the user about what we are doing
59 echo "Deleting tracer nodes: /dev/tracer and /dev/tracerU"
61 # remove nodes
62 rm -f /dev/${MAIN_DEVICE}
63 rm -f /dev/${USER_DEVICE}
65 if lsmod | /bin/grep "^${MODULE} "
66 then
67 echo -n "Removing tracer kernel module: "
68 # invoke modprobe -r
69 /sbin/modprobe -r ${MODULE}
70 echo "OK"
73 restart() {
74 stop
75 start
78 case "$1" in
79 start)
80 start
82 stop)
83 stop
85 restart|reload)
86 restart
89 echo $"Usage: $0 {start|stop|restart}"
90 exit 1
91 esac
93 exit $?