1.\" $NetBSD: vnfileops.9,v 1.12 2007/05/17 17:47:10 pooka Exp $ 2.\" 3.\" Copyright (c) 2001, 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.\" 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 May 17, 2007 38.Dt VNFILEOPS 9 39.Os 40.Sh NAME 41.Nm vnfileops , 42.Nm vn_closefile , 43.Nm vn_fcntl , 44.Nm vn_ioctl , 45.Nm vn_read , 46.Nm vn_poll , 47.Nm vn_statfile , 48.Nm vn_write , 49.Nd vnode file descriptor operations 50.Sh SYNOPSIS 51.In sys/param.h 52.In sys/file.h 53.In sys/vnode.h 54.Ft int 55.Fn vn_closefile "struct file *fp" "struct lwp *l" 56.Ft int 57.Fn vn_fcntl "struct file *fp" "u_int com" "void *data" "struct lwp *l" 58.Ft int 59.Fn vn_ioctl "struct file *fp" "u_long com" "void *data" "struct lwp *l" 60.Ft int 61.Fn vn_read "struct file *fp" "off_t *offset" "struct uio *uio" "kauth_cred_t cred" "int flags" 62.Ft int 63.Fn vn_poll "struct file *fp" "int events" "struct lwp *l" 64.Ft int 65.Fn vn_statfile "struct file *fp" "struct stat *sb" "struct lwp *l" 66.Ft int 67.Fn vn_write "struct file *fp" "off_t *offset" "struct uio *uio" "kauth_cred_t cred" "int flags" 68.Sh DESCRIPTION 69The functions described in this page are the vnode-specific file 70descriptor operations. 71They should only be accessed through the opaque function pointers 72in the file entries (see 73.Xr file 9 ) . 74They are described here only for completeness. 75.Sh FUNCTIONS 76.Bl -tag -width compact 77.It Fn vn_closefile "fp" "l" 78Common code for a file table vnode close operation. 79The file is described by 80.Fa fp 81and 82.Fa l 83is the calling lwp. 84.Fn vn_closefile 85simply calls 86.Xr vn_close 9 87with the appropriate arguments. 88.It Fn vn_fcntl "fp" "com" "data" "l" 89Common code for a file table vnode 90.Xr fcntl 2 91operation. 92The file is specified by 93.Fa fp . 94The argument 95.Fa l 96is the calling lwp. 97.Fn vn_fcntl 98simply locks the vnode and invokes the vnode operation 99.Xr VOP_FCNTL 9 100with the command 101.Fa com 102and buffer 103.Fa data . 104The vnode is unlocked on return. 105If the operation is successful zero is returned, otherwise an 106appropriate error is returned. 107.It Fn vn_ioctl "fp" "com" "data" "l" 108Common code for a file table vnode ioctl operation. 109The file is specified by 110.Fa fp . 111The argument 112.Fa l 113is the calling lwp 114.Fn vn_ioctl 115simply locks the vnode and invokes the vnode operation 116.Xr VOP_IOCTL 9 117with the command 118.Fa com 119and buffer 120.Fa data . 121The vnode is unlocked on return. 122If the operation is successful zero is returned, otherwise an 123appropriate error is returned. 124.It Fn vn_read "fp" "offset" "uio" "cred" "flags" 125Common code for a file table vnode read. 126The argument 127.Fa fp 128is the file structure, The argument 129.Fa offset 130is the offset into the file. 131The argument 132.Fa uio 133is the uio structure describing the memory to read into. 134The caller's credentials are specified in 135.Fa cred . 136The 137.Fa flags 138argument can define FOF_UPDATE_OFFSET to update the read position in 139the file. 140If the operation is successful zero is returned, otherwise an 141appropriate error is returned. 142.It Fn vn_poll "fp" "events" "l" 143Common code for a file table vnode poll operation. 144.Fn vn_poll 145simply calls 146.Xr VOP_POLL 9 147with the events 148.Fa events 149and the calling lwp 150.Fa l . 151The function returns a bitmask of available events. 152.It Fn vn_statfile "fp" "sb" "l" 153Common code for a stat operation. 154The file descriptor is specified by the argument 155.Fa fp 156and 157.Fa sb 158is the buffer to return the stat information. 159The argument 160.Fa l 161is the calling lwp. 162.Fn vn_statfile 163basically calls the vnode operation 164.Xr VOP_GETATTR 9 165and transfer the contents of a vattr structure into a struct stat. 166If the operation is successful zero is returned, otherwise an 167appropriate error code is returned. 168.It Fn vn_write "fp" "offset" "uio" "cred" "flags" 169Common code for a file table vnode write. 170The argument 171.Fa fp 172is the file structure, The argument 173.Fa offset 174is the offset into the file. 175The argument 176.Fa uio 177is the uio structure describing the memory to read from. 178The caller's credentials are specified in 179.Fa cred . 180The 181.Fa flags 182argument can define FOF_UPDATE_OFFSET to update the read position in 183the file. 184If the operation is successful zero is returned, otherwise an 185appropriate error is returned. 186.El 187.Sh CODE REFERENCES 188This section describes places within the 189.Nx 190source tree where actual code implementing or using the vnode 191framework can be found. 192All pathnames are relative to 193.Pa /usr/src . 194.Pp 195The high-level convenience functions are implemented within the file 196.Pa sys/kern/vfs_vnops.c . 197.Sh SEE ALSO 198.Xr file 9 , 199.Xr intro 9 , 200.Xr vnode 9 , 201.Xr vnodeops 9 , 202.Xr vnsubr 9 203