Process table/File Table/inode/vnode

Source: Internet
Author: User

Generally speaking, we say that the process has a file descriptor table, the file descriptor list pointer to an inode, which omitted the File,dentry object, on the exact understanding of the VFS structure is useless, this article in conjunction with the network, and according to APUE8.3 and LKD13.11 chapter proofreading, summarized in the next, Hope to be useful.

The kernel, which corresponds to each process, has a file descriptor that represents all the files opened by the process. Each item in the File description table is a pointer to a data block that describes the open file ——— the file object, which describes important information such as open mode, read and write location, and the kernel creates a new file object when the process opens. It is important to note that the file object is not dedicated to a process, and the pointers in the files descriptor tables of the different processes can point to the same file object, thereby sharing the open files. The file object has a reference count, which records the number of filename descriptors that reference the object, and the kernel destroys the file object only if the reference count is 0 o'clock, so a process closes it without affecting the process that shares the same file object with it.

The file object contains a pointer to the Dentry object.  The Dentry object represents a separate file path, and if a file path is opened more than once, multiple file objects are created, but they all point to the same Dentry object. The Dentry object also contains a pointer to the Inode object. The Inode object represents a separate file.  Because there are hard links and symbolic links, different dentry objects can point to the same Inode object. The Inode object contains all the information that is required to eventually manipulate the file, such as the file system type, how the file is manipulated, the permissions of the file, the date of access, and so on. After opening the file, the process obtains the file descriptor is essentially the file descriptor of the subscript, the kernel according to the subscript value to access the corresponding file object, so as to achieve the operation of the file.



Note that the kernel creates multiple file objects when the same file is opened multiple times by the same process. When a process uses a fork system call to create a child process, the child process inherits the file descriptor of the parent process, so files opened in the parent process can be accessed in the child process with the same descriptor.

about Vnode Nodesis part of the VFS, and I haven't had time to verify it, but as MOS (modern OS) 10.6.4 says, Vnode is used to identify whether the inode is local or remote, and it belongs to the idea of NFS. Make up again later.

Process table/File Table/inode/vnode

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.