设为首页 - 加入收藏 ASP站长网(Aspzz.Cn)- 科技、建站、经验、云计算、5G、大数据,站长网!
热搜: 数据 创业者 手机
当前位置: 首页 > 服务器 > 搭建环境 > Linux > 正文

linux – 为什么两个设备共享相同的主要次要设备号?

发布时间:2020-12-25 07:22 所属栏目:118 来源:网络整理
导读:我正在阅读“ Linux设备驱动程序,第3版”,并发现了一些我无法理解的东西. 在第3.2章中,作者说: Traditionally,the major number identifies the driver associated with the device. The minor number is used by the kernel to determine exactly which de

我正在阅读“ Linux设备驱动程序,第3版”,并发现了一些我无法理解的东西.

在第3.2章中,作者说:

Traditionally,the major number identifies the driver associated with the device.
The minor number is used by the kernel to determine exactly which device is being referred to.

然后我尝试了“ls -l / dev”来看一看,我发现有些不寻常:

brw-rw----  1 root disk      1,1 2011-08-23 23:52 ram1
brw-rw----  1 root disk      1,2 2011-08-23 23:52 ram2
brw-rw----  1 root disk      1,3 2011-08-23 23:52 ram3
brw-rw----  1 root disk      1,4 2011-08-23 23:52 ram4
brw-rw----  1 root disk      1,5 2011-08-23 23:52 ram5
...
crw-r-----  1 root kmem      1,1 2011-08-23 23:52 mem
crw-r-----  1 root kmem      1,4 2011-08-23 23:52 port
crw-rw-rw-  1 root root      1,3 2011-08-23 23:52 null
crw-rw-rw-  1 root root      1,5 2011-08-23 23:52 zero

这些设备(ram1-ram5)都有一个克隆,具有相同的主要次要,但名称和类型不同.我认为作者说“主要数字表示设备类,次要数字表示设备索引.因此Major-Minor标识了一个独特的设备.”

现在我很困惑.为什么两个设备可以共享同一个主要未成年人?设备号到底是什么?

如果我错了,请纠正我..提前谢谢.

解决方法

mem,port,null和zero是字符设备(由列表开头的c证明). ramN设备是块设备(因此b).块设备的主要/次要编号与字符设备无关,反之亦然.

(编辑:ASP站长网)

    网友评论
    推荐文章
      热点阅读