A
Sysfs
Sysfs to organize devices and buses connected to the system into a hierarchical file that can be
of space access to.
For a brief introduction to the Sysfs file system, you may want to know how SYSFS recognizes devices that exist in the system and should
What device number should be used. For drivers that have been programmed into the kernel, when detected by the kernel, they will be directly
Registers its object in Sysfs and does this when the module is loaded for a driver that is compiled into a module
。 Once the Sysfs file system is mounted (mounted to/sys), the built-in driver can be used by the user-space process and provided to Udev to create the device node in SYSFS registered data.
1. Sysfs mount point is the/sys directory, SYSFS is a virtual file system (there are other virtual files
Systems, such as USBFS and PROCFS), SYSFS exported the data structure of the kernel.
2./sys/dev/and/sys/devices are SYSFS organized according to the idea of object-oriented management, SYSFS is mainly used to depict the device driver model in Linux kernel 2.6, and the user-state daemon (UDEV) dynamically periodically scans/ SYS directory to automatically manage device files (also known as device nodes) to create or delete corresponding device files in the/dev directory.
B
Udev
Udev is a tool that dynamically updates device files, including devices, based on the state of the hardware devices in the system
File creation, deletion and so on. Device files are usually placed in the/dev directory, and after using Udev, only the devices that are actually present in the system are included under/dev. It is independent of the hardware platform, is located in the user space, needs the support of kernel Sysfs and TMPFS, SYSFS provides the device entrance and Uevent channel for Udev, and TMPFS provides storage space for udev device files.
In Unix and Unix-like systems, hardware devices can be accessed through special files in the/dev directory, which are also known as device files or device nodes. Reading and writing these files as normal files can use the kernel device driver to communicate with the hardware device, which is not the data on the read-write disk, and there are many resources on the web that describe the file details in the/dev directory. Previously, these special files were created with the Mknod command when the system was installed, and in recent years the Linux system began using Udev to manage the device files under/dev at runtime. If Udev creates a device file when the device is detected and deletes the files when the device is removed, including hot-swappable devices. Therefore, most of the device files in the/dev directory are only present in the system for the duration of the device. Udev builds the device files based on the messages that SYSFS exports to the user space.
The Udev and Sysfs of Linux