访问 Linux 驱动程序时需要 /dev 节点
我试图了解 Linux 2.6 中 /dev 节点的必要性。我确实知道,在 Linux 2.4 时代,必须在该目录下输入条目才能从用户空间访问驱动程序。但在2.6版本中我们使用/sys接口来实现这一点。但仍然可以在 /dev 目录中找到条目。
作为理解这一点的一步,我更改了“miscdevice”对象中的名称参数(这是我的 /dev 目录中的名称),该参数作为输入传递给我的传感器驱动程序中的“misc_register”API,并且驱动程序仍然工作同样的方式。
是否有任何驱动程序仍然依赖 /dev 节点来工作?如果是的话,它们是什么?
谢谢, 文卡特什。
I am trying to understand the necessity of /dev node in Linux 2.6 . I do understand that, in Linux 2.4 days, entries under this directory were necessary so as to access the Drivers from userspace. But in 2.6 version we use /sys interface inorder to achieve this. But still could find entries for within /dev directory .
As a step towards understanding the same, I changed the name parameter (this was the name in my /dev directory ) , within "miscdevice" object, that was passed as input to "misc_register" API within my Sensor driver and still the driver worked the same way.
Are there any drivers which still relay on /dev node for their working ? If yes what are they ?
Thanks,
Venkatesh.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
您混淆了两个不同的事情...
/dev
中的文件是您为了与设备交互而读取和写入的实际设备 - 因此,如果您想写入串行端口,您可以在/dev
中打开代表它的文件并写入。/sys
中的文件向用户空间公开设备的各种属性,以便程序可以查看设备支持哪些功能或配置它。在某些情况下,可以写入/sys
中的文件,以便以某种方式更改设备的配置。You are confusing two different things...
The files in
/dev
are the actual devices that you read and write to in order to interact with a device - so if you want to write to a serial port you open the file in/dev
that represents it and write to it.The files in
/sys
expose various attributes of the device to userspace so that programs can, for example, see what features a device supports, or hos it is configured. In a few cases the files in/sys
can be written to in order to change the configuration of the device in some way.