xref: /freebsd/share/man/man9/VOP_OPENCLOSE.9 (revision fa9896e082a1046ff4fbc75fcba4d18d1f2efc19)
1fab63cc4SDoug Rabson.\" -*- nroff -*-
2fab63cc4SDoug Rabson.\"
3fab63cc4SDoug Rabson.\" Copyright (c) 1996 Doug Rabson
4fab63cc4SDoug Rabson.\"
5fab63cc4SDoug Rabson.\" All rights reserved.
6fab63cc4SDoug Rabson.\"
7fab63cc4SDoug Rabson.\" This program is free software.
8fab63cc4SDoug Rabson.\"
9fab63cc4SDoug Rabson.\" Redistribution and use in source and binary forms, with or without
10fab63cc4SDoug Rabson.\" modification, are permitted provided that the following conditions
11fab63cc4SDoug Rabson.\" are met:
12fab63cc4SDoug Rabson.\" 1. Redistributions of source code must retain the above copyright
13fab63cc4SDoug Rabson.\"    notice, this list of conditions and the following disclaimer.
14fab63cc4SDoug Rabson.\" 2. Redistributions in binary form must reproduce the above copyright
15fab63cc4SDoug Rabson.\"    notice, this list of conditions and the following disclaimer in the
16fab63cc4SDoug Rabson.\"    documentation and/or other materials provided with the distribution.
17fab63cc4SDoug Rabson.\"
18fab63cc4SDoug Rabson.\" THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY EXPRESS OR
19fab63cc4SDoug Rabson.\" IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
20fab63cc4SDoug Rabson.\" OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
21fab63cc4SDoug Rabson.\" IN NO EVENT SHALL THE DEVELOPERS BE LIABLE FOR ANY DIRECT, INDIRECT,
22fab63cc4SDoug Rabson.\" INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
23fab63cc4SDoug Rabson.\" NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
24fab63cc4SDoug Rabson.\" DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
25fab63cc4SDoug Rabson.\" THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
26fab63cc4SDoug Rabson.\" (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
27fab63cc4SDoug Rabson.\" THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
28fab63cc4SDoug Rabson.\"
294cbe4bf9SEdward Tomasz Napierala.Dd December 2, 2009
30fab63cc4SDoug Rabson.Dt VOP_OPEN 9
31*aa12cea2SUlrich Spörlein.Os
32fab63cc4SDoug Rabson.Sh NAME
33fab63cc4SDoug Rabson.Nm VOP_OPEN ,
34fab63cc4SDoug Rabson.Nm VOP_CLOSE
35fab63cc4SDoug Rabson.Nd open or close a file
36fab63cc4SDoug Rabson.Sh SYNOPSIS
3732eef9aeSRuslan Ermilov.In sys/param.h
3832eef9aeSRuslan Ermilov.In sys/vnode.h
39fab63cc4SDoug Rabson.Ft int
40e3e7f469SKonstantin Belousov.Fn VOP_OPEN "struct vnode *vp" "int mode" "struct ucred *cred" "struct thread *td" "struct file *fp"
41fab63cc4SDoug Rabson.Ft int
42c2508101SAndrew R. Reiter.Fn VOP_CLOSE "struct vnode *vp" "int mode" "struct ucred *cred" "struct thread *td"
43fab63cc4SDoug Rabson.Sh DESCRIPTION
44fab63cc4SDoug RabsonThe
45facc6767SRuslan Ermilov.Fn VOP_OPEN
46fab63cc4SDoug Rabsonentry point is called before a file is accessed by a process and the
47facc6767SRuslan Ermilov.Fn VOP_CLOSE
48fab63cc4SDoug Rabsonentry point is called after a file is finished with by the process.
49fab63cc4SDoug Rabson.Pp
50fab63cc4SDoug RabsonThe arguments are:
51fab63cc4SDoug Rabson.Bl -tag -width mode
520640e9e0SHiten Pandya.It Fa vp
530a57ea7dSRuslan ErmilovThe vnode of the file.
540640e9e0SHiten Pandya.It Fa mode
550a57ea7dSRuslan ErmilovThe access mode required by the calling process.
564cbe4bf9SEdward Tomasz Napierala.It Fa cred
574cbe4bf9SEdward Tomasz NapieralaThe caller's credentials.
580640e9e0SHiten Pandya.It Fa td
590a57ea7dSRuslan ErmilovThe thread which is accessing the file.
60e3e7f469SKonstantin Belousov.It Fa fp
61e3e7f469SKonstantin BelousovThe file being opened.
62fab63cc4SDoug Rabson.El
63ffdbee25SDoug Rabson.Pp
64e3e7f469SKonstantin BelousovPointer to the file
65e3e7f469SKonstantin Belousov.Fa fp
66e3e7f469SKonstantin Belousovis useful for file systems which require such information, e.g.,
67feaaabdcSRuslan Ermilov.Xr fdescfs 5 .
68e3e7f469SKonstantin BelousovUse
69e3e7f469SKonstantin Belousov.Ql NULL
70e3e7f469SKonstantin Belousovas
71e3e7f469SKonstantin Belousov.Fa fp
72e3e7f469SKonstantin Belousovargument to
73e3e7f469SKonstantin Belousov.Fn VOP_OPEN
74e3e7f469SKonstantin Belousovfor in-kernel opens.
752b55fc2eSHiten Pandya.Pp
76fab63cc4SDoug RabsonThe access mode is a set of flags, including
77fab63cc4SDoug Rabson.Dv FREAD ,
78fab63cc4SDoug Rabson.Dv FWRITE ,
79fab63cc4SDoug Rabson.Dv O_NONBLOCK ,
80fab63cc4SDoug Rabson.Dv O_APPEND .
81fab63cc4SDoug Rabson.Sh LOCKS
82facc6767SRuslan Ermilov.Fn VOP_OPEN
83bebac989SMatthew Dillonexpects
84bebac989SMatthew Dillon.Fa vp
85bebac989SMatthew Dillonto be locked on entry and will leave it locked on return.
86bebac989SMatthew Dillon.Pp
87facc6767SRuslan Ermilov.Fn VOP_CLOSE
88bebac989SMatthew Dillonexpects at least a reference to be associated with the vnode and does not
89c1c03d49SHiten Pandyacare whether the vnode is locked or not.
90c1c03d49SHiten PandyaThe lock and reference state is left unchanged on return.
91c1c03d49SHiten PandyaNote that
92bebac989SMatthew Dillon.Fa vn_close
93bebac989SMatthew Dillonexpects an unlocked, referenced vnode and will dereference the vnode prior
94bebac989SMatthew Dillonto returning.
95fab63cc4SDoug Rabson.Sh RETURN VALUES
96fab63cc4SDoug RabsonZero is returned on success, otherwise an error code is returned.
97fab63cc4SDoug Rabson.Sh SEE ALSO
98fab63cc4SDoug Rabson.Xr vnode 9 ,
99fab63cc4SDoug Rabson.Xr VOP_LOOKUP 9
100fab63cc4SDoug Rabson.Sh AUTHORS
101571dba6eSHiten PandyaThis manual page was written by
102aaf1f16eSPhilippe Charnier.An Doug Rabson .
103