1 .\" $NetBSD: vnfileops.9,v 1.14 2008/04/30 13:10:59 martin Exp $
3 .\" Copyright (c) 2001, 2005, 2006 The NetBSD Foundation, Inc.
4 .\" All rights reserved.
6 .\" This code is derived from software contributed to The NetBSD Foundation
7 .\" by Gregory McGarry.
9 .\" Redistribution and use in source and binary forms, with or without
10 .\" modification, are permitted provided that the following conditions
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.
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.
42 .Nd vnode file descriptor operations
48 .Fn vn_closefile "file_t *fp"
50 .Fn vn_fcntl "file_t *fp" "u_int com" "void *data"
52 .Fn vn_ioctl "file_t *fp" "u_long com" "void *data"
54 .Fn vn_read "file_t *fp" "off_t *offset" "struct uio *uio" "kauth_cred_t cred" "int flags"
56 .Fn vn_poll "file_t *fp" "int events"
58 .Fn vn_statfile "file_t *fp" "struct stat *sb"
60 .Fn vn_write "file_t *fp" "off_t *offset" "struct uio *uio" "kauth_cred_t cred" "int flags"
62 The functions described in this page are the vnode-specific file
63 descriptor operations.
64 They should only be accessed through the opaque function pointers
65 in the file entries (see
67 They are described here only for completeness.
69 .Bl -tag -width compact
70 .It Fn vn_closefile "fp" "l"
71 Common code for a file table vnode close operation.
72 The file is described by
80 with the appropriate arguments.
81 .It Fn vn_fcntl "fp" "com" "data" "l"
82 Common code for a file table vnode
85 The file is specified by
91 simply locks the vnode and invokes the vnode operation
97 The vnode is unlocked on return.
98 If the operation is successful zero is returned, otherwise an
99 appropriate error is returned.
100 .It Fn vn_ioctl "fp" "com" "data" "l"
101 Common code for a file table vnode ioctl operation.
102 The file is specified by
108 simply locks the vnode and invokes the vnode operation
114 The vnode is unlocked on return.
115 If the operation is successful zero is returned, otherwise an
116 appropriate error is returned.
117 .It Fn vn_read "fp" "offset" "uio" "cred" "flags"
118 Common code for a file table vnode read.
121 is the file structure, The argument
123 is the offset into the file.
126 is the uio structure describing the memory to read into.
127 The caller's credentials are specified in
131 argument can define FOF_UPDATE_OFFSET to update the read position in
133 If the operation is successful zero is returned, otherwise an
134 appropriate error is returned.
135 .It Fn vn_poll "fp" "events" "l"
136 Common code for a file table vnode poll operation.
144 The function returns a bitmask of available events.
145 .It Fn vn_statfile "fp" "sb" "l"
146 Common code for a stat operation.
147 The file descriptor is specified by the argument
151 is the buffer to return the stat information.
156 basically calls the vnode operation
158 and transfer the contents of a vattr structure into a struct stat.
159 If the operation is successful zero is returned, otherwise an
160 appropriate error code is returned.
161 .It Fn vn_write "fp" "offset" "uio" "cred" "flags"
162 Common code for a file table vnode write.
165 is the file structure, The argument
167 is the offset into the file.
170 is the uio structure describing the memory to read from.
171 The caller's credentials are specified in
175 argument can define FOF_UPDATE_OFFSET to update the read position in
177 If the operation is successful zero is returned, otherwise an
178 appropriate error is returned.
181 This section describes places within the
183 source tree where actual code implementing or using the vnode
184 framework can be found.
185 All pathnames are relative to
188 The high-level convenience functions are implemented within the file
189 .Pa sys/kern/vfs_vnops.c .