Linux Kernel design basics (iv) virtual file system

Source: Internet
Author: User

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.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.