Linux Kernel Architecture

(Jacob Rumans) #1

Chapter 10: Filesystems without Persistent Storage


The kernel provides thectl_table_headerdata structure to enable several sysctl tables to be maintained
in a linked list that can be traversed and manipulated using the familiar standard functions. The structure
is prefixed to a sysctl table in order to insert the elements needed for list management:

<sysctl.h>
struct ctl_table_header
{
ctl_table *ctl_table;
struct list_head ctl_entry;
...
};
ctl_tableis a pointer to a sysctl array (consisting ofctl_tableelements).ctl_entryholds the elements
required to manage the list. Figure 10-7 clearly illustrates the relationship betweenctl_table_header
andctl_table.^3

child

INFO CLOSEAUTO ...

child child

ctl_entry

DEV KERN ...

ctl_entry

DEV

... ... ... CDROM

Figure 10-7: Relationship betweenctl_table_headerand
ctl_table.

The hierarchical relationship between the various sysctl tables of the system is established by thechild
element ofctl_tableand by the linked list implemented usingctl_table_header. The linkage via
childenables a direct connection to be made between the various tables that map the sysctl hierarchy.

In the kernel it is possible to define various hierarchies in which sysctl tables are interlinked by means
ofchildpointers. However, because there may be just one overall hierarchy, the individual hierarchies
must be ‘‘overlaid‘‘ to form a single hierarchy. This situation is illustrated in Figure 10-7, in which there
are two independent hierarchies. One is the standard kernel hierarchy containing sysctls to query, for
example, the name of the host or the network status. This hierarchy also includes a container to supply
information on system peripherals.

The CD-ROM driver wants to export sysctls to output information on the CD-ROM drive of the sys-
tem. What is needed is a sysctl (in/proc/sys/dev/cdrom/infoin theprocfilesystem) that is a child of
CTL_DEVand provides, for example, general data to describe the drive. How does the driver go about
this?

(^3) The list elements are actually below the data elements, but, for reasons of presentability, I have turned this situation ‘‘on its head‘‘
in the figure.

Free download pdf