1.\" $NetBSD: vfssubr.9,v 1.3 2003/04/16 13:35:35 wiz 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 April 6, 2003 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_sysctl 60.Nd high-level interface to kernel file system interface 61.Sh SYNOPSIS 62.In sys/param.h 63.In sys/mount.h 64.In sys/vnode.h 65.Ft void 66.Fn vfs_getnewfsid "struct mount *mp" 67.Ft struct mount * 68.Fn vfs_getvfs "fsid_t *fsid" 69.Ft int 70.Fn vfs_export "struct mount *mp" "struct netexport *nep" \ 71"struct export_args *argp" 72.Ft void 73.Fn vfs_showexport "struct mount *mp" "struct export_args *argp" \ 74"struct netexport *nep" 75.Ft int 76.Fn vfs_export_lookup "struct mount *mp" "struct netexport *nep" \ 77"struct export_args *argp" 78.Ft int 79.Fn vfs_setpublicfs "struct mount *mp" "struct netexport *nep" \ 80"struct export_args *argp" 81.Ft int 82.Fn vfs_mountedon "struct vnode *vp" 83.Ft int 84.Fn vfs_mountroot "void" 85.Ft void 86.Fn vfs_unmountall "struct proc *p" 87.Ft int 88.Fn vfs_busy "struct mount *mp" "int flags" "struct simplelock *interlkp" 89.Ft void 90.Fn vfs_unbusy "struct mount *mp" 91.Ft int 92.Fn vfs_rootmountalloc "char *fstypename" "char *devname" \ 93"struct mount **mpp" 94.Ft void 95.Fn vfs_shutdown "void" 96.Ft int 97.Fn vfs_attach "struct vfsops *vfs" 98.Ft int 99.Fn vfs_detach "struct vfsops *vfs" 100.Ft void 101.Fn vfs_reinit "void" 102.Ft struct vfsops * 103.Fn vfs_getopsbyname "const char *name" 104.Ft int 105.Fn vfs_sysctl "int *name" "u_int namelen" "void *oldp" "size_t *oldlenp" \ 106"void *newp" "size_t newlen" "struct proc *p" 107.Sh DESCRIPTION 108The high-level functions described in this page are the interface to 109the kernel file system interface (VFS). 110.Sh FUNCTIONS 111.Bl -tag -width compact 112.It Fn vfs_getnewfsid "mp" 113Get a new unique file system id type for the file system specified by 114the mount structure 115.Fa mp . 116The file system id type is stored in 117.Em mp-\*[Gt]mnt_stat.f_fsid . 118.It Fn vfs_getvfs "fsid" 119Lookup a mount point with the file system identifier 120.Fa fsid . 121.It Fn vfs_export "mp" "nep" "argp" 122Undocumented. 123.It Fn vfs_showexport "mp" "argp" "nep" 124Undocumented. 125.It Fn vfs_export_lookup "mp" "nep" "argp" 126Check client permission on the exportable file system specified by the 127mount structure 128.Fa mp . 129The argument 130.Fa nam 131is the address of the networked client. 132This function is used by file system type specific functions to verify 133that the client can access the file system. 134.It Fn vfs_setpublicfs "mp" "nep" "argp" 135Set the publicly exported file system specified by the mount structure 136.Fa mp . 137.It Fn vfs_mountedon "vp" 138Check to see if a file system is mounted on a block device specified 139by the vnode 140.Fa vp . 141.It Fn vfs_mountroot "void" 142Mount the root file system. 143.It Fn vfs_unmountall "p" 144Unmount all file systems. 145.It Fn vfs_busy "mp" "flags" "interlkp" 146Mark the mount point specified by 147.Fa mp 148as busy. 149This function is used to synchronize access and to delay unmounting. 150The interlock specified by argument 151.Fa interlkp 152is not released on failure. 153.It Fn vfs_unbusy "mp" 154Free the busy file system specified by the mount structure 155.Fa mp . 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_sysctl "name" "namelen" "oldp" "oldlenp" "newp" "newlen" \ 191"struct proc *p" 192Retrieve file system-specific information for the sysctl(3) function. 193.El 194.Sh CODE REFERENCES 195This section describes places within the 196.Nx 197source tree where actual code implementing or using the vfs 198operations can be found. 199All pathnames are relative to 200.Pa /usr/src . 201.Pp 202The vfs interface functions are implemented within the files 203.Pa sys/kern/vfs_subr.c 204and 205.Pa sys/kern/vfs_init.c . 206.Sh SEE ALSO 207.Xr intro 9 , 208.Xr namei 9 , 209.Xr vfs 9 , 210.Xr vfsops 9 , 211.Xr vnode 9 , 212.Xr vnodeops 9 213