xref: /netbsd/share/man/man9/vnfileops.9 (revision c4a72b64)
1.\"     $NetBSD: vnfileops.9,v 1.5 2002/10/20 20:21:07 gmcgarry Exp $
2.\"
3.\" Copyright (c) 2001 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 October 14, 2002
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.Fd #include \*[Lt]sys/param.h\*[Gt]
52.Fd #include \*[Lt]sys/file.h\*[Gt]
53.Fd #include \*[Lt]sys/vnode.h\*[Gt]
54.Ft int
55.Fn vn_closefile "struct file *fp" "struct proc *p"
56.Ft int
57.Fn vn_fcntl "struct file *fp" "u_int com" "caddr_t data" "struct proc *p"
58.Ft int
59.Fn vn_ioctl "struct file *fp" "u_long com" "caddr_t data" "struct proc *p"
60.Ft int
61.Fn vn_read "struct file *fp" "off_t *offset" "struct uio *uio" "struct ucred *cred" "int flags"
62.Ft int
63.Fn vn_poll "struct file *fp" "int events" "struct proc *p"
64.Ft int
65.Fn vn_statfile "struct file *fp" "struct stat *sb" "struct proc *p"
66.Ft int
67.Fn vn_write "struct file *fp" "off_t *offset" "struct uio *uio" "struct ucred *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" "p"
78Common code for a file table vnode close operation.
79The file is described by
80.Fa fp
81and
82.Fa p
83is the calling process.
84.Fn vn_closefile
85simply calls
86.Xr vn_close 9
87with the appropriate arguments.
88.It Fn vn_fcntl "fp" "com" "data" "p"
89Common code for a file table vnode
90.Xr fcntl 2
91operation.
92The file is specified by
93.Fa fp .
94The argument
95.Fa p
96is the calling process.
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" "p"
108Common code for a file table vnode ioctl operation.
109The file is specified by
110.Fa fp .
111The argument
112.Fa p
113is the calling process.
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" "p"
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 process
150.Fa p .
151If the operation is success zero is returned, otherwise an appropriate
152error code is returned.
153.It Fn vn_statfile "fp" "sb" "p"
154Common code for a stat operation.
155The file descriptor is specified by the argument
156.Fa fp
157and
158.Fa sb
159is the buffer to return the stat information.
160The argument
161.Fa p
162is the calling process.
163.Fn vn_statfile
164basically calls the vnode operation
165.Xr VOP_GETATTR 9
166and transfer the contents of a vattr structure into a struct stat.
167If the operation is successful zero is returned, otherwise an
168appropriate error code is returned.
169.It Fn vn_write "fp" "offset" "uio" "cred" "flags"
170Common code for a file table vnode write.
171The argument
172.Fa fp
173is the file structure,  The argument
174.Fa offset
175is the offset into the file.
176The argument
177.Fa uio
178is the uio structure describing the memory to read from.
179The caller's credentials are specified in
180.Fa cred .
181The
182.Fa flags
183argument can define FOF_UPDATE_OFFSET to update the read position in
184the file.
185If the operation is successful zero is returned, otherwise an
186appropriate error is returned.
187.El
188.Sh CODE REFERENCES
189This section describes places within the
190.Nx
191source tree where actual code implementing or utilising the vnode
192framework can be found.
193All pathnames are relative to
194.Pa /usr/src .
195.Pp
196The high-level convenience functions are implemented within the file
197.Pa sys/kern/vfs_vnops.c .
198.Sh SEE ALSO
199.Xr file 9 ,
200.Xr intro 9 ,
201.Xr vnode 9 ,
202.Xr vnodeops 9 ,
203.Xr vnsubr 9
204