Device File System Guide分析和总结分析和总结.docxVIP

  • 0
  • 0
  • 约1.16万字
  • 约 8页
  • 2023-04-25 发布于上海
  • 举报

Device File System Guide分析和总结分析和总结.docx

Disclaimer : This document is not valid and is not maintained anymore. Device File System Guide Content: What is devfs? The (good?) old days Warning: Warning: devfs is obsolete and has been removed from the stable 2.6 tree in the 2.6.13 release. Users on 2.6 kernels are hereby advised to switch to udev. For further information on udev, please refer to the Gentoo udev Guide. Traditional Linux implementations provide their users with an abstract device path, called /dev. Inside this path the user finds device nodes, special files that represent devices inside their system. For instance, /dev/hda represents the first IDE device in their system. By providing device files to the users, they can create programs that interact with hardware as if the hardware was a regular file instead of using special APIs. The device files are split in two groups, called character devices and block devices. The first group consists of hardware of which read/writes are not buffered. The second group naturally consists of hardware of which read/writes are buffered. Both devices can be read one character at a time, or in blocks. Therefore, the naming might sound confusing and in fact is wrong. If you take a look at a certain device file, you might find something like this: Code Listing 1.1: Checking the information of a device file # ls -l /dev/hda Code Listing 1.1: Checking the information of a device file # ls -l /dev/hda brw-rw 1 root disk 3, 0 Jul 5 2000 /dev/hda In the previous example we see that /dev/hda is a block device. However, more importantly, it has two special numbers assigned to it:3, 0. This pair is called the major-minor pair. It is used by the kernel to map a device file to a real device. The major corresponds with a certain device, the minor with a subdevice. Seems confusing? It isnt. Two examples are /dev/hda4 and /dev/tty5. The first device file corresponds with the fourth partition on the first IDE device. Its major-minor pair is 3, 4. In other words, the minor corresp

您可能关注的文档

文档评论(0)

1亿VIP精品文档

相关文档