vfs_hooks(9)
- NetBSD Manual Pages
VFS_HOOKS(9) NetBSD Kernel Developer's Manual VFS_HOOKS(9)
NAME
vfs_hooks, vfs_hooks_unmount -- VFS hooks interface
SYNOPSIS
#include <sys/param.h>
#include <sys/mount.h>
void
vfs_hooks_unmount(struct mount *mp);
DESCRIPTION
The VFS hooks interface provides a way for different kernel subsystems to
attach custom functions to specific VFS operations. This enforces code
separation by keeping the VFS's core sources uncluttered and makes all
subsystem functionality reside in a single place. As an example, this
interface is used by the NFS server code to automatically handle the
exports list for each mount point.
Hooks are described by a struct vfs_hooks object, as seen below:
struct vfs_hooks {
int (*vh_unmount)(struct mount *);
};
For simplicity, each field is named after the VFS operation it refers to.
The purpose of each member function, alongside some important notes, is
shown below:
vh_unmount(mp)
This hook is executed during the unmount process of a file sys-
tem.
For more information about the purpose of each operation, see vfsops(9).
Note that any of these fields may be a null pointer.
After the definition of a struct vfs_hooks object, the kernel has to add
it to the vfs_hooks link set using the VFS_HOOKS_ATTACH(struct vfs_hooks
*) macro.
Please note that this interface is incomplete on purpose to keep it in
its smallest possible size (i.e., do not provide a hook that is not
used). If you feel the need to hook a routine to a VFS operation that is
not yet supported by this interface, just add it to the files described
in CODE REFERENCES.
FUNCTIONS
The following functions are provided to the VFS code to run the hooked
functions:
vfs_hooks_unmount(mp)
Runs all hooks for the VFS unmount operation. Given that these
operations shall not fail, it returns void.
CODE REFERENCES
The VFS hooks interface is implemented within the files
sys/kern/vfs_hooks.c and sys/sys/mount.h.
SEE ALSO
intro(9), vfs(9), vfsops(9)
HISTORY
The VFS hooks interface appeared in NetBSD 4.0.
NetBSD 10.99 September 23, 2005 NetBSD 10.99
Powered by man-cgi (2021-06-01).
Maintained for NetBSD
by Kimmo Suominen.
Based on man-cgi by Panagiotis Christias.