Linux Virtual File System

Source: Internet
Author: User
From: http://personal.denison.edu /~ Bressoud/cs372-f05/geekos_project/fsproject.html

Figure 10.1. Overview of the virtual filesystem (VFS)

The VFS layer works by dispatching requests for filesystem operations (such as opening, reading, or writing a file) to the appropriate filesystem implementation. the VFS works by defining several abstract PES ypes representing mounted filesystem instances, open files, and open directories. each of these datatypes containsVirtual function tableWhich contains pointers to functions in the filesystem that the object belongs to. For example,FileObjects Created by the gosfs filesystem have a virtual function table whoseRead ()Entry points to the FunctionGosfs_read ().

To give you an idea of how VFS works, here is what happens when a user process reads data from an open file in a gosfs filesystem.

  1. The process calltheRead ()In the C library, which generates a software interrupts to handle y the kernel that a system call is requested. it passes a file descriptor identifying the open file, the address of the buffer to store the data read from the file, and the number of bytes requested.

  2. The kernel calltheSys_read ()System Call handler function. This function will look at the process's open file list (inUser_context) To findFileObject representing the open file. It will also need to allocate a kernel buffer to temporarily hold the data read from the file. It will then call the kernel VFS FunctionRead ().

  3. The VFSRead ()Will find the address ofReadFunction in the file's virtual function table. Because the file is part of a gosfs filesystem, this will resolve toGosfs_read ()Function.

  4. Gosfs_read ()Will do whatever work is necessary to read the requested data from the file, at the current file position, copying the data into the kernel buffer createdSys_read ().

  5. When control returnsSys_read (), It will copy the data read from the kernel buffer to the user buffer (usingCopy_to_user ()Function), and destroy the kernel buffer.

  6. Finally,Sys_read ()Will return, and the process will resume execution.

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.