Linux Kernel Architecture

(Jacob Rumans) #1

Chapter 8: The Virtual Filesystem


nameholds the filesystem name as a string (and therefore contains values such asreiserfs,ext3,andthe
like).fs_flagsare flags used, for example, to indicate Read Only mounting, to disallow setuid/setgid
execution, or to make other fine adjustments.owneris a pointer to a module structure that only con-
tains a value if the filesystem was loaded as a module (a null pointer indicates a filesystem permanently
compiled into the kernel).

The available filesystems are linked by means of thenextelement, whichcannotuse standard list func-
tions because the list is linked in one direction only.

The most interesting entries arefs_supersand the function pointerget_sb. A superblock structure
is created in memory for each mounted filesystem. This structure holds relevant information on the
filesystem itself and on the mount point. Because several filesystemsof the same typecan be mounted
(the best example is of a filesystem of the same type on the home and root partition), several superblock
structures exist for a single filesystem type and are grouped together in a linked list.fs_supersis
the corresponding list head. Further details are provided in the information below on filesystem
mounting.

Also of great importance for the mount process is the function (stored in theget_sb)forreading
the superblock of the underlying storage medium. Logically, this function depends on the specific
filesystem and cannot be implemented as an abstraction. Neither can the function be held in the above
super_operationsstructure because the superblock object and the pointer to this structure are not
created untilget_sbis invoked.

kill_superperforms clean-up work when a filesystem type is no longer needed.

Mountingand Unmounting


Mounting and unmounting directory trees is much more complex than simply registering filesystems
because the actions required on kernel-internal data structures are considerably more complicated than
adding objects to a linked list. Filesystem mounting is initiated by themountsystem call. Before dis-
cussing the individual steps in detail, we need to clarify which tasks must be performed to mount a new
filesystem in an existing directory tree. We also need to look at the data structure used to describe mount
points.

VFS Mount Structures


Unixemploys a single filesystem hierarchy into which new filesystems can be integrated, as shown in
Figure 8-4.

/

bin mnt

tmp data

usr

share bin cdrom

src libs

Ext2

Reiserfs

ISO9660

Figure 8-4: Filesystem hierarchy with various filesystem types.
Free download pdf