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.
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.
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 ().
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.
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 ().
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.
Finally,Sys_read ()Will return, and the process will resume execution.