/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.

/dev、/sys/dev 和/sys/devices 和udev的关系的更多相关文章

  1. /sys/kernel/debug/usb/devices解析

    1.概述 USB设备通过debugfs导出/sys/kernel/debug/usb/devices显示内核已知的每个USB设备及其配置描述符.此文件对于用户模式下的状态查看工具非常方便,可以扫描文本 ...

  2. /dev/tty /dev/ttyS0 /dev/tty0区别 (转载)

    1.串行端口终端(/dev/ttySn)     串行端口终端(Serial Port Terminal)是使用计算机串行端口连接的终端设备.    计算机把每个串行端口都看作是一个字符设备.有段时间 ...

  3. Difference between 2>&-, 2>/dev/null, |&, &>/dev/null and >/dev/null 2>&1

    Reference link: http://unix.stackexchange.com/questions/70963/difference-between-2-2-dev-null-dev-nu ...

  4. /dev/console,/dev/null,/dev/tty

    UNIX和Linux中比较重要的三个设备文件是:/dev/console,/dev/tty和/dev/null. 0 :  /dev/console 这个设备代表的是系统控制台,错误信息和诊断信息通常 ...

  5. python之sys.stdout、sys.stdin

    转自:http://www.cnblogs.com/turtle-fly/p/3280519.html 本文环境:Python 2.7  使用 print obj 而非 print(obj) sys. ...

  6. python(38):sys.argv,sys.argv.pop(),获取用户的外部输入,非指定

    见下面的例子(一): # /usr/bin/env python # coding=utf8 import os import requests import sys if __name__ == & ...

  7. python中sys.stdout、sys.stdin

    如果需要更好的控制输出,而print不能满足需求,sys.stdout,sys.stdin,sys.stderr就是你需要的. 1. sys.stdout与print: 在python中调用print ...

  8. 标准输入输出 sys.stdin与sys.stdin

    1.python中的标准输入输出 如果需要更好的控制输出,而print不能满足需求,input也不能 sys.stdout,sys.stdin,sys.stderr就是你需要的. 2.输入:sys.s ...

  9. python重定向sys.stdin、sys.stdout和sys.stderr

    转自:https://www.cnblogs.com/guyuyuan/p/6885448.html 标准输入.标准输出和错误输出. 标准输入:一般是键盘.stdin对象为解释器提供输入字符流,一般使 ...

随机推荐

  1. Compile C++ code in Matlab with OpenCV support

    Provides a function named as "mex_opencv(src)" The code function mex_opencv(src) ARC = 'x6 ...

  2. OpenCV + Python 人脸检测

    必备知识 Haar-like opencv api 读取图片 灰度转换 画图 显示图像 获取人脸识别训练数据 探测人脸 处理人脸探测的结果 实例 图片素材 人脸检测代码 人脸检测结果 总结 下午的时候 ...

  3. Unity3d导出Recast geomset.txt

    Unity3d导出Recast geomset.txt (金庆的专栏) Recast Demo 输入需要 geomset.txt 文件来指定区域类型. 以ObjExporter.cs为基础,编写Uni ...

  4. C++:如何删除string对象的末尾非数字字符

    功能实现: 现有一个string对象包含数字字符以及非数字字符,实现删除string对象的末尾非数字字符. 实例: 输入为"0 1 1 2 3    " 输出为"0 1 ...

  5. ASCII 大文字生成器

    display text in large ASCII art fonts 显示大ASCII艺术字体 这种东西在源码声明或者软件初始化控制台打印时候很有用. 例如打开: http://www.oran ...

  6. 闪屏页面开发遇到的问题you need to use a theme.appcompat theme (or descendant)

    开始做一个新闻客户端的应用,在做到闪屏页面时之前发布应用的时候总是报错,原因是我在splash.java中把Activty写成ActionBarActivity,导包,然后就可以了.以前也遇到过这种情 ...

  7. 06 获取Activity的栈管理器

    代码 <span style="font-size:18px;">package com.fmy.day8_29task.util; import java.util. ...

  8. Swift基础用法(Swift开发之一)

    昨晚苹果发布了新一代编程语言Swift,官方提供了一个iBook的说明文档,有需要的可以看下.地址:https://itunes.apple.com/cn/book/swift-programming ...

  9. ROS_Kinetic_21 使用Qt Creator Plug in即ros_qtc_plugin

    更为详细版本请参考: http://blog.csdn.net/zhangrelay/article/details/52214411 结合看更为具体. 首先,先上原版参考: 1 http://wik ...

  10. 【Unity技巧】制作一个简单的NPC

    1. 写在前面 前几天看了cgcookie的一个教程,学习了下怎么根据已有人物模型制作一个仿版的NPC人物,感觉挺好玩的,整理一下放到博客里! 先看一下教程里面的最终效果. 是不是很像个幽灵~ 下面是 ...