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