diff options
Diffstat (limited to 'pa3_device_driver/module.sh')
-rwxr-xr-x | pa3_device_driver/module.sh | 24 |
1 files changed, 24 insertions, 0 deletions
diff --git a/pa3_device_driver/module.sh b/pa3_device_driver/module.sh new file mode 100755 index 0000000..3aec3a1 --- /dev/null +++ b/pa3_device_driver/module.sh @@ -0,0 +1,24 @@ +#!/bin/bash +if [ "$1" == "sample" ]; then + MAJOR=511 + MODULE="pa3_char_driver" + DEVICE="/dev/simple_character_device" + if [ ! -f "$MODULE.ko" ]; then + cp .char_driver_sample $MODULE.ko + fi +elif [ "$1" == "test" ]; then + MAJOR=241 + MODULE="char_driver" + DEVICE="/dev/char_dev" +else + echo "usage: ./module.sh [sample] [test]" +fi + +if [ $(rg -q $MODULE /proc/modules) ]; then + rmmod $MODULE +fi +if [ -f $DEVICE ]; then + rm $DEVICE +fi +mknod -m 777 $DEVICE c $MAJOR 0 +insmod "$MODULE.ko" |