x
Loading
 Loading
Hello, Guest | Login | Register

Want to Know What’s Really Going On in the /dev Directory? A Look at devfs

The role of the kernel is mostly related to hardware control, as user-space programs need a way of referring to hardware devices that they wish to use. Some hardware devices are used implicitly, through interfaces such as sockets or filesystems. However, it is often necessary to refer to a hardware device directly — such as a particular serial port or hard-disk partition. This is accomplished through the use of special device files that are usually found in the /dev directory. The special files are not associated with data stored in the disk; rather, they correspond to particular hardware devices. When user programs access and use these special files, the operation is passed to a device driver in the system kernel. For example, when you issue an open and a read on the /dev/ttyS0 file, data is read from a serial port; the serial-port device driver is invoked whenever /dev/ttyS0 is accessed.

The role of the kernel is mostly related to hardware control, as user-space programs need a way of referring to hardware devices that they wish to use. Some hardware devices are used implicitly, through interfaces such as sockets or filesystems. However, it is often necessary to refer to a hardware device directly — such as a particular serial port or hard-disk partition. This is accomplished through the use of special device files that are usually found in the /dev directory. The special files are not associated with data stored in the disk; rather, they correspond to particular hardware devices. When user programs access and use these special files, the operation is passed to a device driver in the system kernel. For example, when you issue an open and a read on the /dev/ttyS0 file, data is read from a serial port; the serial-port device driver is invoked whenever /dev/ttyS0 is accessed.

All Unix systems provide a directory, conventionally called /dev, where device files are held; however, each Unix variant uses a different name layout inside that directory. Until recently, Linux systems were required to store the /dev directory on disk. What this means is that /dev includes directory entries for every possible device driver, which may not correspond to the particular hardware available on the system.

The static nature of information stored on disk makes it difficult to dynamically add and remove device files whenever drivers are loaded and unloaded from the kernel, which makes…

Please log in to view this content.

Not Yet a Member?

Register with LinuxMagazine.com and get free access to the entire archive, including:

  • Hands-on Content
  • White Papers
  • Community Features
  • And more.
Already a Member?
Log in!
Username

Password

Remember me

Forgotten your password?
Forgotten your username?
Read More
  1. Power Up Linux GUI Apps
  2. Tweeting from the Command Line with Twyt
  3. When Memory Serves You: Using ramfs and tmpfs
  4. Disk-O-Tech: Linux Disk Management
  5. Bang for the Buck
Follow Linux Magazine
Rackspace