1 .\" $NetBSD: vfs_hooks.9,v 1.3 2006/01/16 22:05:21 yamt Exp $
3 .\" Copyright (c) 2005 The NetBSD Foundation, Inc.
4 .\" All rights reserved.
6 .\" This code is derived from software contributed to The NetBSD Foundation
7 .\" by Julio M. Merino Vidal.
9 .\" Redistribution and use in source and binary forms, with or without
10 .\" modification, are permitted provided that the following conditions
12 .\" 1. Redistributions of source code must retain the above copyright
13 .\" notice, this list of conditions and the following disclaimer.
14 .\" 2. Redistributions in binary form must reproduce the above copyright
15 .\" notice, this list of conditions and the following disclaimer in the
16 .\" documentation and/or other materials provided with the distribution.
18 .\" THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
19 .\" ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
20 .\" TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
21 .\" PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
22 .\" BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
23 .\" CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
24 .\" SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
25 .\" INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
26 .\" CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
27 .\" ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
28 .\" POSSIBILITY OF SUCH DAMAGE.
30 .Dd September 23, 2005
36 .Nd VFS hooks interface
41 .Fn vfs_hooks_unmount "struct mount *mp"
43 The VFS hooks interface provides a way for different kernel subsystems to
44 attach custom functions to specific VFS operations.
45 This enforces code separation by keeping the VFS's core sources uncluttered
46 and makes all subsystem functionality reside in a single place.
47 As an example, this interface is used by the NFS server code to automatically
48 handle the exports list for each mount point.
50 Hooks are described by a
52 object, as seen below:
55 int (*vh_unmount)(struct mount *);
59 For simplicity, each field is named after the VFS operation it refers to.
60 The purpose of each member function, alongside some important notes, is
62 .Bl -tag -width compat
63 .It Fn vh_unmount "mp"
64 This hook is executed during the unmount process of a file system.
67 For more information about the purpose of each operation, see
69 Note that any of these fields may be a null pointer.
71 After the definition of a
73 object, the kernel has to add it to the
76 .Fn VFS_HOOKS_ATTACH "struct vfs_hooks *"
79 Please note that this interface is incomplete on purpose to keep it in its
80 smallest possible size (i.e., do not provide a hook that is not used).
81 If you feel the need to hook a routine to a VFS operation that is not yet
82 supported by this interface, just add it to the files described in
85 The following functions are provided to the VFS code to run the hooked
87 .Bl -tag -width compact
88 .It Fn vfs_hooks_unmount "mp"
89 Runs all hooks for the VFS unmount operation.
90 Given that these operations shall not fail, it returns
94 The VFS hooks interface is implemented within the files
95 .Pa sys/kern/vfs_hooks.c
103 The VFS hooks interface appeared in