字符设备驱动之/proc/devices和/dev的关系
2013-12-18 00:56
513 查看
/proc/devices/下的设备是驱动程序生成的,它可产生一个major供mknod作为参数。
/dev/下的设备是通过mknod加上去的,用户通过此设备名来访问驱动。
The following script, scull_load, is part of the scull distribution. The user of a driver that is distributed in the form of a module can invoke such a script from the system's rc.local file
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 . 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
# 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]
请 问:linux环境下,/dev/目录下的内容与/proc/下文件devices中的内容有什么区别?我在目标板上做实验时发现,当我向板子上加载驱动 模块时,devices文件中有变化,而/dev下根本没有变化,/dev/下不也应该是设备接点吗,为什么为模块建立设备接点时,/dev/下却没有变 化呢?
请各位帮帮忙,谢谢!!!
/proc/devices/中的设备是通过insmod加载到内核的,它可产生一个major供mknod作为参数。
/dev/*.* 是通过mknod加上去的,格式:mknod device1 c/b major minor 如:mknod dr1 c 254 0,用户通过此设备名来访问你的驱动。
/dev/下的设备是通过mknod加上去的,用户通过此设备名来访问驱动。
The following script, scull_load, is part of the scull distribution. The user of a driver that is distributed in the form of a module can invoke such a script from the system's rc.local file
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 . 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
# 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]
请 问:linux环境下,/dev/目录下的内容与/proc/下文件devices中的内容有什么区别?我在目标板上做实验时发现,当我向板子上加载驱动 模块时,devices文件中有变化,而/dev下根本没有变化,/dev/下不也应该是设备接点吗,为什么为模块建立设备接点时,/dev/下却没有变 化呢?
请各位帮帮忙,谢谢!!!
/proc/devices/中的设备是通过insmod加载到内核的,它可产生一个major供mknod作为参数。
/dev/*.* 是通过mknod加上去的,格式:mknod device1 c/b major minor 如:mknod dr1 c 254 0,用户通过此设备名来访问你的驱动。
相关文章推荐
- 字符设备驱动之/proc/devices和/dev的关系
- 字符设备驱动中cdev与inode、file_operations的关系
- 字符设备驱动中cdev与inode、file_operations的关系
- 字符设备驱动3:驱动代码与文件系统中的设备信息的关系
- /proc/devices和/dev的关系
- android 字符设备驱动模块及在 /dev 下自动创建设备节点问题
- 设备驱动模型:字符、BUS、platform、sysfs的关系
- /proc/devices和/dev的关系
- 字符设备驱动、平台设备驱动、设备驱动模型、sysfs的关系
- 国嵌内核驱动进阶班-7-3(阻塞型字符设备驱动)
- 字符设备驱动开发流程详解
- Linux字符设备驱动之register_chrdev_region()系列
- Linux字符设备驱动 - VF(Virtual File) - ver 3
- 高级字符设备驱动-Poll设备方法笔记
- Linux驱动学习笔记(3)字符设备驱动
- Android字符设备驱动及应用层从jni控制GPIO实战
- 国嵌--linux字符设备驱动学习之memdev设备
- 创建一个字符设备驱动
- Linux 字符设备驱动(一)
- Linux字符设备驱动