unload.sh

来自「Linux 2.6内核版本下的PCI字符驱动开发练习参考代码。」· Shell 代码 · 共 70 行

SH
70
字号
#!/bin/shmodule="hello"device="hello"/sbin/rmmod $module || exit 1rm -f /dev/${device}[0]#[0-15]########################################################################!/bin/sh#module="PCII32IN"#device="PCII32IN"#/sbin/rmmod $module || exit 1#rm -f /dev/${device}[0-15]########################################################################!/bin/sh#module="hello"#device="hello"#mode="664"#$hello="hello"# invoke insmod with all arguments we got# and use a pathname, as newer modutils don't look in . by default#/sbin/rmmod ./$module.ko $* || exit 1#	$echo $hello#$echo   Driver unload  successful # remove stale nodes#rm -f /dev/${device} [0] #[0-3]#major=$(awk "\\$2==\"$module\" {print \\$1}" /proc/devices)#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"#chgrp $group /dev/${device}[0]#[0-3]#chmod $mode /dev/${device}[0-3]##################################################################!/bin/sh#odule="scull"#evice="scull"#ode="664"# invoke insmod with all arguments we got# and use a pathname, as newer modutils don't look in . by default#sbin/insmod ./$module.ko $* || exit 1# remove stale nodes#m -f /dev/${device}[0-3]#major=$(awk "\\$2==\"$module\" {print \\$1}" /proc/devices)#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"#chgrp $group /dev/${device}[0-3]#chmod $mode /dev/${device}[0-3]###################################################################

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?