zoukankan      html  css  js  c++  java
  • /dev、/sys/dev 和/sys/devices 和udev的关系

    /dev,设备文件存储目录,应用程序通过对这些文件的读写和控制,可以访问实际的设备;


    /sys/devices目录,按照设备挂接的总线类型,组织成层次结构,保存了系统所有的设备;是文件系统管理设备的最重要的目录结构;

    这是内核设备按总线类型分层放置的目录结构, devices 中的所有设备都是连接于某种总线之下,在这里的每一种具体总线之下可以

    找到每一个具体设备的符号链接,它也是构成 Linux 统一设备模型的一部分;


    /sys/dev下有两个子目录,block和char,存放的是块设备和字符设备的主次号码,形式为(major:minor),它指向/sys/devices目录下的

    设备。


    一直没有认真看过sysfs的文档,所以一直就迷迷糊糊的不知道/sys/dev和/sys/devices到底啥关系,另外对于udev也是一知半解。懒啊...

    终于遇到了问题,不得不看看文档,总结了下:

    sysfsintroduction:

    ----------------------------

    sysfs is amechanism for representing kernel objects, their attributes, and theirrelationships

    with each other.

    It provides twocomponents: a kernel programming interface for exporting these items via sysfs,and a user interface to view and manipulate these items that maps back to thekernel objects which they represent.

    The table belowshows the mapping between internel (kernel) constructs and their external

    (userspace) sysfsmappings.

    ---------------------------------------

    |Internal             | External      |

    ---------------------------------------

    |KernelObjects       | Directories   |

    ---------------------------------------

    |ObjectAttributes    | Regular Files |

    ---------------------------------------

    |ObjectRelationships | Symbolic Links|

    ---------------------------------------

    (Reference:http://www.kernel.org/pub/linux/kernel/people/mochel/doc/papers/ols-2005/mochel.pdf)

    /sys/dev:

    ------------------

    Contains twodirectories char/ and block/. Inside these two directories there are symlinksnamed <major>:<minor>. These symlinks point to the sysfs directoryfor the given device. /sys/dev provides a quick way to lookup the sysfsinterface for a device from the result of a stat(2) operation.

    Example:

    root@AuxLinux:/sys#ls -l dev/block/8:1

    lrwxrwxrwx 1 rootroot 0 2011-08-26 10:13 dev/block/8:1 ->../../devices/pci0000:00/0000:00:10.0/host2/target2:0:0/2:0:0:0/block/sda/sda1

    root@AuxLinux:/sys#stat /dev/sda1

      File: `/dev/sda1'

      Size: 0               Blocks: 0          IO Block: 4096   block special file

    Device: 5h/5d   Inode: 5484        Links: 1     Device type: 8,1

    Access:(0660/brw-rw----)  Uid: (    0/   root)   Gid: (    6/   disk)

    Access: 2011-08-2418:25:02.902025252 +0800

    Modify: 2011-08-1815:14:17.281472005 +0800

    Change: 2011-08-1815:14:17.281472005 +0800

    /sys/devices:

    ----------------------------

    Contains afilesystem representation of the device tree. It maps directly to the internalkernel device tree, which is a hierarchy of struct device.

    udev:

    -----------------------------

    udev is a devicemanagement framework that replaced the devfs facility in the Linux 2.6 kernel.It is composed of some kernel services and the udevd daemon. The kernel informsthe udevd daemon when certain events happen. The udevd daemon is configured torespond to some events with actions. Always, it means adding/removing devicefile under /dev dynamically.



  • 相关阅读:
    软件的安全性应从哪几个方面去测试?
    目前主要的测试用例设计方法是什么?
    什么是软件质量?
    软件配置管理的作用?软件配置包括什么?
    什么是软件测试?软件测试的目的与原则
    软件生存周期及其模型是什么?
    软件的概念和特点?软件复用的含义?构件包括哪些?
    一台客户端有三百个客户与三百个客户端有三百个客户对服务器施压,有什么区别?
    在搜索引擎中输入汉字就可以解析到对应的域名,请问如何用LoadRunner进行测试。
    测试08
  • 原文地址:https://www.cnblogs.com/LoongEmbedded/p/5298366.html
Copyright © 2011-2022 走看看