diff options
author | Jack Sangdahl <[email protected]> | 2024-04-02 23:09:00 -0600 |
---|---|---|
committer | Jack Sangdahl <[email protected]> | 2024-04-02 23:09:00 -0600 |
commit | 8dbe92136c33a2254b617e6d5273d5499de5ad90 (patch) | |
tree | 310c981ca2d57559d00d87366984715286c2e28c /pa3_device_driver/module.sh | |
parent | 4485201ffbadee4126f04575b1a4aa991152b22c (diff) | |
download | csci3753-8dbe92136c33a2254b617e6d5273d5499de5ad90.tar.gz csci3753-8dbe92136c33a2254b617e6d5273d5499de5ad90.zip |
pa3
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" |