in Linux, the Virtual File System, or VFS is a layer between the kernel and the filesystems to mediate file access, improve effiency, and simplify filesystem level code. It acts as a switch between the kernel and filesystem drivers (such as ext2, smb, nfs, ufs, etc).

It has several internal interfaces:

file descriptors
handles (integers), that with the process id, map to an inode. This is the userspace view of a file.
Maps a directory/file name to it's VFS inode. These are cached by the VFS layer to improve efficiency.
a representation of a files metadata, such as the owner, time stamps, and permissions, as well as a filesystem-specific pointer (such as to an ext2 block).
This is a representation of a filesystems metadata, such as the device, blocksize, dirty flags, list of dirty inodes, and a pointer to the root inode of the filesystem.

VFS is responsible for handling system calls, such as open(), readdir(), poll(), read(), write(), stat(), etc, and then calling functions in the filesystem drivers. The filesystem layer is reponsible for handling the calls from the VFS, and translating the filesystem specific metadata to the VFS data formats.

VFS tracks the mountpoints, and does directory name resolution, using the mount point information, dentry cache, and calls into the filesystem to find a file. It is also responsible for handling quota, and deleting inodes when they become free (if a file is deleted when it is in use). It handles caching of directory entries and file meta-data and also provides functions to the filesystem layer to handle block-special and character-special devices (ie, to route /dev/null to the appropriate driver)

Further information is available in Documentation/vfs.txt in your kernel distribution.

  • Documentation/vfs.txt from kernel source.

To be a bit more abstract, a Virtual Filesystem (VFS) is simply an abstract interface to a specific filesystem implementation.

If something is supported by VFS, then it will be supported by the filesystems the Operating System supports, or at least return an error condition.

If you're familiar with Object Oriented Programming policy, then you can think of the VFS as an abstract, or virtual, base class.

Log in or register to write something here or to contact authors.