-
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathledfifo_load
More file actions
executable file
·29 lines (25 loc) · 959 Bytes
/
ledfifo_load
File metadata and controls
executable file
·29 lines (25 loc) · 959 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
#!/bin/bash
# REF: https://lwn.net/images/pdf/LDD3/ch03.pdf - Page 47
module="LEDfifo"
device="ledfifo"
mode="666"
# invoke insmod with all arguments we got
# and use a pathname, as newer modutils don't look in . by default
(set -x;/sbin/insmod ./$module.ko $* || exit 1)
# remove stale nodes
(set -x;rm -f /dev/${device}[0-3])
#major=$(awk "\$2==\"$module\" {print \$1}" /proc/devices)
major=$(cat /proc/devices | grep ${device} | cut -d' ' -f1 | sort -n | tail -1)
if [ -n "${major}" ]; then
(set -x;mknod /dev/${device}0 c ${major} 0)
#mknod /dev/${device}1 c $major 1
#mknod /dev/${device}2 c $major 2
#mknod /dev/${device}3 c $major 3
# give appropriate group/permissions, and change the group.
# Not all distributions have staff, some have "wheel" instead.
group="staff"
grep -q '^staff:' /etc/group || group="wheel"
(set -x;chgrp $group /dev/${device}[0-3]; chmod $mode /dev/${device}[0-3])
else
echo "$0: failed to grab major node id"
fi