xref: /netbsd-src/share/man/man9/vfssubr.9 (revision de1dfb1250df962f1ff3a011772cf58e605aed11)
1.\"     $NetBSD: vfssubr.9,v 1.10 2004/04/21 01:05:35 christos Exp $
2.\"
3.\" Copyright (c) 2003 The NetBSD Foundation, Inc.
4.\" All rights reserved.
5.\"
6.\" This code is derived from software contributed to The NetBSD Foundation
7.\" by Gregory McGarry.
8.\"
9.\" Redistribution and use in source and binary forms, with or without
10.\" modification, are permitted provided that the following conditions
11.\" are met:
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.
17.\" 3. All advertising materials mentioning features or use of this software
18.\"    must display the following acknowledgement:
19.\"        This product includes software developed by the NetBSD
20.\"        Foundation, Inc. and its contributors.
21.\" 4. Neither the name of The NetBSD Foundation nor the names of its
22.\"    contributors may be used to endorse or promote products derived
23.\"    from this software without specific prior written permission.
24.\"
25.\" THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
26.\" ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
27.\" TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
28.\" PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
29.\" BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
30.\" CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
31.\" SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
32.\" INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
33.\" CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
34.\" ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
35.\" POSSIBILITY OF SUCH DAMAGE.
36.\"
37.Dd January 10, 2004
38.Dt VFSSUBR 9
39.Os
40.Sh NAME
41.Nm vfssubr ,
42.Nm vfs_getnewfsid ,
43.Nm vfs_getvfs ,
44.Nm vfs_export ,
45.Nm vfs_showexport ,
46.Nm vfs_export_lookup ,
47.Nm vfs_setpublicfs ,
48.Nm vfs_mountedon ,
49.Nm vfs_mountroot ,
50.Nm vfs_unmountall ,
51.Nm vfs_busy ,
52.Nm vfs_unbusy ,
53.Nm vfs_rootmountalloc ,
54.Nm vfs_shutdown ,
55.Nm vfs_attach ,
56.Nm vfs_detach ,
57.Nm vfs_reinit ,
58.Nm vfs_getopsbyname ,
59.Nm vfs_write_suspend ,
60.Nm vfs_write_resume
61.Nd high-level interface to kernel file system interface
62.Sh SYNOPSIS
63.In sys/param.h
64.In sys/mount.h
65.In sys/vnode.h
66.Ft void
67.Fn vfs_getnewfsid "struct mount *mp"
68.Ft struct mount *
69.Fn vfs_getvfs "fsid_t *fsid"
70.Ft int
71.Fn vfs_export "struct mount *mp" "struct netexport *nep" \
72"struct export_args *argp"
73.Ft void
74.Fn vfs_showexport "struct mount *mp" "struct export_args *argp" \
75"struct netexport *nep"
76.Ft int
77.Fn vfs_export_lookup "struct mount *mp" "struct netexport *nep" \
78"struct export_args *argp"
79.Ft int
80.Fn vfs_setpublicfs "struct mount *mp" "struct netexport *nep" \
81"struct export_args *argp"
82.Ft int
83.Fn vfs_mountedon "struct vnode *vp"
84.Ft int
85.Fn vfs_mountroot "void"
86.Ft void
87.Fn vfs_unmountall  "struct proc *p"
88.Ft int
89.Fn vfs_busy "struct mount *mp" "int flags" "struct simplelock *interlkp"
90.Ft void
91.Fn vfs_unbusy "struct mount *mp"
92.Ft int
93.Fn vfs_rootmountalloc "char *fstypename" "char *devname" \
94"struct mount **mpp"
95.Ft void
96.Fn vfs_shutdown "void"
97.Ft int
98.Fn vfs_attach "struct vfsops *vfs"
99.Ft int
100.Fn vfs_detach "struct vfsops *vfs"
101.Ft void
102.Fn vfs_reinit "void"
103.Ft struct vfsops *
104.Fn vfs_getopsbyname "const char *name"
105.Ft int
106.Fn vfs_write_suspend "struct mount *mp" "int slpflag" "int slptimeo"
107.Ft void
108.Fn vfs_write_resume "struct mount *mp"
109.Sh DESCRIPTION
110The high-level functions described in this page are the interface to
111the kernel file system interface (VFS).
112.Sh FUNCTIONS
113.Bl -tag -width compact
114.It Fn vfs_getnewfsid "mp"
115Get a new unique file system id type for the file system specified by
116the mount structure
117.Fa mp .
118The file system id type is stored in
119.Em mp-\*[Gt]mnt_stat.f_fsidx .
120.It Fn vfs_getvfs "fsid"
121Lookup a mount point with the file system identifier
122.Fa fsid .
123.It Fn vfs_export "mp" "nep" "argp"
124Undocumented.
125.It Fn vfs_showexport "mp" "argp" "nep"
126Undocumented.
127.It Fn vfs_export_lookup "mp" "nep" "argp"
128Check client permission on the exportable file system specified by the
129mount structure
130.Fa mp .
131The argument
132.Fa nam
133is the address of the networked client.
134This function is used by file system type specific functions to verify
135that the client can access the file system.
136.It Fn vfs_setpublicfs "mp" "nep" "argp"
137Set the publicly exported file system specified by the mount structure
138.Fa mp .
139.It Fn vfs_mountedon "vp"
140Check to see if a file system is mounted on a block device specified
141by the vnode
142.Fa vp .
143.It Fn vfs_mountroot "void"
144Mount the root file system.
145.It Fn vfs_unmountall "p"
146Unmount all file systems.
147.It Fn vfs_busy "mp" "flags" "interlkp"
148Mark the mount point specified by
149.Fa mp
150as busy.
151This function is used to synchronize access and to delay unmounting.
152The interlock specified by argument
153.Fa interlkp
154is not released on failure.
155.It Fn vfs_unbusy "mp"
156Free the busy file system specified by the mount structure
157.Fa mp .
158.It Fn vfs_rootmountalloc "fstypename" "devname" "mpp"
159Lookup a file system type specified by the name
160.Fa fstypename
161and if found allocate and initialise a mount structure for it.
162The allocated mount structure is returned in the address specified by
163.Fa mpp .
164The device the root file system was mounted from is specified by the
165argument
166.Fa devname
167and is recorded in the new mount structure.
168.It Fn vfs_shutdown
169Sync and unmount all file systems before shutting down.
170Invoked by
171.Xr cpu_reboot 9 .
172.It Fn vfs_attach "vfs"
173Establish file system
174.Fa vfs
175and initialise it.
176.It Fn vfs_detach "vfs"
177Remove file system
178.Fa vfs
179from the kernel.
180.It Fn vfs_reinit "void"
181Reinitialises all file systems within the kernel through file
182system-specific vfs operation (see
183.Xr vfsops 9 ) .
184.It Fn vfs_getopsbyname "name"
185Given a file system name specified by
186.Fa name ,
187look up the vfs operations for that file system (see
188.Xr vfsops 9 ) ,
189or return
190.Dv NULL
191if file system isn't present in the kernel.
192.It Fn vfs_write_suspend "mp" "slpflag" "slptimeo"
193Request a mounted file system to suspend write operations.
194All new write operations to the file system are stopped.
195After all write operations in progress have completed, the
196file system is synced to disk and the function returns.
197If the file system is currently suspended the
198.Xr sleep 9
199flag and timeout are specified by the arguments
200.Fa slpflag
201and
202.Fa slptimeo
203respectively.
204If
205.Fa slptimeo
206is less than zero
207.Er EWOULDBLOCK
208is returned.
209If the operation is successful, zero is returned, otherwise an
210appropriate error code is returned.
211.It Fn vfs_write_resume "mp"
212Request a mounted file system to resume write operations.
213.El
214.Sh CODE REFERENCES
215This section describes places within the
216.Nx
217source tree where actual code implementing or using the vfs
218operations can be found.
219All pathnames are relative to
220.Pa /usr/src .
221.Pp
222The vfs interface functions are implemented within the files
223.Pa sys/kern/vfs_subr.c
224and
225.Pa sys/kern/vfs_init.c .
226.Sh SEE ALSO
227.Xr intro 9 ,
228.Xr namei 9 ,
229.Xr vfs 9 ,
230.Xr vfsops 9 ,
231.Xr vnode 9 ,
232.Xr vnodeops 9
233