/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导出了内核的数据结构。后台程序会动态地周期性的扫描/sys目录中的属性项来自动管理设备文件(也称为设备节点),从而在/dev目录会建立或者删除对应的设备文件。

Documentation\filesystems

Top Level Directory Layout~~~~~~~~~~~~~~~~~~~~~~~~~~The sysfs directory arrangement exposes the relationship of kerneldata 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 mapsdirectly to the internal kernel device tree, which is a hierarchy ofstruct device.</span> bus/ contains flat directory layout of the various bus types in thekernel. Each bus's directory contains two subdirectories:devices/drivers/devices/ contains symlinks for each device discovered in the systemthat point to the device's directory under root/.drivers/ contains a directory for each device driver that is loadedfor devices on that particular bus (this assumes that drivers do notspan multiple bus types).fs/ contains a directory for some filesystems. Currently eachfilesystem wanting to export attributes must create its own hierarchybelow fs/ (see ./fuse.txt for an example).<span style="color:#ff0000;">dev/ contains two directories char/ and block/. Inside these twodirectories there are symlinks named <major>:<minor>. These symlinkspoint to the sysfs directory for the given device. /sys/dev provides aquick way to lookup the sysfs interface for a device from the result ofa stat(2) operation.</span>More information can driver-model specific features can be found inDocumentation/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 tothe udevd daemon through a netlink socket* When udevd receives the uevent, it matches its configured rules against the availabledevice 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

用敬业的精神去面对每一份挑战,

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

相关文章:

你感兴趣的文章:

标签云: