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