Linux Kernel Architecture

(Jacob Rumans) #1

Chapter 10: Filesystems without Persistent Storage


Two further steps are necessary to connect this data structure with sysfs:


  1. Create aksetthat corresponds to thekobj_typeby usingdecl_subsys.

  2. Register theksetwithregister_subsystem; this function ends up in callingkset_add
    which, in turn, callskobject_addto create an appropriate directory withcreate_dir.Once
    more, this function callspopulate_dir, which iterates over all default attributes and creates
    a sysfs file for each of them.


Because subelements of generic hard disks (i.e., partitions) are connected with the kset introduced above,
they automatically inherit all default attributes by virtue of thekobjectmodel.

10.4 Summary


Filesystems do not necessarily need to be backed by a physical block device, but their contents can also be
generated dynamically. This allows for passing information from the kernel to userland (and vice versa),
which can be easily obtained by regular file I/O operations. The/procfilesystem was one of the first
virtual filesystems used by Linux, and a more recent addition is sysfs, which presents a hierarchically
structured representation of (nearly) all objects known to the kernel.

This chapter also discussed some generic routines to implement virtual filesystems and additionally
considered how pseudo-filesystems that are not visible to userland carry information important for the
kernel itself.
Free download pdf