The Virtual Filesystem

In Linux the filesystems are separated from the kernel and from the system services by an interface layer known as the Virtual File system, or VFS.

When a developer wants to add support for a new filesystem to the kernel, a new filesystem driver must be written that knows how to access the relevant filesystems data structures.

Because the kernel provides the VFS abstraction layer, the filesystem driver is written to interface to this.

When the kernel needs to perform a common operation like writing a file to the disk, it will run a generic function that is a part of the VFS API. This relevant VFS function will look up the specific filesystem function to run for handling this request in the filesystem driver for the relevant filesystem on which this file is located. The kernel uses its mount table to determine which filesystem type and heads driver to use.

When a filesystem driver is loaded, it registers its specific functions in the VFS so that the kernel knows what functions to call from its generic VFS functions, and where they are located in memory. (see the section called “Device Drivers”)

Figure 8.12. The Virtual Filesystem

The Virtual Filesystem

The VFS interface provides support for many types of filesystems, and presents a unified interface to the Linux kernel, they look like a hierarchical tree structure that represents the filesystem as a whole entity.