summaryrefslogtreecommitdiffstats
path: root/hello_load.sh
diff options
context:
space:
mode:
authorKyle K <kylek389@gmail.com>2012-12-24 12:53:20 -0600
committerKyle Kaminski <kyle@kkaminsk.com>2012-12-24 12:53:20 -0600
commit0d9aff9bd305d18625c322a1a891aba278049862 (patch)
tree274aa52bf311107232488fb3f924cef316cfcb28 /hello_load.sh
parentf0531d88e958b5fa77f8dc9bb34e697e872aeba9 (diff)
downloadkernelhello-0d9aff9bd305d18625c322a1a891aba278049862.tar.gz
kernelhello-0d9aff9bd305d18625c322a1a891aba278049862.tar.bz2
kernelhello-0d9aff9bd305d18625c322a1a891aba278049862.zip
spawn char device at /dev/, implement read
Diffstat (limited to 'hello_load.sh')
-rwxr-xr-xhello_load.sh24
1 files changed, 24 insertions, 0 deletions
diff --git a/hello_load.sh b/hello_load.sh
new file mode 100755
index 0000000..fc54ab6
--- /dev/null
+++ b/hello_load.sh
@@ -0,0 +1,24 @@
+#!/bin/bash
+
+MODULE=hello
+DEVICE=helloc
+MODE=664
+
+# invoke insmod with all arguments and use a pathname
+# as newer modutils don't look into . by default
+/usr/bin/insmod ./${MODULE}.ko $* || exit 1
+
+# remove stale nodes
+rm -f /dev/${DEVICE}[0]
+
+MAJOR=$(awk "\$2 == \"$DEVICE\" {print \$1}" /proc/devices)
+
+mknod /dev/${DEVICE}0 c $MAJOR 0
+
+# give appriopriate permissions
+GROUP=staff
+grep -q '^staff' /etc/group || GROUP=wheel
+
+chgrp $GROUP /dev/${DEVICE}0
+chmod $MODE /dev/${DEVICE}0
+