xref: /netbsd/share/man/man9/vfssubr.9 (revision 6550d01e)
1.\"     $NetBSD: vfssubr.9,v 1.20 2010/12/02 12:54:13 wiz Exp $
2.\"
3.\" Copyright (c) 2003, 2005, 2006 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.\"
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.
29.\"
30.Dd May 9, 2009
31.Dt VFSSUBR 9
32.Os
33.Sh NAME
34.Nm vfssubr ,
35.Nm vfs_getnewfsid ,
36.Nm vfs_getvfs ,
37.Nm vfs_export ,
38.Nm vfs_showexport ,
39.Nm vfs_export_lookup ,
40.Nm vfs_setpublicfs ,
41.Nm vfs_mountedon ,
42.Nm vfs_mountroot ,
43.Nm vfs_unmountall ,
44.Nm vfs_busy ,
45.Nm vfs_unbusy ,
46.Nm vfs_mountalloc ,
47.Nm vfs_rootmountalloc ,
48.Nm vfs_shutdown ,
49.Nm vfs_attach ,
50.Nm vfs_detach ,
51.Nm vfs_reinit ,
52.Nm vfs_getopsbyname ,
53.Nm vfs_suspend ,
54.Nm vfs_resume
55.Nd high-level interface to kernel file system interface
56.Sh SYNOPSIS
57.In sys/param.h
58.In sys/mount.h
59.In sys/vnode.h
60.Ft void
61.Fn vfs_getnewfsid "struct mount *mp"
62.Ft struct mount *
63.Fn vfs_getvfs "fsid_t *fsid"
64.Ft int
65.Fn vfs_export_lookup "struct mount *mp" "struct netexport *nep" \
66"struct export_args *argp"
67.Ft int
68.Fn vfs_setpublicfs "struct mount *mp" "struct netexport *nep" \
69"struct export_args *argp"
70.Ft int
71.Fn vfs_mountedon "struct vnode *vp"
72.Ft int
73.Fn vfs_mountroot "void"
74.Ft void
75.Fn vfs_unmountall  "struct lwp *l"
76.Ft int
77.Fn vfs_busy "struct mount *mp" "int flags" "struct simplelock *interlkp"
78.Ft void
79.Fn vfs_unbusy "struct mount *mp"
80.Ft struct mount *
81.Fn vfs_mountalloc "struct vfsops *vfs" "struct vnode *vp"
82.Ft int
83.Fn vfs_rootmountalloc "char *fstypename" "char *devname" \
84"struct mount **mpp"
85.Ft void
86.Fn vfs_shutdown "void"
87.Ft int
88.Fn vfs_attach "struct vfsops *vfs"
89.Ft int
90.Fn vfs_detach "struct vfsops *vfs"
91.Ft void
92.Fn vfs_reinit "void"
93.Ft struct vfsops *
94.Fn vfs_getopsbyname "const char *name"
95.Ft int
96.Fn vfs_suspend "struct mount *mp" "int nowait"
97.Ft void
98.Fn vfs_resume "struct mount *mp"
99.Sh DESCRIPTION
100The high-level functions described in this page are the interface to
101the kernel file system interface (VFS).
102.Sh FUNCTIONS
103.Bl -tag -width compact
104.It Fn vfs_getnewfsid "mp"
105Get a new unique file system id type for the file system specified by
106the mount structure
107.Fa mp .
108The file system id type is stored in
109.Em mp-\*[Gt]mnt_stat.f_fsidx .
110.It Fn vfs_getvfs "fsid"
111Lookup a mount point with the file system identifier
112.Fa fsid .
113.It Fn vfs_export_lookup "mp" "nep" "argp"
114Check client permission on the exportable file system specified by the
115mount structure
116.Fa mp .
117The argument
118.Fa nam
119is the address of the networked client.
120This function is used by file system type specific functions to verify
121that the client can access the file system.
122.It Fn vfs_setpublicfs "mp" "nep" "argp"
123Set the publicly exported file system specified by the mount structure
124.Fa mp .
125.It Fn vfs_mountedon "vp"
126Check to see if a file system is mounted on a block device specified
127by the vnode
128.Fa vp .
129.It Fn vfs_mountroot "void"
130Mount the root file system.
131.It Fn vfs_unmountall "l"
132Unmount all file systems.
133.It Fn vfs_busy "mp" "flags" "interlkp"
134Mark the mount point specified by
135.Fa mp
136as busy.
137This function is used to synchronize access and to delay unmounting.
138The interlock specified by argument
139.Fa interlkp
140is not released on failure.
141.It Fn vfs_unbusy "mp"
142Free the busy file system specified by the mount structure
143.Fa mp .
144.It Fn vfs_mountalloc "vfsops" "vp"
145Allocate and initialise a mount structure, setting
146.Em mnt_vnodecovered
147to
148.Fa vp
149and
150.Em mnt_op
151to
152.Fa vfsops .
153On success, mark the mount structure as busy and return its address.
154Otherwise, return
155.Dv NULL .
156.It Fn vfs_rootmountalloc "fstypename" "devname" "mpp"
157Lookup a file system type specified by the name
158.Fa fstypename
159and if found allocate and initialise a mount structure for it.
160The allocated mount structure is returned in the address specified by
161.Fa mpp .
162The device the root file system was mounted from is specified by the
163argument
164.Fa devname
165and is recorded in the new mount structure.
166.It Fn vfs_shutdown
167Sync and unmount all file systems before shutting down.
168Invoked by
169.Xr cpu_reboot 9 .
170.It Fn vfs_attach "vfs"
171Establish file system
172.Fa vfs
173and initialise it.
174.It Fn vfs_detach "vfs"
175Remove file system
176.Fa vfs
177from the kernel.
178.It Fn vfs_reinit "void"
179Reinitialises all file systems within the kernel through file
180system-specific vfs operation (see
181.Xr vfsops 9 ) .
182.It Fn vfs_getopsbyname "name"
183Given a file system name specified by
184.Fa name ,
185look up the vfs operations for that file system (see
186.Xr vfsops 9 ) ,
187or return
188.Dv NULL
189if file system isn't present in the kernel.
190.It Fn vfs_suspend "mp" "nowait"
191Request a mounted file system to suspend all operations.
192All new operations to the file system are stopped.
193After all operations in progress have completed, the
194file system is synced to disk and the function returns.
195If a file system suspension is currently in progress and
196.Fa nowait
197is set
198.Er EWOULDBLOCK
199is returned.
200If the operation is successful, zero is returned, otherwise an
201appropriate error code is returned.
202.It Fn vfs_resume "mp"
203Request a mounted file system to resume operations.
204.El
205.Sh CODE REFERENCES
206The vfs interface functions are implemented within the files
207.Pa sys/kern/vfs_subr.c
208and
209.Pa sys/kern/vfs_init.c .
210.Sh SEE ALSO
211.Xr intro 9 ,
212.Xr namei 9 ,
213.Xr vfs 9 ,
214.Xr vfsops 9 ,
215.Xr vnode 9 ,
216.Xr vnodeops 9
217