The virtual file system is an abstraction of a physical file system implementation. It provides a consistent interface to multiple file systems, both local and remote. This consistent interface allows the user to view the directory tree on the running system as a single entity even when the tree is made up of a number of diverse file system types. The interface also allows the logical file system code in the kernel to operate without regard to the type of file system being accessed.
A virtual file system can also be viewed as a subset of the logical file system tree, that part belonging to a single file system implementation. A virtual file system can be physical (the instantiation of a physical file system), remote, or strictly logical. In the latter case, for example, a virtual file system need not actually be a true file system or entail any underlying physical storage device.
A virtual file system mount point grafts a virtual file system subtree onto the logical file system tree. This mount point ties together a mounted-over v-node (virtual node) and the root of the virtual file system subtree. A mounted-over, or stub, v-node points to a virtual file system, and the mounted VFS points to the v-node it is mounted over.
A virtual node (v-node) represents access to an object within a virtual file system. V-nodes are used only to translate a path name into a generic node (g-node).
A v-node is either created or used again for every reference made to a file by path name. When a user attempts to open or create a file, if the VFS containing the file already has a v-node representing that file, a use count in the v-node is incremented and the existing v-node is used. Otherwise, a new v-node is created.
Every path name known to the logical file system can be associated with, at most, one file system object. However, each file system object can have several names. Multiple names appear in the following cases:
A generic i-node (g-node) is the representation of an object in a file system implementation. There is a one-to-one correspondence between a g-node and an object in a file system implementation. Each g-node represents an object owned by the file system implementation.
Each file system implementation is responsible for allocating and destroying g-nodes. The g-node then serves as the interface between the logical file system and the file system implementation. Calls to the file system implementation serve as requests to perform an operation on a specific g-node.
A g-node is needed, in addition to the file system i-node, because some file system implementations may not include the concept of an i-node. Thus the g-node structure substitutes for whatever structure the file system implementation may have used to uniquely identify a file system object.
The logical file system relies on the file system implementation to provide valid data for the following fields in the g-node:
|gn_type||Identifies the type of object represented by the g-node.|
|gn_ops||Identifies the set of operations that can be performed on the object.|
Operations that can be performed upon a virtual file system and its underlying objects are divided into two categories. Operations upon a file system implementation as a whole (not requiring the existence of an underlying file system object) are called vfs operations. Operations upon the underlying file system objects are called v-node (virtual node) operations. Before writing specific virtual file system operations, it is important to note the requirements for a file system implementation.
File system implementations differ in how they implement the predefined operations. However, the logical file system expects that a file system implementation meets the following criteria:
There are two important data structures used to represent information about a virtual file system, the vfs structure and the v-node. Each virtual file system has a vfs structure in memory that describes its type, attributes, and position in the file tree hierarchy. Each file object within that virtual file system can be represented by a v-node.
The vfs structure contains the following fields:
|vfs_flag|| Contains the state flags:
|vfs_type||Identifies the type of file system implementation. Possible values for this field are described in the /usr/include/sys/vmount.h file.|
|vfs_ops||Points to the set of operations for the specified file system type.|
|vfs_mntdover||Points to the mounted-over v-node.|
|vfs_data||Points to the file system implementation data. The interpretation of this field is left to the discretion of the file system implementation. For example, the field could be used to point to data in the kernel extension segment or as an offset to another segment.|
|vfs_mdata||Records the user arguments to the mount call that created this virtual file system. This field has a time stamp. The user arguments are retained to implement the mntctl call, which replaces the /etc/mnttab table.|
Understanding Data Structures and Header Files for Virtual File Systems.
Configuring a Virtual File System.
List of Virtual File System Operations.
The mount subroutine, mntctl subroutine.