/dev、/sys/devices 和 /sys/dev 之间区别

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

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

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

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

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

1. sysfs的挂载点是/sys目录, sysfs是一个虚拟的文件系统(还有其它的虚拟文件系统,例如usbfs和procfs),sysfs导出了内核的数据结构。
2. /sys/dev/ 和/sys/devices是sysfs按面向对象管理的思想来组织,sysfs最主要是用来描绘Linux kernel 2.6中的设备驱动模型,用户态的
后台程序会动态地周期性的扫描/sys目录中的属性项来自动管理设备文件(也称为设备节点),从而在/dev目录会建立或者删除对应的设备文件。

Documentation\filesystems

Top Level Directory Layout
~~~~~~~~~~~~~~~~~~~~~~~~~~

The sysfs directory arrangement exposes the relationship of kernel
data structures. 

The top level sysfs directory looks like:

block/
bus/
class/
dev/
devices/
firmware/
net/
fs/

<span style="color:#ff0000;">devices/ contains a filesystem representation of the device tree. It maps
directly to the internal kernel device tree, which is a hierarchy of
struct device.</span> 

bus/ contains flat directory layout of the various bus types in the
kernel. Each bus's directory contains two subdirectories:

	devices/
	drivers/

devices/ contains symlinks for each device discovered in the system
that point to the device's directory under root/.

drivers/ contains a directory for each device driver that is loaded
for devices on that particular bus (this assumes that drivers do not
span multiple bus types).

fs/ contains a directory for some filesystems.  Currently each
filesystem wanting to export attributes must create its own hierarchy
below fs/ (see ./fuse.txt for an example).

<span style="color:#ff0000;">dev/ contains two directories char/ and block/. Inside these two
directories there are symlinks named <major>:<minor>.  These symlinks
point to the sysfs directory for the given device.  /sys/dev provides a
quick way to lookup the sysfs interface for a device from the result of
a stat(2) operation.</span>

More information can driver-model specific features can be found in
Documentation/driver-model/. 
udev:
-----------------------------
udev is a device management 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 informs the udevd daemon when certain events happen. The udevd daemon is configured to respond to some events with actions. Always, it means adding/removing device file under /dev dynamically.

* When the kernel detects that a device has been added or removed, a uevent is sent to
the udevd daemon through a netlink socket
* When udevd receives the uevent, it matches its configured rules against the available
device attributes provided in sysfs
* If a match is found, one or more actions (e.g., create device node, remove device node,
install firmware, etc.) are taken

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

狂奔的乌龟

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值