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