Linux Kernel Architecture

(Jacob Rumans) #1

Chapter 10: Filesystems without Persistent Storage


Chapter 10: Filesystems without Persistent Storage.......................


strings. The filesystem is, however, very useful for tools that want to gather detailed infor-
mation about the hardware present in a system and the topological connection between the
devices.
It is also possible to create sysfs entries for kernel objects that usekobjects(seeChapter1
for more information) with little effort. This gives userland easy access to important core
kernel data structures.

❑ Small filesystems that serve a specific purpose can be constructed from standard func-
tions supplied by the kernel. The in-kernel library that provides the required functions
is calledlibfs. Additionally, the kernel provides means to implement sequential files with
ease. Both techniques are put together in the debugging filesystem debugfs, which allows
kernel developers to quickly export values to and import values from userland without the
hassle of having to create custom interfaces or special-purpose filesystems.

10.1 The proc Filesystem


As mentioned at the beginning of this chapter, theprocfilesystem is avirtualfilesystem whose informa-
tion cannot be read by a block device. Information is generated dynamically only when the contents of a
file are read.

Using theprocfilesystem, information can be obtained on the kernel subsystems (e.g., memory uti-
lization, peripherals attached, etc.) and kernel behavior can be modified without the need to recompile
the sources, load modules, or reboot the system. Closely related to this filesystem is the system control
mechanism —sysctlfor short — which has been frequently referenced in previous chapters. Theproc
filesystem provides an interface to all options exported using this mechanism, thus allowing parameters
to be modified with little effort. No special communication programs need be developed — all that is
required is a shell and the standardcatandechoprograms.

Usually, the process data filesystem (its full name) is mounted in/proc, from which it obviously
derives its more frequently used abbreviated name (procFS). Nevertheless, it is worth noting that the
filesystem — like any other filesystem — can be mounted at any other point in the file tree, although this
would be unusual.

The section below describes the layout and contents of theprocfilesystem to illustrate its functions and
options before we move on to examine its implementation details.

10.1.1 Contents of /proc


Although the size of theprocfilesystem varies from system to system (different data are exported
depending on hardware configuration, and different architectures affect its contents) it nevertheless con-
tains a large number of deeply nested directories, files, and links. However, this wealth of information
can be grouped into a few larger categories:

❑ Memory management
❑ Characteristic data of system processes

Simple Filesystems


❑ Device drivers
Free download pdf