xref: /netbsd-src/sys/kern/vnode_if.src (revision 7cc2f76925f078d01ddc9e640a98f4ccfc9f8c3b)
1#	$NetBSD: vnode_if.src,v 1.26 2000/11/27 08:39:45 chs 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     - X -
117#
118#! mknod cnp	CREATE, LOCKPARENT
119#
120vop_mknod {
121	IN WILLPUT struct vnode *dvp;
122	OUT WILLRELE 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#% revoke     vp      U U U
232#
233vop_revoke {
234	IN struct vnode *vp;
235	IN int flags;
236};
237
238#
239# XXX - not used
240#
241vop_mmap {
242	IN struct vnode *vp;
243	IN int fflags;
244	IN struct ucred *cred;
245	IN struct proc *p;
246};
247
248#
249#% fsync      vp      L L L
250#
251vop_fsync {
252	IN struct vnode *vp;
253	IN struct ucred *cred;
254	IN int flags;
255	IN off_t offlo
256	IN off_t offhi
257	IN struct proc *p;
258};
259
260#
261# Needs work: Is newoff right?  What's it mean?
262#
263vop_seek {
264	IN struct vnode *vp;
265	IN off_t oldoff;
266	IN off_t newoff;
267	IN struct ucred *cred;
268};
269
270#
271#% remove     dvp     L U U
272#% remove     vp      L U U
273#
274#! remove cnp	DELETE, LOCKPARENT | LOCKLEAF
275#
276vop_remove {
277	IN WILLPUT struct vnode *dvp;
278	IN WILLPUT struct vnode *vp;
279	IN struct componentname *cnp;
280};
281
282#
283#% link               vp      U U U
284#% link               tdvp    L U U
285#
286#! link	 cnp	CREATE, LOCKPARENT
287#
288vop_link {
289	IN WILLPUT struct vnode *dvp;
290	IN struct vnode *vp;
291	IN struct componentname *cnp;
292};
293
294#
295#% rename     fdvp    U U U
296#% rename     fvp     U U U
297#% rename     tdvp    L U U
298#% rename     tvp     X U U
299#
300#! rename fcnp	DELETE,	WANTPARENT | SAVESTART
301#! rename tcnp	RENAME, LOCKPARENT | LOCKLEAF | NOCACHE | SAVESTART
302#
303# XXX the vop_rename routines should REALLY NOT be depending on SAVESTART!
304#
305vop_rename {
306	IN WILLRELE struct vnode *fdvp;
307	IN WILLRELE struct vnode *fvp;
308	IN struct componentname *fcnp;
309	IN WILLPUT struct vnode *tdvp;
310	IN WILLRELE struct vnode *tvp;
311	IN struct componentname *tcnp;
312};
313
314#
315#% mkdir      dvp     L U U
316#% mkdir      vpp     - L -
317#
318#! mkdir cnp	CREATE, LOCKPARENT
319#
320vop_mkdir {
321	IN WILLPUT struct vnode *dvp;
322	OUT struct vnode **vpp;
323	IN struct componentname *cnp;
324	IN struct vattr *vap;
325};
326
327#
328#% rmdir      dvp     L U U
329#% rmdir      vp      L U U
330#
331#! rmdir cnp	DELETE, LOCKPARENT | LOCKLEAF
332#
333vop_rmdir {
334	IN WILLPUT struct vnode *dvp;
335	IN WILLPUT struct vnode *vp;
336	IN struct componentname *cnp;
337};
338
339#
340#% symlink    dvp     L U U
341#% symlink    vpp     - U -
342#
343#! symlink cnp	CREATE, LOCKPARENT
344#
345# XXX - note that the return vnode has already been VRELE'ed
346#     by the filesystem layer.  To use it you must use vget,
347#     possibly with a further namei.
348#
349vop_symlink {
350	IN WILLPUT struct vnode *dvp;
351	OUT WILLRELE struct vnode **vpp;
352	IN struct componentname *cnp;
353	IN struct vattr *vap;
354	IN char *target;
355};
356
357#
358#% readdir    vp      L L L
359#
360vop_readdir {
361	IN struct vnode *vp;
362	INOUT struct uio *uio;
363	IN struct ucred *cred;
364	OUT int *eofflag;
365	OUT off_t **cookies;
366	IN int *ncookies;
367};
368
369#
370#% readlink   vp      L L L
371#
372vop_readlink {
373	IN struct vnode *vp;
374	INOUT struct uio *uio;
375	IN struct ucred *cred;
376};
377
378#
379#% abortop    dvp     = = =
380#
381#! abortop cnp	as appropriate.
382#
383vop_abortop {
384	IN struct vnode *dvp;
385	IN struct componentname *cnp;
386};
387
388#
389#% inactive   vp      L U U
390#
391vop_inactive {
392	IN WILLUNLOCK struct vnode *vp;
393	IN struct proc *p;
394};
395
396#
397#% reclaim    vp      U U U
398#
399vop_reclaim {
400	IN struct vnode *vp;
401	IN struct proc *p;
402};
403
404#
405#% lock               vp      U L U
406#
407vop_lock {
408	IN struct vnode *vp;
409	IN int flags;
410};
411
412#
413#% unlock     vp      L U L
414#
415vop_unlock {
416	IN struct vnode *vp;
417	IN int flags;
418};
419
420#
421#% bmap               vp      L L L
422#% bmap               vpp     - U -
423#
424vop_bmap {
425	IN struct vnode *vp;
426	IN daddr_t bn;
427	OUT struct vnode **vpp;
428	IN daddr_t *bnp;
429	OUT int *runp;
430};
431
432#
433# Needs work: no vp?
434#
435#vop_strategy {
436#	IN struct buf *bp;
437#};
438
439#
440#% print      vp      = = =
441#
442vop_print {
443	IN struct vnode *vp;
444};
445
446#
447#% islocked   vp      = = =
448#
449vop_islocked {
450	IN struct vnode *vp;
451};
452
453#
454#% pathconf   vp      L L L
455#
456vop_pathconf {
457	IN struct vnode *vp;
458	IN int name;
459	OUT register_t *retval;
460};
461
462#
463#% advlock    vp      U U U
464#
465vop_advlock {
466	IN struct vnode *vp;
467	IN caddr_t id;
468	IN int op;
469	IN struct flock *fl;
470	IN int flags;
471};
472
473#
474#% blkatoff   vp      L L L
475#
476vop_blkatoff {
477	IN struct vnode *vp;
478	IN off_t offset;
479	OUT char **res;
480	OUT struct buf **bpp;
481};
482
483#
484#% valloc     pvp     L L L
485#
486vop_valloc {
487	IN struct vnode *pvp;
488	IN int mode;
489	IN struct ucred *cred;
490	OUT struct vnode **vpp;
491};
492
493#
494#% balloc     vp      L L L
495#
496vop_balloc {
497	IN struct vnode *vp;
498	IN off_t startoffset;
499	IN int size;
500	IN struct ucred *cred;
501	IN int flags;
502	OUT struct buf **bpp;
503};
504
505#
506#% ballocn    vp      L L L
507#
508vop_ballocn {
509	IN struct vnode *vp;
510	IN off_t offset;
511	IN off_t length;
512	IN struct ucred *cred;
513	IN int flags;
514};
515
516#
517#% reallocblks        vp      L L L
518#
519vop_reallocblks {
520	IN struct vnode *vp;
521	IN struct cluster_save *buflist;
522};
523
524#
525#% vfree      pvp     L L L
526#
527vop_vfree {
528	IN struct vnode *pvp;
529	IN ino_t ino;
530	IN int mode;
531};
532
533#
534#% truncate   vp      L L L
535#
536vop_truncate {
537	IN struct vnode *vp;
538	IN off_t length;
539	IN int flags;
540	IN struct ucred *cred;
541	IN struct proc *p;
542};
543
544#
545#% update     vp      L L L
546#
547vop_update {
548	IN struct vnode *vp;
549	IN struct timespec *access;
550	IN struct timespec *modify;
551	IN int flags;
552};
553
554#
555#% lease      vp      = = =
556#
557vop_lease {
558	IN struct vnode *vp;
559	IN struct proc *p;
560	IN struct ucred *cred;
561	IN int flag;
562};
563
564#
565#% whiteout   dvp     L L L
566#% whiteout   cnp     - - -
567#% whiteout   flag    - - -
568#
569#! whiteout cnp	CREATE, LOCKPARENT
570#
571vop_whiteout {
572	IN struct vnode *dvp;
573	IN struct componentname *cnp;
574	IN int flags;
575};
576
577#
578# Needs work: no vp?
579#
580#vop_bwrite {
581#	IN struct buf *bp;
582#};
583
584#
585#% getpages	vp L L L
586#
587vop_getpages {
588	IN struct vnode *vp;
589	IN voff_t offset;
590	IN vm_page_t *m;
591	IN int *count;
592	IN int centeridx;
593	IN vm_prot_t access_type;
594	IN int advice;
595	IN int flags;
596};
597
598#
599#% putpages	vp L L L
600#
601vop_putpages {
602	IN struct vnode *vp;
603	IN vm_page_t *m;
604	IN int count;
605	IN int flags;
606	IN int *rtvals;
607};
608
609#
610#% size		vp = = =
611#
612vop_size {
613	IN struct vnode *vp;
614	IN off_t size;
615	OUT off_t *eobp;
616};
617