/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. load balancer 配置参考

    https://wiki.ewu.edu/oit/Load_balancing_using_nginx

  2. FFmpeg的HEVC解码器源代码简单分析:解码器主干部分

    ===================================================== HEVC源代码分析文章列表: [解码 -libavcodec HEVC 解码器] FFmpe ...

  3. x264源代码简单分析:宏块分析(Analysis)部分-帧内宏块(Intra)

    ===================================================== H.264源代码分析文章列表: [编码 - x264] x264源代码简单分析:概述 x26 ...

  4. Team Foundation Server 2015 Update 2.1 发布日志

    微软在 2016年5月5日发布了Visual Studio Team Foundation Server 2015 update 2.1. 下面我们来看看Update2.1中给我们带来了哪些新功能. ...

  5. ORACLE数据库学习之逻辑结构

     逻辑结构 数据库逻辑结构包含表空间.段.范围(extent).数据块和模式对象. (一)表空间 一个数据库划分为一个或多个逻辑单位,该逻辑单位称为表空间类似于sybase下的设备.(TABLES ...

  6. Android中常用开发工具类—持续更新...

    一.自定义ActionBar public class ActionBarTool { public static void setActionBarLayout(Activity act,Conte ...

  7. SSH深度历险(五) 深入浅出-----IOC AND AOP

    IOC就是Inversion of Control,控制反转.在Java开发中,IoC意味着将你设计好的类交给系统(容器)来控制实现,而不是在你的类内部控制.这称为控制反转. 本人理解:就是把原本你自 ...

  8. Linux中printk()实例

    新建hello.c #include <linux/kernel.h> #include <linux/module.h> int init_module(void) { pr ...

  9. 03安卓TextView

    一  TextView    父类 : View     >概念:文本控件 :文本内容的显示   默认配置不可编辑  子类EditText可以编辑 *********************** ...

  10. Fedora 20: How to enable SSH

    1. systemctl  enable sshd.service 2. service sshd restart