zoukankan      html  css  js  c++  java
  • 关于major、minor的解释

     

    2013年03月13日 ⁄ 综合 ⁄ 共 1057字 ⁄ 字号 ⁄ 评论关闭
     

    我们知道,在Unix系系统中,一切皆是文件,所有硬盘,键盘,网卡等设备都有文件来代表,对应着/dev/下面的文件。对于应用程序来说,可以像对待普通文件一样打开,关闭,读写这些设备文件。但是,这种文件名比如:/dev/sda  、/dev/raw/raw1 都是用户空间名称,OS Kernel根本不知道这个名称代指什么。在内核空间是通过major、minor device number来区分设备的。

    major device number:可以看做是设备驱动程序,被同一设备驱动程序管理的设备有相同的major device number。这个数字实际是Kernel 中device driver table的索引。这个表保存着不同的设备驱动程序。

    minor device number:代表被访问的具体设备。也就是说,Kernel根据major device number找到设备驱动程序,然后再从minor device number获得设备位置等属性。

    所有这些major、minor device number是已经预先分配好了的,起详细信息可以从网址:www.lanana.org/docs/device-list/获得。。。比如裸设备的 major device number是 162 ,SCSI块设备的major device number是8 。。。。

    下面,我们看一下SCSI设备的用户空间文件名是如何和内核空间的major、minor device number对应的。SCSI设备的用户空间文件名是 sd +driver+partition 。  比如:sda1 、 sdb4.。又因为SCSI设备的major number是8 ,minor number=driver*16+partition numebr

    第一块SCSI磁盘 /dev/sda的partition number是0 。 partition number= 0 代表整个磁盘,而其他分区从1开始排列。。Linux每个磁盘最多有16个分区,其中分区4代表真个扩展分区,所以可用的分区只有15个。

    再回头看一下,裸设备文件名:/dev/raw/raw130  中的130代表一个minor device number为130的裸设备;还可以在/dev/raw下执行ll 命令确认major=162, minor=130。

    继续向下看:

    说明这个裸设备绑定到了major device number =8 ,minor device number =17--23 的设备上。。进一步我们可以在/dev/目录下执行ll sd* 来确定裸设备和其绑定设备的对应关系:

  • 相关阅读:
    OSCP Learning Notes Buffer Overflows(3)
    OSCP Learning Notes Buffer Overflows(5)
    OSCP Learning Notes Exploit(3)
    OSCP Learning Notes Exploit(4)
    OSCP Learning Notes Exploit(1)
    OSCP Learning Notes Netcat
    OSCP Learning Notes Buffer Overflows(4)
    OSCP Learning Notes Buffer Overflows(1)
    OSCP Learning Notes Exploit(2)
    C++格式化输出 Learner
  • 原文地址:https://www.cnblogs.com/phpxuetang/p/4535223.html
Copyright © 2011-2022 走看看