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.
- dentries
- Maps a directory/file name to it's VFS inode. These are cached by the VFS layer to improve efficiency.
- inodes
- 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).
- superblocks
- 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.
Sources: - Documentation/vfs.txt from kernel source.
- http://www.coda.cs.cmu.edu/doc/talks/linuxvfs/