Let's take a look at the execution of the write file function:
ret = Write (FD, buf, Len);
Write applies to various file systems, which first executes Sys_write (), and it is this sys_write () that makes the actual file system type Discriminant and performs a write operation under that type of file system. We can see that in a variety of file systems abstracted a generic interface nature of the virtual file system.
We are very concerned about how Linux 2.6 is going to implement VFS. Let's take a look at the four main object types in the VFS:
- A super Block object that represents a specific installed file system.
- An index node object that represents a specific file.
- A catalog item object that represents a catalog item and is an integral part of the path.
- A file object that represents the file opened by the process.
Super BlockThis object is used to store information for a particular file system, represented by the super_block structure. When the file system is installed, the file system calls Alloc_super () to read the file system Super block from the disk and populate it with information into the in-memory super-block object. Use a super block to manipulate an index node, such as Create and initialize, release, write to disk, and so on.
Index node Inodeused to represent a file that contains all the information the kernel needs to manipulate a file or directory. The existence of the inode is the separation of the data and control information of the file, which is described by the struct struct inode. Our common file manipulation create (create file), mkdir (Create new directory), etc., are all indexed node objects to complete.
Catalog Item ObjectThe directory itself is treated as a file in the VFS, so the directory is not a directory item object. The Catalog item object is introduced for easy lookup and is described with struct struct dentry.
File ObjectDoes not use the inode to describe the file, how to have a file object. This file object represents the file that the process has opened, which is an in-memory representation of the opened file. Because multiple processes can open and manipulate a file at the same time, multiple file objects may exist for the same file. Described with struct file, common operations such as open (), write (), and so on.