xref: /netbsd-src/sys/kern/vnode_if.src (revision 8b0f9554ff8762542c4defc4f70e1eb76fb508fa)
1#	$NetBSD: vnode_if.src,v 1.55 2007/11/26 19:02:11 pooka 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 successful 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 L L
60#% lookup     vpp     - L -
61#
62# XXX - the lookup locking protocol defies simple description.
63#    Note especially that *vpp may equal dvp.
64#
65#    More details:
66#     There are three types of lookups: ".", ".." (ISDOTDOT), and other.
67#     On successful lookup of ".", a reference is added to dvp, and it
68#          is returned in *vpp.
69#     To look up ISDOTDOT, dvp is unlocked, the ".." node is locked, and
70#          then dvp is relocked.  This preserves the protocol of always
71#          locking nodes from root ("/") downward and prevents deadlock.
72#     Other lookups find the named node (creating the vnode if needed) and
73#          return it, locked, in *vpp.
74#     On failure, *vpp is NULL, and *dvp is left locked.
75#
76#     *vpp is always locked on return if the operation succeeds.
77#          Typically, if *vpp == dvp, you need to release twice, but
78#          unlock only once.
79#
80#     See sys/sys/namei.h for a description of the SAVENAME and SAVESTART
81#          flags.
82#
83vop_lookup {
84	IN struct vnode *dvp;
85	INOUT WILLMAKE struct vnode **vpp;
86	IN struct componentname *cnp;
87};
88
89#
90#% create     dvp     L U U
91#% create     vpp     - L -
92#
93#! create cnp	CREATE, LOCKPARENT
94#
95vop_create {
96	IN LOCKED=YES WILLPUT struct vnode *dvp;
97	OUT WILLMAKE struct vnode **vpp;
98	IN struct componentname *cnp;
99	IN struct vattr *vap;
100};
101
102#
103#% mknod      dvp     L U U
104#% mknod      vpp     - L -
105#
106#! mknod cnp	CREATE, LOCKPARENT
107#
108vop_mknod {
109	IN LOCKED=YES WILLPUT struct vnode *dvp;
110	OUT WILLMAKE struct vnode **vpp;
111	IN struct componentname *cnp;
112	IN struct vattr *vap;
113};
114
115#
116#% open               vp      L L L
117#
118vop_open {
119	IN LOCKED=YES struct vnode *vp;
120	IN int mode;
121	IN kauth_cred_t cred;
122};
123
124#
125#% close      vp      L L L
126#
127vop_close {
128	IN LOCKED=YES struct vnode *vp;
129	IN int fflag;
130	IN kauth_cred_t cred;
131};
132
133#
134#% access     vp      L L L
135#
136vop_access {
137	IN LOCKED=YES struct vnode *vp;
138	IN int mode;
139	IN kauth_cred_t cred;
140};
141
142#
143#% getattr    vp      = = =
144#
145vop_getattr {
146	IN struct vnode *vp;
147	IN struct vattr *vap;
148	IN kauth_cred_t cred;
149};
150
151#
152#% setattr    vp      L L L
153#
154vop_setattr {
155	IN LOCKED=YES struct vnode *vp;
156	IN struct vattr *vap;
157	IN kauth_cred_t cred;
158};
159
160#
161#% read               vp      L L L
162#
163vop_read {
164	IN LOCKED=YES struct vnode *vp;
165	INOUT struct uio *uio;
166	IN int ioflag;
167	IN kauth_cred_t cred;
168};
169
170#
171#% write      vp      L L L
172#
173vop_write {
174	IN LOCKED=YES struct vnode *vp;
175	INOUT struct uio *uio;
176	IN int ioflag;
177	IN kauth_cred_t cred;
178};
179
180#
181#% ioctl      vp      U U U
182#
183vop_ioctl {
184	IN LOCKED=NO struct vnode *vp;
185	IN u_long command;
186	IN void *data;
187	IN int fflag;
188	IN kauth_cred_t cred;
189};
190
191#
192#% fcntl      vp      U U U
193#
194vop_fcntl {
195	IN LOCKED=NO struct vnode *vp;
196	IN u_int command;
197	IN void *data;
198	IN int fflag;
199	IN kauth_cred_t cred;
200};
201
202#
203#% poll     vp      U U U
204#
205vop_poll {
206	IN LOCKED=NO struct vnode *vp;
207	IN int events;
208};
209
210#
211#% kqfilter     vp      U U U
212#
213vop_kqfilter {
214	IN LOCKED=NO struct vnode *vp;
215	IN struct knote *kn;
216};
217
218#
219#% revoke     vp      U U U
220#
221vop_revoke {
222	IN LOCKED=NO struct vnode *vp;
223	IN int flags;
224};
225
226#
227#% mmap      vp      = = =
228#
229vop_mmap {
230	IN struct vnode *vp;
231	IN vm_prot_t prot;
232	IN kauth_cred_t cred;
233};
234
235#
236#% fsync      vp      L L L
237#
238vop_fsync {
239	IN LOCKED=YES struct vnode *vp;
240	IN kauth_cred_t cred;
241	IN int flags;
242	IN off_t offlo;
243	IN off_t offhi;
244};
245
246#
247# Needs work: Is newoff right?  What's it mean?
248# XXX Locking protocol?
249#
250vop_seek {
251	IN struct vnode *vp;
252	IN off_t oldoff;
253	IN off_t newoff;
254	IN kauth_cred_t cred;
255};
256
257#
258#% remove     dvp     L U U
259#% remove     vp      L U U
260#
261#! remove cnp	DELETE, LOCKPARENT | LOCKLEAF
262#
263vop_remove {
264	IN LOCKED=YES WILLPUT struct vnode *dvp;
265	IN LOCKED=YES WILLPUT struct vnode *vp;
266	IN struct componentname *cnp;
267};
268
269#
270#% link               dvp     L U U
271#% link               vp      U U U
272#
273#! link	 cnp	CREATE, LOCKPARENT
274#
275vop_link {
276	IN LOCKED=YES WILLPUT struct vnode *dvp;
277	IN LOCKED=NO struct vnode *vp;
278	IN struct componentname *cnp;
279};
280
281#
282#% rename     fdvp    U U U
283#% rename     fvp     U U U
284#% rename     tdvp    L U U
285#% rename     tvp     X U U
286#
287#! rename fcnp	DELETE,	LOCKPARENT | SAVESTART
288#! rename tcnp	RENAME, LOCKPARENT | LOCKLEAF | NOCACHE | SAVESTART
289#
290# XXX the vop_rename routines should REALLY NOT be depending on SAVESTART!
291#
292vop_rename {
293	IN LOCKED=NO WILLRELE struct vnode *fdvp;
294	IN LOCKED=NO WILLRELE struct vnode *fvp;
295	IN struct componentname *fcnp;
296	IN LOCKED=YES WILLPUT struct vnode *tdvp;
297	IN WILLPUT struct vnode *tvp;
298	IN struct componentname *tcnp;
299};
300
301#
302#% mkdir      dvp     L U U
303#% mkdir      vpp     - L -
304#
305#! mkdir cnp	CREATE, LOCKPARENT
306#
307vop_mkdir {
308	IN LOCKED=YES WILLPUT struct vnode *dvp;
309	OUT WILLMAKE struct vnode **vpp;
310	IN struct componentname *cnp;
311	IN struct vattr *vap;
312};
313
314#
315#% rmdir      dvp     L U U
316#% rmdir      vp      L U U
317#
318#! rmdir cnp	DELETE, LOCKPARENT | LOCKLEAF
319#
320vop_rmdir {
321	IN LOCKED=YES WILLPUT struct vnode *dvp;
322	IN LOCKED=YES WILLPUT struct vnode *vp;
323	IN struct componentname *cnp;
324};
325
326#
327#% symlink    dvp     L U U
328#% symlink    vpp     - L -
329#
330#! symlink cnp	CREATE, LOCKPARENT
331#
332vop_symlink {
333	IN LOCKED=YES WILLPUT struct vnode *dvp;
334	OUT WILLMAKE struct vnode **vpp;
335	IN struct componentname *cnp;
336	IN struct vattr *vap;
337	IN char *target;
338};
339
340#
341#% readdir    vp      L L L
342#
343vop_readdir {
344	IN LOCKED=YES struct vnode *vp;
345	INOUT struct uio *uio;
346	IN kauth_cred_t cred;
347	OUT int *eofflag;
348	OUT off_t **cookies;
349	IN int *ncookies;
350};
351
352#
353#% readlink   vp      L L L
354#
355vop_readlink {
356	IN LOCKED=YES struct vnode *vp;
357	INOUT struct uio *uio;
358	IN kauth_cred_t cred;
359};
360
361#
362#% abortop    dvp     = = =
363#
364#! abortop cnp	as appropriate.
365#
366vop_abortop {
367	IN struct vnode *dvp;
368	IN struct componentname *cnp;
369};
370
371#
372#% inactive   vp      L U U
373#
374vop_inactive {
375	IN LOCKED=YES WILLUNLOCK struct vnode *vp;
376};
377
378#
379#% reclaim    vp      U U U
380#
381vop_reclaim {
382	IN LOCKED=NO struct vnode *vp;
383};
384
385#
386#% lock               vp      U L U
387#
388vop_lock {
389	IN LOCKED=NO struct vnode *vp;
390	IN int flags;
391};
392
393#
394#% unlock     vp      L U L
395#
396vop_unlock {
397	IN LOCKED=YES struct vnode *vp;
398	IN int flags;
399};
400
401#
402#% bmap               vp      = = =
403#% bmap               vpp     - U -
404#
405vop_bmap {
406	IN struct vnode *vp;
407	IN daddr_t bn;
408	OUT struct vnode **vpp;
409	IN daddr_t *bnp;
410	OUT int *runp;
411};
412
413#
414#% strategy   vp      = = =
415#
416vop_strategy {
417	IN struct vnode *vp;
418	IN struct buf *bp;
419};
420
421#
422#% print      vp      = = =
423#
424vop_print {
425	IN struct vnode *vp;
426};
427
428#
429#% islocked   vp      = = =
430#
431vop_islocked {
432	IN struct vnode *vp;
433};
434
435#
436#% pathconf   vp      L L L
437#
438vop_pathconf {
439	IN LOCKED=YES struct vnode *vp;
440	IN int name;
441	OUT register_t *retval;
442};
443
444#
445#% advlock    vp      U U U
446#
447vop_advlock {
448	IN LOCKED=NO struct vnode *vp;
449	IN void *id;
450	IN int op;
451	IN struct flock *fl;
452	IN int flags;
453};
454
455#
456#% lease      vp      = = =
457#
458vop_lease {
459	IN struct vnode *vp;
460	IN kauth_cred_t cred;
461	IN int flag;
462};
463
464#
465#% whiteout   dvp     L L L
466#% whiteout   cnp     - - -
467#% whiteout   flag    - - -
468#
469#! whiteout cnp	CREATE, LOCKPARENT
470#
471vop_whiteout {
472	IN LOCKED=YES struct vnode *dvp;
473	IN struct componentname *cnp;
474	IN int flags;
475};
476
477#
478# Needs work: no vp?
479#
480#vop_bwrite {
481#	IN struct buf *bp;
482#};
483
484#
485#% getpages	vp = = =
486#
487vop_getpages {
488	IN struct vnode *vp;
489	IN voff_t offset;
490	IN struct vm_page **m;
491	IN int *count;
492	IN int centeridx;
493	IN vm_prot_t access_type;
494	IN int advice;
495	IN int flags;
496};
497
498#
499#% putpages	vp = = =
500#
501vop_putpages {
502	IN struct vnode *vp;
503	IN voff_t offlo;
504	IN voff_t offhi;
505	IN int flags;
506};
507
508#
509#% closeextattr	vp L L L
510#
511vop_closeextattr {
512	IN LOCKED=YES struct vnode *vp;
513	IN int commit;
514	IN kauth_cred_t cred;
515};
516
517#
518#% getextattr	vp L L L
519#
520vop_getextattr {
521	IN LOCKED=YES struct vnode *vp;
522	IN int attrnamespace;
523	IN const char *name;
524	INOUT struct uio *uio;
525	OUT size_t *size;
526	IN kauth_cred_t cred;
527};
528
529#
530#% listextattr	vp L L L
531#
532vop_listextattr {
533	IN LOCKED=YES struct vnode *vp;
534	IN int attrnamespace;
535	INOUT struct uio *uio;
536	OUT size_t *size;
537	IN kauth_cred_t cred;
538};
539
540#
541#% openextattr	vp L L L
542#
543vop_openextattr {
544	IN LOCKED=YES struct vnode *vp;
545	IN kauth_cred_t cred;
546};
547
548#
549#% deleteextattr vp L L L
550#
551vop_deleteextattr {
552	IN LOCKED=YES struct vnode *vp;
553	IN int attrnamespace;
554	IN const char *name;
555	IN kauth_cred_t cred;
556};
557
558#
559#% setextattr	vp L L L
560#
561vop_setextattr {
562	IN LOCKED=YES struct vnode *vp;
563	IN int attrnamespace;
564	IN const char *name;
565	INOUT struct uio *uio;
566	IN kauth_cred_t cred;
567};
568