Linux Kernel Architecture

(Jacob Rumans) #1

Chapter 10: Filesystems without Persistent Storage


❑ First, a four-level hierarchy is created with the help of sysctl tables.CTL_DEVis the base level
and has a child calledDEV_CDROM. This also has several child elements, one of which is called
DEV_CDROM_INFO.
❑ The new hierarchy is associated with the existing standard hierarchy in a linked list. This has the
effect of ‘‘overlaying‘‘ the two hierarchies. Seen from userspace, it is impossible to distinguish
between the hierarchies because they appear as a single overall hierarchy.

The sample program above used the sysctl described without having to know how the hierarchy
is represented in the kernel. All it needs to know to access the required information is the path
CTL_DEV->DEV_CDROM->DEVCDROM_INFO.

Of course, the contents of the/proc/sysdirectory in theprocfilesystem are also constructed in such a
way that the internal composition of the hierarchy is not visible.

Static SysctlTables


Static sysctl tables are defined for all sysctls, regardless of the system configuration.^4 Thebaseelementis
the table namedroot_table, which acts as the root of the statically defined data:

kernel/sysctl.c
static ctl_table root_table[];
static struct ctl_table_header root_table_header =
{ root_table, LIST_HEAD_INIT(root_table_header.ctl_entry) };

The table is given a header element so that additional hierarchies can be maintained in a linked list as
described above; these can be overlaid with the hierarchy defined byroot_table.Theroot_tabletable
defines the framework into which the various sysctls are sorted:

kernel/sysctl.c
static ctl_table root_table[] = {
{
.ctl_name = CTL_KERN,
.procname = "kernel",
.mode = 0555,
.child = kern_table,
},
{
.ctl_name = CTL_VM,
.procname = "vm",
.mode = 0555,
.child = vm_table,
},
#ifdef CONFIG_NET
{
.ctl_name = CTL_NET,
.procname = "net",
.mode = 0555,
.child = net_table,
},
#endif#
...

(^4) Even though sysctls of this kind are implemented on all architectures, their effect may differ from architecture to architecture.

Free download pdf