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

您所在的位置:网站首页 怎么查所在辖区派出所电话 /dev、/sys/devices 和 /sys/dev 之间区别

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

2023-08-20 23:27| 来源: 网络整理| 查看: 265

/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/ 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. 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). dev/ contains two directories char/ and block/. Inside these two directories there are symlinks named :. 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. 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



【本文地址】


今日新闻


推荐新闻


    CopyRight 2018-2019 办公设备维修网 版权所有 豫ICP备15022753号-3