.\" $NetBSD: vnfileops.9,v 1.16 2010/12/02 12:54:13 wiz Exp $ .\" .\" Copyright (c) 2001, 2005, 2006 The NetBSD Foundation, Inc. .\" All rights reserved. .\" .\" This code is derived from software contributed to The NetBSD Foundation .\" by Gregory McGarry. .\" .\" Redistribution and use in source and binary forms, with or without .\" modification, are permitted provided that the following conditions .\" are met: .\" 1. Redistributions of source code must retain the above copyright .\" notice, this list of conditions and the following disclaimer. .\" 2. Redistributions in binary form must reproduce the above copyright .\" notice, this list of conditions and the following disclaimer in the .\" documentation and/or other materials provided with the distribution. .\" .\" THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS .\" ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED .\" TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR .\" PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS .\" BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR .\" CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF .\" SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS .\" INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN .\" CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) .\" ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE .\" POSSIBILITY OF SUCH DAMAGE. .\" .Dd April 9, 2008 .Dt VNFILEOPS 9 .Os .Sh NAME .Nm vnfileops , .Nm vn_closefile , .Nm vn_fcntl , .Nm vn_ioctl , .Nm vn_read , .Nm vn_poll , .Nm vn_statfile , .Nm vn_write .Nd vnode file descriptor operations .Sh SYNOPSIS .In sys/param.h .In sys/file.h .In sys/vnode.h .Ft int .Fn vn_closefile "file_t *fp" .Ft int .Fn vn_fcntl "file_t *fp" "u_int com" "void *data" .Ft int .Fn vn_ioctl "file_t *fp" "u_long com" "void *data" .Ft int .Fn vn_read "file_t *fp" "off_t *offset" "struct uio *uio" "kauth_cred_t cred" "int flags" .Ft int .Fn vn_poll "file_t *fp" "int events" .Ft int .Fn vn_statfile "file_t *fp" "struct stat *sb" .Ft int .Fn vn_write "file_t *fp" "off_t *offset" "struct uio *uio" "kauth_cred_t cred" "int flags" .Sh DESCRIPTION The functions described in this page are the vnode-specific file descriptor operations. They should only be accessed through the opaque function pointers in the file entries (see .Xr file 9 ) . They are described here only for completeness. .Sh FUNCTIONS .Bl -tag -width compact .It Fn vn_closefile "fp" "l" Common code for a file table vnode close operation. The file is described by .Fa fp and .Fa l is the calling lwp. .Fn vn_closefile simply calls .Xr vn_close 9 with the appropriate arguments. .It Fn vn_fcntl "fp" "com" "data" "l" Common code for a file table vnode .Xr fcntl 2 operation. The file is specified by .Fa fp . The argument .Fa l is the calling lwp. .Fn vn_fcntl simply locks the vnode and invokes the vnode operation .Xr VOP_FCNTL 9 with the command .Fa com and buffer .Fa data . The vnode is unlocked on return. If the operation is successful zero is returned, otherwise an appropriate error is returned. .It Fn vn_ioctl "fp" "com" "data" "l" Common code for a file table vnode ioctl operation. The file is specified by .Fa fp . The argument .Fa l is the calling lwp .Fn vn_ioctl simply locks the vnode and invokes the vnode operation .Xr VOP_IOCTL 9 with the command .Fa com and buffer .Fa data . The vnode is unlocked on return. If the operation is successful zero is returned, otherwise an appropriate error is returned. .It Fn vn_read "fp" "offset" "uio" "cred" "flags" Common code for a file table vnode read. The argument .Fa fp is the file structure, The argument .Fa offset is the offset into the file. The argument .Fa uio is the uio structure describing the memory to read into. The caller's credentials are specified in .Fa cred . The .Fa flags argument can define FOF_UPDATE_OFFSET to update the read position in the file. If the operation is successful zero is returned, otherwise an appropriate error is returned. .It Fn vn_poll "fp" "events" "l" Common code for a file table vnode poll operation. .Fn vn_poll simply calls .Xr VOP_POLL 9 with the events .Fa events and the calling lwp .Fa l . The function returns a bitmask of available events. .It Fn vn_statfile "fp" "sb" "l" Common code for a stat operation. The file descriptor is specified by the argument .Fa fp and .Fa sb is the buffer to return the stat information. The argument .Fa l is the calling lwp. .Fn vn_statfile basically calls the vnode operation .Xr VOP_GETATTR 9 and transfer the contents of a vattr structure into a struct stat. If the operation is successful zero is returned, otherwise an appropriate error code is returned. .It Fn vn_write "fp" "offset" "uio" "cred" "flags" Common code for a file table vnode write. The argument .Fa fp is the file structure, The argument .Fa offset is the offset into the file. The argument .Fa uio is the uio structure describing the memory to read from. The caller's credentials are specified in .Fa cred . The .Fa flags argument can define FOF_UPDATE_OFFSET to update the read position in the file. If the operation is successful zero is returned, otherwise an appropriate error is returned. .El .Sh CODE REFERENCES The high-level convenience functions are implemented within the file .Pa sys/kern/vfs_vnops.c . .Sh SEE ALSO .Xr file 9 , .Xr intro 9 , .Xr vnode 9 , .Xr vnodeops 9 , .Xr vnsubr 9