3

I am trying to understand what the VFS is in Linux, the following diagram represents the VFS:

enter image description here

What I am not sure about is whether the VFS is a program that the Application talks to and then the VFS talks to the appropriate file system driver, or is the VFS just an interface/common language that the file system drivers must implement, and in reality the Application is talking directly with the file systems drivers using this interface/common language?

1
  • VFS is an interface. It lives in the kernel.
    – jordanm
    Apr 12 '18 at 13:52
4

The VFS is an interface layer in the kernel. It provides a uniform interface for applications to talk to file systems, regardless of the file system in use: thus system calls such as open, write, read all go to the VFS layer, which then dispatches them to the appropriate file system.

File systems register themselves with the VFS layer and provide a standard set of information, so that the VFS layer can use them. This means that all file systems in Linux need to implement similar concepts: mainly inodes, directory entries, and files.

This is documented in detail in the kernel.

1

VFS is an entire software layer in the kernel situated between the system calls and the filesystem drivers, it is not a filesystem in its own right.

It provides a common interface to multiple file system types.

Imagine for example we use the command:

cp /usb/file /tmp/file

/usb is mounted on a fat32 USB, /tmp is a etx2 filesytem.

VFS layer sits between the application and the file system, so the cp command does not need to know the file system in which is it performing the copy. Instead cp interacts with VFS using generic system calls eg: open,write,read etc....

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.