VFS concept

  

Linux can support various file systems except the Ext2 file system because Linux provides a unified framework, called virtual file system switch (Virtual FilesystemSwitch), referred to as virtual file. System (VFS). In this way, the user program can operate on various file systems and files through the same file system interface, that is, the same set of system calls.

1. Linux supports dozens of file systems, how is it managed, and what does it manage?

First, VFS only manages the file system mounted to the file system, ie it is managed on demand.

Secondly, because it inherits the design of Unix, it also manages files, directory entries, inodes, and superblocks.

2. Four main objects in VFS

(1) Super Block Object: Describes the mounted file system.

Each file system corresponds to a super object. The file system control information is stored in the super block. (2) Index node object: describes a file.

Each file has an inode object. Each index node object has an inode number -----> It is this number to uniquely identify the specified file in a file system. (3) Directory Item Object: Describes a directory entry that is part of the path.

VFS treats each directory as a regular file consisting of several subdirectories and files.

For example: when we look up the path name: /tmp/test, the kernel creates the first directory entry object for the root directory “/”, and creates a second-level directory entry object for the tmp entry in the root directory. Create a third-level directory entry object for the test entry in the /tmp directory. (4) File object: describes the file opened by the process.

Description:

1. Because VFS treats directories as a file, there are no directory objects. Although the directory entry is different from the directory, the directory is the same as the file.

2.Linux separates the information about the file from the file itself. Information about files in Linux is stored in a separate data structure called an inode. The file (directory) information is stored in a separate block in the form of an inode; the control information is stored centrally in the superblock of the disk.

Copyright © Windows knowledge All Rights Reserved