1.\" $OpenBSD: VOP_LOOKUP.9,v 1.46 2022/06/26 05:20:42 visa Exp $ 2.\" 3.\" Copyright (c) 2003 Ted Unangst 4.\" Copyright (c) 2000, 2001 The NetBSD Foundation, Inc. 5.\" All rights reserved. 6.\" 7.\" Redistribution and use in source and binary forms, with or without 8.\" modification, are permitted provided that the following conditions 9.\" are met: 10.\" 1. Redistributions of source code must retain the above copyright 11.\" notice, this list of conditions and the following disclaimer. 12.\" 2. Redistributions in binary form must reproduce the above copyright 13.\" notice, this list of conditions and the following disclaimer in the 14.\" documentation and/or other materials provided with the distribution. 15.\" 16.\" THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR 17.\" IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES 18.\" OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. 19.\" IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, 20.\" INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT 21.\" NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 22.\" DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 23.\" THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 24.\" (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF 25.\" THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 26.\" 27.Dd $Mdocdate: June 26 2022 $ 28.Dt VOP_LOOKUP 9 29.Os 30.Sh NAME 31.Nm VOP_LOOKUP , 32.Nm VOP_ABORTOP , 33.Nm VOP_ACCESS , 34.Nm VOP_ADVLOCK , 35.Nm VOP_BMAP , 36.Nm VOP_BWRITE , 37.Nm VOP_CLOSE , 38.Nm VOP_CREATE , 39.Nm VOP_FSYNC , 40.Nm VOP_GETATTR , 41.Nm VOP_INACTIVE , 42.Nm VOP_IOCTL , 43.Nm VOP_ISLOCKED , 44.Nm VOP_KQFILTER , 45.Nm VOP_LINK , 46.Nm VOP_LOCK , 47.Nm VOP_MKDIR , 48.Nm VOP_MKNOD , 49.Nm VOP_OPEN , 50.Nm VOP_PATHCONF , 51.Nm VOP_PRINT , 52.Nm VOP_READ , 53.Nm VOP_READDIR , 54.Nm VOP_READLINK , 55.Nm VOP_RECLAIM , 56.Nm VOP_REMOVE , 57.Nm VOP_RENAME , 58.Nm VOP_REVOKE , 59.Nm VOP_RMDIR , 60.Nm VOP_SETATTR , 61.Nm VOP_STRATEGY , 62.Nm VOP_SYMLINK , 63.Nm VOP_UNLOCK , 64.Nm VOP_WRITE 65.Nd vnode operations 66.Sh SYNOPSIS 67.In sys/vnode.h 68.Ft int 69.Fo VOP_ABORTOP 70.Fa "struct vnode *dvp" 71.Fa "struct componentname *cnp" 72.Fc 73.Ft int 74.Fo VOP_ACCESS 75.Fa "struct vnode *vp" 76.Fa "int mode" 77.Fa "struct ucred *cred" 78.Fa "struct proc *p" 79.Fc 80.Ft int 81.Fo VOP_ADVLOCK 82.Fa "struct vnode *vp" 83.Fa "void *id" 84.Fa "int op" 85.Fa "struct flock *fl" 86.Fa "int flags" 87.Fc 88.Ft int 89.Fo VOP_BMAP 90.Fa "struct vnode *vp" 91.Fa "daddr_t bn" 92.Fa "struct vnode **vpp" 93.Fa "daddr_t *bnp" 94.Fa "int *runp" 95.Fc 96.Ft int 97.Fo VOP_BWRITE 98.Fa "struct buf *bp" 99.Fc 100.Ft int 101.Fo VOP_CLOSE 102.Fa "struct vnode *vp" 103.Fa "int fflag" 104.Fa "struct ucred *cred" 105.Fa "struct proc *p" 106.Fc 107.Ft int 108.Fo VOP_CREATE 109.Fa "struct vnode *dvp" 110.Fa "struct vnode **vpp" 111.Fa "struct componentname *cnp" 112.Fa "struct vattr *vap" 113.Fc 114.Ft int 115.Fo VOP_FSYNC 116.Fa "struct vnode *vp" 117.Fa "struct ucred *cred" 118.Fa "int waitfor" 119.Fa "struct proc *p" 120.Fc 121.Ft int 122.Fo VOP_GETATTR 123.Fa "struct vnode *vp" 124.Fa "struct vattr *vap" 125.Fa "struct ucred *cred" 126.Fa "struct proc *p" 127.Fc 128.Ft int 129.Fo VOP_INACTIVE 130.Fa "struct vnode *vp" 131.Fa "struct proc *p" 132.Fc 133.Ft int 134.Fo VOP_IOCTL 135.Fa "struct vnode *vp" 136.Fa "u_long command" 137.Fa "void *data" 138.Fa "int fflag" 139.Fa "struct ucred *cred" 140.Fa "struct proc *p" 141.Fc 142.Ft int 143.Fo VOP_ISLOCKED 144.Fa "struct vnode *vp" 145.Fc 146.Ft int 147.Fo VOP_KQFILTER 148.Fa "struct vnode *vp" 149.Fa "struct knote *kn" 150.Fc 151.Ft int 152.Fo VOP_LINK 153.Fa "struct vnode *dvp" 154.Fa "struct vnode *vp" 155.Fa "struct componentname *cnp" 156.Fc 157.Ft int 158.Fo VOP_LOCK 159.Fa "struct vnode *vp" 160.Fa "int flags" 161.Fc 162.Ft int 163.Fo VOP_LOOKUP 164.Fa "struct vnode *dvp" 165.Fa "struct vnode **vpp" 166.Fa "struct componentname *cnp" 167.Fc 168.Ft int 169.Fo VOP_MKDIR 170.Fa "struct vnode *dvp" 171.Fa "struct vnode **vpp" 172.Fa "struct componentname *cnp" 173.Fa "struct vattr *vap" 174.Fc 175.Ft int 176.Fo VOP_MKNOD 177.Fa "struct vnode *dvp" 178.Fa "struct vnode **vpp" 179.Fa "struct componentname *cnp" 180.Fa "struct vattr *vap" 181.Fc 182.Ft int 183.Fo VOP_OPEN 184.Fa "struct vnode *vp" 185.Fa "int mode" 186.Fa "struct ucred *cred" 187.Fa "struct proc *p" 188.Fc 189.Ft int 190.Fo VOP_PATHCONF 191.Fa "struct vnode *vp" 192.Fa "int name" 193.Fa "register_t *retval" 194.Fc 195.Ft int 196.Fo VOP_PRINT 197.Fa "struct vnode *vp" 198.Fc 199.Ft int 200.Fo VOP_READ 201.Fa "struct vnode *vp" 202.Fa "struct uio *uio" 203.Fa "int ioflag" 204.Fa "struct ucred *cred" 205.Fc 206.Ft int 207.Fo VOP_READDIR 208.Fa "struct vnode *vp" 209.Fa "struct uio *uio" 210.Fa "struct ucred *cred" 211.Fa "int *eofflag" 212.Fc 213.Ft int 214.Fo VOP_READLINK 215.Fa "struct vnode *vp" 216.Fa "struct uio *uio" 217.Fa "struct ucred *cred" 218.Fc 219.Ft int 220.Fo VOP_RECLAIM 221.Fa "struct vnode *vp" 222.Fa "struct proc *p" 223.Fc 224.Ft int 225.Fo VOP_REMOVE 226.Fa "struct vnode *dvp" 227.Fa "struct vnode *vp" 228.Fa "struct componentname *cnp" 229.Fc 230.Ft int 231.Fo VOP_RENAME 232.Fa "struct vnode *fdvp" 233.Fa "struct vnode *fvp" 234.Fa "struct componentname *fcnp" 235.Fa "struct vnode *tdvp" 236.Fa "struct vnode *tvp" 237.Fa "struct componentname *tcnp" 238.Fc 239.Ft int 240.Fo VOP_REVOKE 241.Fa "struct vnode *vp" 242.Fa "int flags" 243.Fc 244.Ft int 245.Fo VOP_RMDIR 246.Fa "struct vnode *dvp" 247.Fa "struct vnode *vp" 248.Fa "struct componentname *cnp" 249.Fc 250.Ft int 251.Fo VOP_SETATTR 252.Fa "struct vnode *vp" 253.Fa "struct vattr *vap" 254.Fa "struct ucred *cred" 255.Fa "struct proc *p" 256.Fc 257.Ft int 258.Fo VOP_STRATEGY 259.Fa "struct vnode *vp" 260.Fa "struct buf *bp" 261.Fc 262.Ft int 263.Fo VOP_SYMLINK 264.Fa "struct vnode *dvp" 265.Fa "struct vnode **vpp" 266.Fa "struct componentname *cnp" 267.Fa "struct vattr *vap" 268.Fa "char *target" 269.Fc 270.Ft int 271.Fo VOP_UNLOCK 272.Fa "struct vnode *vp" 273.Fc 274.Ft int 275.Fo VOP_WRITE 276.Fa "struct vnode *vp" 277.Fa "struct uio *uio" 278.Fa "int ioflag" 279.Fa "struct ucred *cred" 280.Fc 281.Sh DESCRIPTION 282The 283.Nm VOP 284functions implement a generic way to perform operations on vnodes. 285The VOP function called passes the arguments to the correct file system 286specific function. 287Not all file systems implement all operations, in which case a generic 288method will be used. 289These functions exist to provide an abstract method to invoke vnode 290operations without needing to know anything about the underlying file system. 291Many system calls map directly to a specific VOP function. 292.Pp 293The arguments for each VOP 294function consist of one or more vnode pointers along with other data 295needed to perform the operation. 296Care must be taken to obey the vnode locking discipline when using 297VOP functions. 298Many VOP calls take a 299.Vt struct proc *p 300argument. 301This should be the current process. 302VOP calls are not safe to call in an interrupt context. 303.Pp 304The 305.Vt vattr 306structure used by 307.Fn VOP_CREATE , 308.Fn VOP_GETATTR , 309.Fn VOP_MKDIR , 310.Fn VOP_MKNOD , 311.Fn VOP_SETATTR , 312and 313.Fn VOP_SYMLINK 314is: 315.Bd -literal 316struct vattr { 317 enum vtype va_type; /* vnode type */ 318 mode_t va_mode; /* files access mode and type */ 319 nlink_t va_nlink; /* number of references */ 320 uid_t va_uid; /* owner user id */ 321 gid_t va_gid; /* owner group id */ 322 long va_fsid; /* file system id */ 323 u_quad_t va_fileid; /* file id */ 324 u_quad_t va_size; /* file size in bytes */ 325 long va_blocksize; /* blocksize preferred for i/o */ 326 struct timespec va_atime; /* time of last access */ 327 struct timespec va_mtime; /* time of last modification */ 328 struct timespec va_ctime; /* time file changed */ 329 u_long va_gen; /* generation number of file */ 330 u_long va_flags; /* flags defined for file */ 331 dev_t va_rdev; /* device the vnode represents */ 332 u_quad_t va_bytes; /* bytes of held disk space */ 333 u_quad_t va_filerev; /* file modification number */ 334 u_int va_vaflags; /* operations flags */ 335 long va_spare; /* remain quad aligned */ 336}; 337.Ed 338.Pp 339The following sections comment on the VOP functions from the consumer's 340perspective. 341.Pp 342.Bl -tag -width Ds -compact 343.It Fn VOP_ABORTOP dvp cnp 344Abort any asynchronous operations pending on the vnode 345.Fa dvp 346associated with the path name 347.Fa cnp . 348This is mostly used by internal VFS code and should not be needed by 349file system implementors. 350.Pp 351.It Fn VOP_ACCESS vp mode cred p 352Determine if the locked vnode 353.Fa vp 354can be accessed by the calling process 355.Fa p 356with credentials 357.Fa cred 358for the given access 359.Fa mode . 360.Pp 361.Fa mode 362may contain any of the following values: 363.Pp 364.Bl -tag -width Ds -compact -offset indent 365.It Dv VWRITE 366check writeability 367.It Dv VREAD 368check readability 369.It Dv VEXEC 370check executability 371.El 372.Pp 373If the access check succeeds, zero is returned; otherwise, an 374appropriate error code is returned. 375.Pp 376.It Fn VOP_ADVLOCK vp id op fl flags 377Perform advisory locking on the vnode 378.Fa vp 379according to the operation 380.Fa op 381and lock specification 382.Fa fl . 383.Fa id 384identifies the resource holding the lock 385(typically a pointer to the holding process). 386.Pp 387.Fa op 388may be one of the following operations: 389.Pp 390.Bl -tag -width F_GETLK -compact -offset indent 391.It Dv F_GETLK 392Get the first lock that would block a lock request. 393.It Dv F_SETLK 394Set a lock. 395.It Dv F_UNLCK 396Release a lock. 397.El 398.Pp 399.Fa flags 400may contain the following flags: 401.Pp 402.Bl -tag -width F_POSIX -compact -offset indent 403.It Dv F_WAIT 404If required, block waiting to obtain an exclusive lock. 405.It Dv F_POSIX 406Follow POSIX locking semantics; see 407.Xr fcntl 2 . 408.It Dv F_FLOCK 409Follow 410.Xr flock 2 411locking semantics. 412.El 413.Pp 414Upon success, zero is returned; otherwise, an appropriate error code is 415returned. 416.Pp 417.It Fn VOP_BMAP vp bn vpp bnp runp 418Convert the logical block number 419.Fa bn 420of the file the locked vnode 421.Fa vp 422is associated with its physical number on-disk. 423The physical block number is stored in 424.Fa *bnp 425on return. 426.Fa vpp , 427if 428.No non- Ns Dv NULL , 429will be updated to point to the vnode of the block device of which 430.Fa vp 431is associated. 432.Fa runp , 433if 434.No non- Ns Dv NULL , 435will be updated to the number of contiguous disk blocks following 436.Fa *bnp . 437Upon success, zero is returned; otherwise, an appropriate error code is 438returned. 439.Pp 440.It Fn VOP_BWRITE bp 441Write a file system buffer to disk. 442Upon success, zero is returned; otherwise, an appropriate error code is 443returned. 444.Pp 445.It Fn VOP_CLOSE vp fflag cred p 446Close the file associated with the locked vnode 447.Fa vp 448with file flags 449.Fa fflag 450by the calling process 451.Fa p 452with credentials 453.Fa cred . 454This operation should be performed only when the file is no longer being 455used. 456Upon success, zero is returned; otherwise, an appropriate error code is 457returned. 458.Pp 459.It Fn VOP_CREATE dvp vpp cnp vap 460Create a new directory entry for a regular file in the directory 461.Fa dvp 462and return a locked, referenced vnode in 463.Fa vpp . 464The file name is in 465.Fa cnp 466and its permissions will be 467.Fa vap . 468.Fa dvp 469must be locked. 470.Pp 471.It Fn VOP_FSYNC vp cred waitfor p 472Flush any dirty buffers associated with 473.Fa vp 474to disk. 475The vnode is locked on entry and exit. 476.Fa waitfor 477can be set to 478.Dv MNT_WAIT 479to indicate that 480.Fn VOP_FSYNC 481should not return until all data is written. 482.Pp 483.It Fn VOP_GETATTR vp vap cred p 484.It Fn VOP_SETATTR vp vap cred p 485Access the vnode attributes 486.Fa vap 487of the vnode 488.Fa vp 489by the calling process 490.Fa p 491with credentials 492.Fa cred . 493.Fn VOP_SETATTR 494requires that 495.Fa vp 496be locked. 497A field value for any member of 498.Fa vap 499of 500.Dv VNOVAL 501represents that the information could not be obtained by 502.Fn VOP_GETATTR 503or should not be changed by 504.Fn VOP_SETATTR . 505Upon success of obtaining or changing the attributes, zero is returned; 506otherwise, an appropriate error code is returned. 507All attributes are held in the 508.Vt vattr 509structure shown above. 510.Pp 511.It Fn VOP_INACTIVE vp p 512Notify the underlying file system that the locked vnode 513.Fa vp 514is no longer in use. 515The vnode will be unlocked upon return. 516.Fa p 517specifies the calling process. 518This may happen when the vnode reference count reaches zero or 519when the underlying file system has disappeared or has been forcibly 520unmounted. 521.Pp 522Typically, the underlying file system will write any buffers associated 523with 524.Fa vp 525to disk or delete the file entry, if need be. 526The underlying file system may not necessarily release any buffers 527associated with 528.Fa vp 529so that it can be immediately reactivated in case the file is used again. 530Upon success, zero is returned; otherwise, an appropriate error code is 531returned. 532.Pp 533.It Fn VOP_IOCTL vp command data fflag cred p 534Perform the control operation 535.Fa command 536with additional information 537.Fa data 538on the vnode 539.Fa vp , 540normally associated with a device, 541with file flags 542.Fa fflag 543by the calling process 544.Fa p 545with credentials 546.Fa cred . 547Upon success, zero is returned; otherwise, an appropriate error code is 548returned. 549.Pp 550.It Fn VOP_ISLOCKED vp 551.It Fn VOP_LOCK vp flags 552.It Fn VOP_UNLOCK vp 553.Fn VOP_LOCK 554is used internally by 555.Xr vn_lock 9 556to lock a vnode. 557It should not be used by other file system code. 558.Fn VOP_UNLOCK 559unlocks a vnode. 560Note the asymmetry between 561.Xr vn_lock 9 562and 563.Fn VOP_UNLOCK . 564.Pp 565.Fa flags 566may contain the following flags: 567.Pp 568.Bl -tag -width LK_RECURSEFAIL -compact -offset indent 569.It Dv LK_EXCLUSIVE 570Acquire an exclusive lock. 571.It Dv LK_SHARED 572Acquire a shared lock. 573.It Dv LK_NOWAIT 574Don't wait if the vnode lock is held by someone else 575(may still wait on reclamation lock). 576.It Dv LK_RECURSEFAIL 577Attempt at recursive lock fails. 578.It Dv LK_DRAIN 579Used to mean something else, but is now used abused as a flag to avoid a lock 580inversion deadlock in deadfs. 581Do not use this, it must die. 582.El 583.Pp 584.Fn VOP_ISLOCKED 585returns one of the following values: 586.Pp 587.Bl -tag -width LK_EXCLUSIVE -compact -offset indent 588.It Dv LK_EXCLUSIVE 589.Fa vp 590is locked for exclusive access by the calling thread. 591.It Dv LK_EXCLOTHER 592.Fa vp 593is locked for exclusive access by a different thread. 594.It Dv LK_SHARED 595.Fa vp 596is locked for shared access. 597The current thread may be one of the threads that have it locked. 598.It 0 599.Fa vp 600is not locked. 601.El 602.Pp 603.Fn VOP_ISLOCKED 604should be used cautiously, as not all file systems implement locks 605effectively. 606.Pp 607.It Fn VOP_KQFILTER vp kn 608Register the 609.Xr knote 9 610filtering information 611.Fa kn 612for the vnode 613.Fa vp . 614Only filters for 615.Dv EVFILT_READ , 616.Dv EVFILT_WRITE , 617and 618.Dv EVFILT_VNODE 619will invoke this operation. 620Upon success, zero is returned; otherwise, a non-zero value is returned. 621.Pp 622.It Fn VOP_LINK dvp vp cnp 623Increase the link count for the vnode 624.Fa vp . 625A new entry with name 626.Fa cnp 627should be added to the directory 628.Fa dvp . 629.Fa dvp 630is locked on entry and unlocked on exit. 631.Pp 632.It Fn VOP_LOOKUP dvp vpp cnp 633Find the file corresponding to the name 634.Fa cnp 635in the directory 636.Fa dvp 637and return a vnode in 638.Fa vpp . 639.Fa dvp 640must be locked and referenced on entry with 641.Xr vget 9 . 642On a successful return, 643.Fa vpp 644will be returned locked and referenced, and 645.Fa dvp 646will return with the same reference count, but may be returned locked 647or unlocked depending on the specific flags used in 648.Fa cnp->cn_flags . 649On error 650.Fa vpp 651will be 652.Dv NULL 653and 654.Fa cnp->cn_flags 655will be set to 656.Dv PDIRUNLOCK 657if 658.Fa dvp 659has been unlocked. 660.Pp 661.It Fn VOP_MKDIR dvp vpp cnp vap 662Create a new directory named by 663.Fa cnp 664with permissions 665.Fa vattr 666in the directory 667.Fa dvp . 668On success, the new vnode is returned locked in 669.Fa vpp . 670.Fa dvp 671must be locked on entry and is unlocked on exit. 672.Pp 673.It Fn VOP_MKNOD dvp vpp cnp vap 674Create a device special file with name 675.Fa cnp 676and attributes 677.Fa vap 678in the directory associated with the locked vnode 679.Fa dvp . 680A pointer to the new, locked vnode will be returned in 681.Fa *vpp 682if 683.Fa vpp 684is not 685.Dv NULL . 686Upon success, zero is returned; otherwise, an appropriate error code is 687returned. 688.Pp 689.It Fn VOP_OPEN vp mode cred p 690Open the file associated with the vnode 691.Fa vp 692with the access modes 693.Fa mode 694by the calling process 695.Fa p 696with credentials 697.Fa cred . 698.Fa mode 699takes the flags described in 700.Xr open 2 . 701.Pp 702For some underlying file systems, access permissions for the file by the 703process are checked; for others, this is a no-op. 704In any case, this must be called before a process can access the file. 705Upon success, zero is returned; otherwise, an appropriate error code is 706returned. 707.Pp 708.It Fn VOP_PATHCONF vp name retval 709Obtain the value of the applicable POSIX configurable pathname variable (see 710.Xr pathconf 2 ) 711specified by 712.Fa name 713from the locked vnode 714.Fa vp . 715The result is placed in 716.Fa *retval . 717Upon success, zero is returned; otherwise, an appropriate error code is 718returned. 719.Pp 720.It Fn VOP_PRINT vp 721Print information about the vnode to the kernel message buffer. 722It is not used normally, but exists only for debugging purposes. 723.Pp 724.It Fn VOP_READ vp uio ioflag cred 725Copy data from the locked vnode 726.Fa vp 727to the buffers specified by 728.Fa uio 729with calling process credentials 730.Fa cred . 731.Pp 732.Fa ioflag 733may contain the following flags: 734.Pp 735.Bl -tag -width IO_APPEND -offset indent -compact 736.It Dv IO_NDELAY 737Non-blocking I/O. 738.It Dv IO_UNIT 739Do I/O as an atomic unit. 740.El 741.Pp 742Upon success, zero is returned; otherwise, an appropriate error code is 743returned. 744.Pp 745.It Fn VOP_READDIR vp uio cred eofflag 746Read the contents of the directory associated with the locked vnode 747.Fa vp , 748usually via 749.Fn VOP_READ , 750and convert its file-system-specific format to that expected by the 751.Xr getdents 2 752system call, storing the result into the buffers specified by 753.Fa uio . 754.Fa cred 755specifies the credentials of the calling process. 756.Fa *eofflag 757is set to a non-zero value on return once successful end-of-file for the 758directory contents has been reached. 759.Pp 760Upon success, zero is returned; otherwise, an appropriate error code is 761returned. 762.Pp 763.It Fn VOP_READLINK vp uio cred 764Read a symbolic link and return the target's name in 765.Fa uio . 766.Fa vp 767is locked on entry and exit and must be a symlink. 768.Pp 769.It Fn VOP_RECLAIM vp p 770Used by 771.Xr vclean 9 772so that the file system has an opportunity to free memory 773and perform any other cleanup activity related to 774.Fa vp . 775.Fa vp 776is unlocked on entry and exit. 777.Fn VOP_RECLAIM 778should not be used by generic code. 779.Pp 780.It Fn VOP_REMOVE dvp vp cnp 781Remove the link named 782.Fa cnp 783from the directory 784.Fa dvp . 785This file corresponds to the vnode 786.Fa vp . 787Both 788.Fa dvp 789and 790.Fa vp 791are locked on entry and unlocked on exit, and 792each has its reference count decremented by one. 793.Fn VOP_REMOVE 794does not delete the file from disk unless its link count 795becomes zero (for file systems which support multiple links). 796.Pp 797.It Fn VOP_RENAME fdvp fvp fcnp tdvp tvp tcnp 798Remove the link to the file with associated vnode 799.Fa fvp 800and name 801.Fa fcnp 802in the directory with associated vnode 803.Fa fdvp , 804and create a new link to the file with name 805.Fa tcnp 806(and associated locked vnode 807.Fa tvp , 808if the file already exists) residing in the directory with the 809associated locked vnode 810.Fa tdvp . 811.Fa fdvp , 812.Fa fvp , 813and 814.Fa tvp 815(if not 816.Dv NULL ) 817will be released (see 818.Xr vrele 9 ) 819and 820.Fa tdvp 821will have its reference count decremented (see 822.Xr vput 9 ) 823on return. 824If not 825.Dv NULL , 826.Fa tvp 827will be unlocked on return (see 828.Xr vput 9 ) . 829Upon success, zero is returned; otherwise, an appropriate error code is 830returned. 831.Pp 832.It Fn VOP_REVOKE vp flags 833Used by the 834.Xr revoke 2 835system call to prevent any further access to a vnode. 836The vnode ops will be changed to those of deadfs, which returns only 837errors. 838.Ar vp 839must be unlocked. 840.Pp 841.It Fn VOP_RMDIR dvp vp cnp 842Remove the directory 843.Fa vp 844from the directory 845.Fa dvp . 846Both are locked on entry and unlocked on exit. 847The name of the directory for removal is additionally contained in 848.Fa cnp . 849.Pp 850.It Fn VOP_STRATEGY vp bp 851Call the appropriate strategy function for the device vnode 852.Fa vp 853to read or write the buffer 854.Fa bp . 855.Pp 856.It Fn VOP_SYMLINK dvp vpp cnp vap target 857Create a symbolic link with name 858.Fa cnp 859in the directory 860.Fa dvp 861with mode 862.Fa vap . 863The link will point to 864.Fa target 865and a vnode for it is returned in 866.Fa vpp . 867The directory vnode is locked on entry and unlocked on exit. 868Note that unlike most VOP calls returning a vnode, 869.Fn VOP_SYMLINK 870does not lock or reference 871.Fa vpp . 872.Pp 873.It Fn VOP_WRITE vp uio ioflag cred 874Copy data from the buffers specified by 875.Fa uio 876to the locked vnode 877.Fa vp 878with calling process credentials 879.Fa cred . 880.Pp 881.Fa ioflag 882may contain the following flags: 883.Pp 884.Bl -tag -width IO_APPEND -offset indent -compact 885.It Dv IO_APPEND 886Perform write at the end of file. 887.It Dv IO_NDELAY 888Non-blocking I/O. 889.It Dv IO_SYNC 890Wait for I/O to complete. 891.It Dv IO_UNIT 892Do I/O as an atomic unit. 893.El 894.Pp 895Upon success, zero is returned; otherwise, an appropriate error code is 896returned. 897.El 898.Sh RETURN VALUES 899The 900.Nm VOP 901functions return 0 to indicate success and a non-zero error code 902to indicate failure. 903.Sh SEE ALSO 904.Xr errno 2 , 905.Xr uiomove 9 , 906.Xr vfs 9 , 907.Xr vn_lock 9 , 908.Xr vnode 9 909.Sh AUTHORS 910This man page was written by 911.An Ted Unangst 912for 913.Ox . 914.Sh BUGS 915The locking discipline is too complex. 916Refer to 917.Xr vn_lock 9 . 918