summaryrefslogtreecommitdiffstats
path: root/hello_load.sh
diff options
context:
space:
mode:
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
+