/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.
/dev、/sys/dev 和/sys/devices 和udev的关系的更多相关文章
- /sys/kernel/debug/usb/devices解析
1.概述 USB设备通过debugfs导出/sys/kernel/debug/usb/devices显示内核已知的每个USB设备及其配置描述符.此文件对于用户模式下的状态查看工具非常方便,可以扫描文本 ...
- /dev/tty /dev/ttyS0 /dev/tty0区别 (转载)
1.串行端口终端(/dev/ttySn) 串行端口终端(Serial Port Terminal)是使用计算机串行端口连接的终端设备. 计算机把每个串行端口都看作是一个字符设备.有段时间 ...
- 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 ...
- /dev/console,/dev/null,/dev/tty
UNIX和Linux中比较重要的三个设备文件是:/dev/console,/dev/tty和/dev/null. 0 : /dev/console 这个设备代表的是系统控制台,错误信息和诊断信息通常 ...
- python之sys.stdout、sys.stdin
转自:http://www.cnblogs.com/turtle-fly/p/3280519.html 本文环境:Python 2.7 使用 print obj 而非 print(obj) sys. ...
- python(38):sys.argv,sys.argv.pop(),获取用户的外部输入,非指定
见下面的例子(一): # /usr/bin/env python # coding=utf8 import os import requests import sys if __name__ == & ...
- python中sys.stdout、sys.stdin
如果需要更好的控制输出,而print不能满足需求,sys.stdout,sys.stdin,sys.stderr就是你需要的. 1. sys.stdout与print: 在python中调用print ...
- 标准输入输出 sys.stdin与sys.stdin
1.python中的标准输入输出 如果需要更好的控制输出,而print不能满足需求,input也不能 sys.stdout,sys.stdin,sys.stderr就是你需要的. 2.输入:sys.s ...
- python重定向sys.stdin、sys.stdout和sys.stderr
转自:https://www.cnblogs.com/guyuyuan/p/6885448.html 标准输入.标准输出和错误输出. 标准输入:一般是键盘.stdin对象为解释器提供输入字符流,一般使 ...
随机推荐
- 在ubuntu上搭建交叉编译环境---arm-none-eabi-gcc
最近要开始搞新项目,基于arm的高通方案的项目. 那么,如何在ubuntu上搭建这个编译环境呢? 1.找到相关的安装包:http://download.csdn.net/download/storea ...
- protobuf中的枚举缺省值应该为UNKNOWN
protobuf中的枚举缺省值应该为UNKNOWN(金庆的专栏)proto3中的枚举值为了与proto2兼容,要求缺省值固定为第1个,值为0.proto2中并没有规定对范围之外的枚举值的处理,而pro ...
- Apache shiro集群实现 (二) shiro 的INI配置
Apache shiro集群实现 (一) shiro入门介绍 Apache shiro集群实现 (二) shiro 的INI配置 Apache shiro集群实现 (三)shiro身份认证(Shiro ...
- ORACLE EBS 表空间控制
--1G=1024MB --1M=1024KB --1K=1024Bytes --1M=11048576Bytes --1G=1024*11048576Bytes=11313741824Bytes S ...
- ActiveMQ安装配置及实例
本文可作为吴水成老师,dubbo课程第21节的学习笔记. ActiveMQ的介绍及功能 参考百度 ActiveMQ的下载 https://activemq.apache.org/activemq-51 ...
- 剑指Offer——美团内推+校招笔试题+知识点总结
剑指Offer--美团内推+校招笔试题+知识点总结 前言 美团9.9内推笔试.9.11校招笔试,反正就是各种虐,笔试内容如下: 知识点:图的遍历(DFS.BFS).进程间通信.二叉查找树节点的删除及中 ...
- Android旋转动画
Android旋转动画 核心方法 public void startAnimation(Animation animation) 执行动画,参数可以是各种动画的对象,Animation的多态,也可以是 ...
- android程序崩溃后重启
有时候由于测试不充分或者程序潜在的问题而导致程序异常崩溃,这个是令人无法接受的,在android中怎样捕获程序的异常崩溃,然后进行一些必要的处理或重新启动 应用这个问题困恼了我很久,今天终于解决了该问 ...
- Nginx Upstream模块源码分析(上)
Upstream模块是一个很重要的模块,很多其他模块都会使用它来完成对后端服务器的访问, 达到反向代理和负载均衡的效果.例如Fastcgi.Memcached.SessionSticky等. 如果自己 ...
- JAVA中的静态成员
//Java中的静态成员 /* *静态的成员变量是属于类的,不属于某个对象,是共享的. * 访问时可以用类名.静态属性直接访问,也可以用对象.访问,后者不提倡. * 静态的成员方法只能访问静态的成员 ...