Linux Kernel Architecture

(Jacob Rumans) #1

Filesystems without


Persistent Storage


Traditionally, filesystems are used to store data persistently on block devices. However, it is also
possible to use filesystems to organize, present, and exchange information that is not stored on
block devices, but dynamically generated by the kernel. This chapter examines some of them:


❑ Theproc filesystemenables the kernel to generate information on the state and con-
figuration of the system. This information can be read from normal files by users
and system programs without the need for special tools for communication with the
kernel; in some cases, a simplecatis sufficient. Data can not only be read from the
kernel, but also sent to it by writing character strings to a file of theprocfilesystem.
echo "value" > /proc/file— there’s no easier way of transferring information from
userspace to the kernel.
This approach makes use of avirtualfilesystem that generates file information ‘‘on the fly,’’
in other words, only when requested to do by read operations. A dedicated hard disk par-
tition or some other block storage device is not needed with filesystems of this type.
In addition to theprocfilesystem, the kernel provides many other virtual filesystems for
various purposes, for example, for the management of all devices and system resources
cataloged in the form of files in hierarchically structured directories. Even device drivers
can make status information available in virtual filesystems, the USB subsystem being one
such example.

❑ Sysfsis one particularly important example of another virtual filesystem that serves a sim-
ilar purpose to procfs on the one hand, but is rather different on the other hand. Sysfs is,
per convention, always mounted at/sys, but there is nothing that would prevent includ-
ing it in other places. It was designed to export information from the kernel into userland
at a highly structured level. In contrast to procfs, it was not designed for direct human
use because the information is deeply and hierarchically nested. Additionally, the files do
not always contain information in ASCII text form, but may well use unreadable binary
Free download pdf