VFS Virtual Filesystem

V

Virtual Filesystem, also known as VFS, is a component of the kernel that handles all system calls related to files and file systems. VFS is a generic interface between the user and a particular file system. This simplifies the implementation of file systems and provides easy integration of multiple file systems.

In this way, the implementation of a file system is achieved by using the API provided by VFS and the generic parts of communication with the hardware device and the I/O subsystem are resolved by VFS.

From a functional point of view, file systems can be grouped into:
– disk file systems (ext3, ext4, xfs, fat, ntfs, etc.)
– file files for the network (nfs, smbfs / cifs, ncp, etc.)
– virtual file systems (procfs, sysfs, sockfs, pipefs, etc.)

A Linux kernel instance will use VFS for the (tree type) hierarchy of directories and files. A new file system will be added as a VFS sub-tree through the mount operation. Each file system is usually mounted from the environment for which it was built from a block device, network, etc.

In particular, however, the VFS can use as a virtual block device a normal file, so you can mount disk file systems over normal files. Thus, stacks of file systems can be created.
The basic idea of ​​the VFS is to provide a single file model that can represent the files in any file system. The file system driver is responsible for bringing the common denominator. Thus, a single directory structure can be created that contains the entire system. There will be a file system that will be the root, the rest being mounted in its various directories.
The general model of the file system, to which any implemented file system must be reduced, consists of several entities with well defined role: superblock, inode, tab and dentry. These entities are file system metadata (they contain information about data or other metadata).
Model entities interact with VFS or kernel subsystems: dentry cache, inode cache, buffer cache. Each entity is treated as an object: it has an associated data structure and a pointer to a method table. Induction of a particular behavior of each component is done by replacing the associated methods.

The superblock stores the information needed for a mounted file system:

    – zones of inodes, blocks
    – the size of the file system block
    – maximum length of file names
    – maximum file size
    – the root location of the inode

The inode maintains information about a file in the general sense: common file, directory, special file, block device, character device, link, or whatever can be abstracted as a file.

An inode holds information such as:

    – file type;
    – file size;
    – access rights;
    – the time of access or modification;
    – positioning the data on the disk (pointers to the blocks on the disk containing data).

File is the component of the general model of the file system that is closest to the user. The structure exists only as a VFS entity in memory and has no physical correspondent on disk.

The file structure holds information such as:

    – the position of the file cursor;
    – file opening rights;
    – pointer to the associated inode.

Dentry associates an inode with the file name. In general, a dentry structure contains two fields:
    – an integer that identifies the inode;
    -a string representing its name.
The functions of the VFS usually receive as a parameter the superblock, an inode and/or a dentry, which contain a pointer to the superblock, so that this private data can be easily accessed.

Recent Posts

Archives

Categories