In a similar fashion to the
vnode(9) interface, all operations that are done on a file system are conducted through a single interface that allows the system to carry out operations on a file system without knowing its construction or type.
All supported file systems in the kernel have an entry in the
vfs_list_initial table. This table is generated by
config(1) and is a
NULL-terminated list of
vfsops structures. The vfsops structure describes the operations that can be done to a specific file system type. The following table lists the elements of the vfsops vector, the corresponding invocation macro, and a description of the element.
Vector element
Macro
Description
int (*vfs_mount)()
VFS_MOUNT
Mount a file system
int (*vfs_start)()
VFS_START
Make operational
int (*vfs_unmount)()
VFS_UNMOUNT
Unmount a file system
int (*vfs_root)()
VFS_ROOT
Get the file system root vnode
int (*vfs_quotactl)()
VFS_QUOTACTL
Query/modify space quotas
int (*vfs_statvfs)()
VFS_STATVFS
Get file system statistics
int (*vfs_sync)()
VFS_SYNC
Flush file system buffers
int (*vfs_vget)()
VFS_VGET
Get vnode from file id
int (*vfs_fhtovp)()
VFS_FHTOVP
NFS file handle to vnode lookup
int (*vfs_vptofh)()
VFS_VPTOFH
Vnode to NFS file handle lookup
void (*vfs_init)()
-
Initialize file system
void (*vfs_reinit)()
-
Reinitialize file system
void (*vfs_done)()
-
Cleanup unmounted file system
int (*vfs_mountroot)()
-
Mount the root file system
int (*vfs_snapshot)()
VFS_SNAPSHOT
Take a snapshot
int (*vfs_suspendctl)()
VFS_SUSPENDCTL
Suspend or resume
Some additional non-function members of the vfsops structure are the file system name
vfs_name and a reference count
vfs_refcount. It is not mandatory for a file system type to support a particular operation, but it must assign each member function pointer to a suitable function to do the minimum required of it. In most cases, such functions either do nothing or return an error value to the effect that it is not supported.
vfs_reinit,
vfs_mountroot,
vfs_fhtovp, and
vfs_vptofh may be
NULL.
At system boot, each file system with an entry in
vfs_list_initial is established and initialized. Each initialized file system is recorded by the kernel in the list
vfs_list and the file system specific initialization function
vfs_init in its vfsops vector is invoked. When the file system is no longer needed
vfs_done is invoked to run file system specific cleanups and the file system is removed from the kernel list.
At system boot, the root file system is mounted by invoking the file system type specific
vfs_mountroot function in the vfsops vector. All file systems that can be mounted as a root file system must define this function. It is responsible for initializing to list of mount structures for all future mounted file systems.
Kernel state which affects a specific file system type can be queried and modified using the
sysctl(8) interface.