/proc/devices和/dev/目录下文件的区别
2013-07-19 16:25阅读:
//*************************************************
转自http://blog.sina.cn/dpool/blog/s/blog_8c5b746601014jp6.html?vt=4
//*************************************************
/proc/devices/下的设备是驱动程序生成的,它可产生一个major供mknod作为参数。
/dev/下的设备是通过mknod加上去的,用户通过此设备名来访问驱动。
The following script, scull_load, is part of the sculldistribution. The user of a driver that is distributed in the formof a module can invoke such a script from the system's rc.localfile or call it manually whenever the module is needed.
#!/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 . bydefault
/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/${d
转自http://blog.sina.cn/dpool/blog/s/blog_8c5b746601014jp6.html?vt=4
//*************************************************
/proc/devices/下的设备是驱动程序生成的,它可产生一个major供mknod作为参数。
/dev/下的设备是通过mknod加上去的,用户通过此设备名来访问驱动。
The following script, scull_load, is part of the sculldistribution. The user of a driver that is distributed in the formof a module can invoke such a script from the system's rc.localfile or call it manually whenever the module is needed.
#!/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 . bydefault
/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/${d