我已经开始学习“Linux Device Drivers 3rd ed”,但我无法理解以下脚本的语法。我知道基本的 shell 脚本,并且可以使用 awk 实用程序来制作基本程序
Q1)/sbin/insmod ./$module.ko $* || 退出 1 a) 说明 insmod 的完整路径需要什么?b)我使用 ./ 来调用可执行文件,但从未在命令中间看到 ./。c) 是 $module=scull??? d) $* 是什么意思?e) 双棒是干什么用的?
Q2)major=$(awk "\$2= =\"$module\" {print \$1}" /proc/devices) 这条 awk 语句通过哪些步骤为我们获取 scull 设备?我没有得到双斜杠“\”和双等号。
#!/bin/sh
module="scull"
device="scull"
mode="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
rm -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