xref: /netbsd/sys/kern/vnode_if.src (revision c4a72b64)
1#	$NetBSD: vnode_if.src,v 1.31 2002/10/23 09:14:32 jdolecek Exp $
2#
3# Copyright (c) 1992, 1993
4#	The Regents of the University of California.  All rights reserved.
5#
6# Redistribution and use in source and binary forms, with or without
7# modification, are permitted provided that the following conditions
8# are met:
9# 1. Redistributions of source code must retain the above copyright
10#    notice, this list of conditions and the following disclaimer.
11# 2. Redistributions in binary form must reproduce the above copyright
12#    notice, this list of conditions and the following disclaimer in the
13#    documentation and/or other materials provided with the distribution.
14# 3. All advertising materials mentioning features or use of this software
15#    must display the following acknowledgement:
16#	This product includes software developed by the University of
17#	California, Berkeley and its contributors.
18# 4. Neither the name of the University nor the names of its contributors
19#    may be used to endorse or promote products derived from this software
20#    without specific prior written permission.
21#
22# THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
23# ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
24# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
25# ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
26# FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
27# DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
28# OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
29# HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
30# LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
31# OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
32# SUCH DAMAGE.
33#
34#	@(#)vnode_if.src	8.14 (Berkeley) 8/6/95
35#
36#
37
38#
39# Above each of the vop descriptors is a specification of the locking
40# protocol used by each vop call.  The first column is the name of
41# the variable, the remaining three columns are in, out and error
42# respectively.  The "in" column defines the lock state on input,
43# the "out" column defines the state on succesful return, and the
44# "error" column defines the locking state on error exit.
45#
46# The locking value can take the following values:
47# L: locked.
48# U: unlocked.
49# -: not applicable.  vnode does not yet (or no longer) exists.
50# =: the same on input and output, may be either L or U.
51# X: locked if not nil.
52#
53# For operations other than VOP_LOOKUP which require a component name
54# parameter, the flags required for the initial namei() call are listed.
55# Additional flags may be added to the namei() call, but these are required.
56#
57
58#
59#% lookup     dvp     L ? ?
60#% lookup     vpp     - L -
61#
62# XXX - the lookup locking protocol defies simple description and depends
63#     on the flags and operation fields in the (cnp) structure.  Note
64#     especially that *vpp may equal dvp and both may be locked.
65#
66#    More details:
67#     There are three types of lookups: ".", ".." (ISDOTDOT), and other.
68#     On successful lookup of ".", a reference is added to dvp, and it
69#          is returned in *vpp.
70#     To look up ISDOTDOT, dvp is unlocked, the ".." node is locked, and
71#          then dvp is relocked iff LOCKPARENT is set and this is the last
72#          component name (ISLASTCN set). This preserves the
73#          protocol of always locking nodes from root ("/") downward and
74#          prevents deadlock.
75#     Other lookups find the named node (creating the vnode if needed) and
76#          return it, locked, in *vpp.
77#     For non-"." lookups, if LOCKPARENT is not set or this was not the
78#          last component name, dvp is returned unlocked on a successful
79#          lookup.
80#     On failure, *vpp is NULL, and *dvp is left locked. If there was
81#          an error re-locking dvp (for instance in the ISDOTDOT case),
82#          the error is returned with PDIRUNLOCK set.
83#
84#     *vpp is always locked on return if the operation succeeds.
85#     typically, if *vpp == dvp, you need to release twice, but unlock once.
86#
87#     The PDIRUNLOCK flag is set when dvp is unlocked in the lookup routine.
88#          It signals the caller that dvp's lock state changed. It will
89#          be set on exit if either a successful lookup unlocked the
90#          parrent, or there was an error re-locking dvp in the ISDOTDOT case.
91#
92#     See sys/sys/namei.h for a description of the SAVENAME and SAVESTART
93#          flags.
94#
95vop_lookup {
96	IN struct vnode *dvp;
97	INOUT struct vnode **vpp;
98	IN struct componentname *cnp;
99};
100
101#
102#% create     dvp     L U U
103#% create     vpp     - L -
104#
105#! create cnp	CREATE, LOCKPARENT
106#
107vop_create {
108	IN WILLPUT struct vnode *dvp;
109	OUT struct vnode **vpp;
110	IN struct componentname *cnp;
111	IN struct vattr *vap;
112};
113
114#
115#% mknod      dvp     L U U
116#% mknod      vpp     - L -
117#
118#! mknod cnp	CREATE, LOCKPARENT
119#
120vop_mknod {
121	IN WILLPUT struct vnode *dvp;
122	OUT struct vnode **vpp;
123	IN struct componentname *cnp;
124	IN struct vattr *vap;
125};
126
127#
128#% open               vp      L L L
129#
130vop_open {
131	IN struct vnode *vp;
132	IN int mode;
133	IN struct ucred *cred;
134	IN struct proc *p;
135};
136
137#
138#% close      vp      L L L
139#
140vop_close {
141	IN struct vnode *vp;
142	IN int fflag;
143	IN struct ucred *cred;
144	IN struct proc *p;
145};
146
147#
148#% access     vp      L L L
149#
150vop_access {
151	IN struct vnode *vp;
152	IN int mode;
153	IN struct ucred *cred;
154	IN struct proc *p;
155};
156
157#
158#% getattr    vp      = = =
159#
160vop_getattr {
161	IN struct vnode *vp;
162	IN struct vattr *vap;
163	IN struct ucred *cred;
164	IN struct proc *p;
165};
166
167#
168#% setattr    vp      L L L
169#
170vop_setattr {
171	IN struct vnode *vp;
172	IN struct vattr *vap;
173	IN struct ucred *cred;
174	IN struct proc *p;
175};
176
177#
178#% read               vp      L L L
179#
180vop_read {
181	IN struct vnode *vp;
182	INOUT struct uio *uio;
183	IN int ioflag;
184	IN struct ucred *cred;
185};
186
187#
188#% write      vp      L L L
189#
190vop_write {
191	IN struct vnode *vp;
192	INOUT struct uio *uio;
193	IN int ioflag;
194	IN struct ucred *cred;
195};
196
197#
198#% ioctl      vp      U U U
199#
200vop_ioctl {
201	IN struct vnode *vp;
202	IN u_long command;
203	IN caddr_t data;
204	IN int fflag;
205	IN struct ucred *cred;
206	IN struct proc *p;
207};
208
209#
210#% fcntl      vp      L L L
211#
212vop_fcntl {
213	IN struct vnode *vp;
214	IN u_int command;
215	IN caddr_t data;
216	IN int fflag;
217	IN struct ucred *cred;
218	IN struct proc *p;
219};
220
221#
222#% poll     vp      U U U
223#
224vop_poll {
225	IN struct vnode *vp;
226	IN int events;
227	IN struct proc *p;
228};
229
230#
231#% kqfilter     vp      U U U
232#
233vop_kqfilter {
234	IN struct vnode *vp;
235	IN struct knote *kn;
236};
237
238#
239#% revoke     vp      U U U
240#
241vop_revoke {
242	IN struct vnode *vp;
243	IN int flags;
244};
245
246#
247#% mmap      vp      = = =
248#
249vop_mmap {
250	IN struct vnode *vp;
251	IN int fflags;
252	IN struct ucred *cred;
253	IN struct proc *p;
254};
255
256#
257#% fsync      vp      L L L
258#
259vop_fsync {
260	IN struct vnode *vp;
261	IN struct ucred *cred;
262	IN int flags;
263	IN off_t offlo
264	IN off_t offhi
265	IN struct proc *p;
266};
267
268#
269# Needs work: Is newoff right?  What's it mean?
270#
271vop_seek {
272	IN struct vnode *vp;
273	IN off_t oldoff;
274	IN off_t newoff;
275	IN struct ucred *cred;
276};
277
278#
279#% remove     dvp     L U U
280#% remove     vp      L U U
281#
282#! remove cnp	DELETE, LOCKPARENT | LOCKLEAF
283#
284vop_remove {
285	IN WILLPUT struct vnode *dvp;
286	IN WILLPUT struct vnode *vp;
287	IN struct componentname *cnp;
288};
289
290#
291#% link               vp      U U U
292#% link               tdvp    L U U
293#
294#! link	 cnp	CREATE, LOCKPARENT
295#
296vop_link {
297	IN WILLPUT struct vnode *dvp;
298	IN struct vnode *vp;
299	IN struct componentname *cnp;
300};
301
302#
303#% rename     fdvp    U U U
304#% rename     fvp     U U U
305#% rename     tdvp    L U U
306#% rename     tvp     X U U
307#
308#! rename fcnp	DELETE,	WANTPARENT | SAVESTART
309#! rename tcnp	RENAME, LOCKPARENT | LOCKLEAF | NOCACHE | SAVESTART
310#
311# XXX the vop_rename routines should REALLY NOT be depending on SAVESTART!
312#
313vop_rename {
314	IN WILLRELE struct vnode *fdvp;
315	IN WILLRELE struct vnode *fvp;
316	IN struct componentname *fcnp;
317	IN WILLPUT struct vnode *tdvp;
318	IN WILLRELE struct vnode *tvp;
319	IN struct componentname *tcnp;
320};
321
322#
323#% mkdir      dvp     L U U
324#% mkdir      vpp     - L -
325#
326#! mkdir cnp	CREATE, LOCKPARENT
327#
328vop_mkdir {
329	IN WILLPUT struct vnode *dvp;
330	OUT struct vnode **vpp;
331	IN struct componentname *cnp;
332	IN struct vattr *vap;
333};
334
335#
336#% rmdir      dvp     L U U
337#% rmdir      vp      L U U
338#
339#! rmdir cnp	DELETE, LOCKPARENT | LOCKLEAF
340#
341vop_rmdir {
342	IN WILLPUT struct vnode *dvp;
343	IN WILLPUT struct vnode *vp;
344	IN struct componentname *cnp;
345};
346
347#
348#% symlink    dvp     L U U
349#% symlink    vpp     - L -
350#
351#! symlink cnp	CREATE, LOCKPARENT
352#
353vop_symlink {
354	IN WILLPUT struct vnode *dvp;
355	OUT struct vnode **vpp;
356	IN struct componentname *cnp;
357	IN struct vattr *vap;
358	IN char *target;
359};
360
361#
362#% readdir    vp      L L L
363#
364vop_readdir {
365	IN struct vnode *vp;
366	INOUT struct uio *uio;
367	IN struct ucred *cred;
368	OUT int *eofflag;
369	OUT off_t **cookies;
370	IN int *ncookies;
371};
372
373#
374#% readlink   vp      L L L
375#
376vop_readlink {
377	IN struct vnode *vp;
378	INOUT struct uio *uio;
379	IN struct ucred *cred;
380};
381
382#
383#% abortop    dvp     = = =
384#
385#! abortop cnp	as appropriate.
386#
387vop_abortop {
388	IN struct vnode *dvp;
389	IN struct componentname *cnp;
390};
391
392#
393#% inactive   vp      L U U
394#
395vop_inactive {
396	IN WILLUNLOCK struct vnode *vp;
397	IN struct proc *p;
398};
399
400#
401#% reclaim    vp      U U U
402#
403vop_reclaim {
404	IN struct vnode *vp;
405	IN struct proc *p;
406};
407
408#
409#% lock               vp      U L U
410#
411vop_lock {
412	IN struct vnode *vp;
413	IN int flags;
414};
415
416#
417#% unlock     vp      L U L
418#
419vop_unlock {
420	IN struct vnode *vp;
421	IN int flags;
422};
423
424#
425#% bmap               vp      L L L
426#% bmap               vpp     - U -
427#
428vop_bmap {
429	IN struct vnode *vp;
430	IN daddr_t bn;
431	OUT struct vnode **vpp;
432	IN daddr_t *bnp;
433	OUT int *runp;
434};
435
436#
437# Needs work: no vp?
438#
439#vop_strategy {
440#	IN struct buf *bp;
441#};
442
443#
444#% print      vp      = = =
445#
446vop_print {
447	IN struct vnode *vp;
448};
449
450#
451#% islocked   vp      = = =
452#
453vop_islocked {
454	IN struct vnode *vp;
455};
456
457#
458#% pathconf   vp      L L L
459#
460vop_pathconf {
461	IN struct vnode *vp;
462	IN int name;
463	OUT register_t *retval;
464};
465
466#
467#% advlock    vp      U U U
468#
469vop_advlock {
470	IN struct vnode *vp;
471	IN caddr_t id;
472	IN int op;
473	IN struct flock *fl;
474	IN int flags;
475};
476
477#
478#% blkatoff   vp      L L L
479#
480vop_blkatoff {
481	IN struct vnode *vp;
482	IN off_t offset;
483	OUT char **res;
484	OUT struct buf **bpp;
485};
486
487#
488#% valloc     pvp     L L L
489#
490vop_valloc {
491	IN struct vnode *pvp;
492	IN int mode;
493	IN struct ucred *cred;
494	OUT struct vnode **vpp;
495};
496
497#
498#% balloc     vp      L L L
499#
500vop_balloc {
501	IN struct vnode *vp;
502	IN off_t startoffset;
503	IN int size;
504	IN struct ucred *cred;
505	IN int flags;
506	OUT struct buf **bpp;
507};
508
509#
510#% reallocblks        vp      L L L
511#
512vop_reallocblks {
513	IN struct vnode *vp;
514	IN struct cluster_save *buflist;
515};
516
517#
518#% vfree      pvp     L L L
519#
520vop_vfree {
521	IN struct vnode *pvp;
522	IN ino_t ino;
523	IN int mode;
524};
525
526#
527#% truncate   vp      L L L
528#
529vop_truncate {
530	IN struct vnode *vp;
531	IN off_t length;
532	IN int flags;
533	IN struct ucred *cred;
534	IN struct proc *p;
535};
536
537#
538#% update     vp      L L L
539#
540vop_update {
541	IN struct vnode *vp;
542	IN struct timespec *access;
543	IN struct timespec *modify;
544	IN int flags;
545};
546
547#
548#% lease      vp      = = =
549#
550vop_lease {
551	IN struct vnode *vp;
552	IN struct proc *p;
553	IN struct ucred *cred;
554	IN int flag;
555};
556
557#
558#% whiteout   dvp     L L L
559#% whiteout   cnp     - - -
560#% whiteout   flag    - - -
561#
562#! whiteout cnp	CREATE, LOCKPARENT
563#
564vop_whiteout {
565	IN struct vnode *dvp;
566	IN struct componentname *cnp;
567	IN int flags;
568};
569
570#
571# Needs work: no vp?
572#
573#vop_bwrite {
574#	IN struct buf *bp;
575#};
576
577#
578#% getpages	vp L L L
579#
580vop_getpages {
581	IN struct vnode *vp;
582	IN voff_t offset;
583	IN struct vm_page **m;
584	IN int *count;
585	IN int centeridx;
586	IN vm_prot_t access_type;
587	IN int advice;
588	IN int flags;
589};
590
591#
592#% putpages	vp = = =
593#
594vop_putpages {
595	IN struct vnode *vp;
596	IN voff_t offlo;
597	IN voff_t offhi;
598	IN int flags;
599};
600