1.\" $NetBSD: vnodeops.9,v 1.33 2005/01/11 01:51:12 chs Exp $ 2.\" 3.\" Copyright (c) 2001, 2005 The NetBSD Foundation, Inc. 4.\" All rights reserved. 5.\" 6.\" This code is derived from software contributed to The NetBSD Foundation 7.\" by Gregory McGarry. 8.\" 9.\" Redistribution and use in source and binary forms, with or without 10.\" modification, are permitted provided that the following conditions 11.\" are met: 12.\" 1. Redistributions of source code must retain the above copyright 13.\" notice, this list of conditions and the following disclaimer. 14.\" 2. Redistributions in binary form must reproduce the above copyright 15.\" notice, this list of conditions and the following disclaimer in the 16.\" documentation and/or other materials provided with the distribution. 17.\" 3. All advertising materials mentioning features or use of this software 18.\" must display the following acknowledgement: 19.\" This product includes software developed by the NetBSD 20.\" Foundation, Inc. and its contributors. 21.\" 4. Neither the name of The NetBSD Foundation nor the names of its 22.\" contributors may be used to endorse or promote products derived 23.\" from this software without specific prior written permission. 24.\" 25.\" THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS 26.\" ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED 27.\" TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR 28.\" PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS 29.\" BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 30.\" CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 31.\" SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 32.\" INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 33.\" CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 34.\" ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 35.\" POSSIBILITY OF SUCH DAMAGE. 36.\" 37.Dd January 2, 2005 38.Dt VNODEOPS 9 39.Os 40.Sh NAME 41.Nm vnodeops , 42.Nm VOP_LOOKUP , 43.Nm VOP_CREATE , 44.Nm VOP_MKNOD , 45.Nm VOP_OPEN , 46.Nm VOP_CLOSE , 47.Nm VOP_ACCESS , 48.Nm VOP_GETATTR , 49.Nm VOP_SETATTR , 50.Nm VOP_READ , 51.Nm VOP_WRITE , 52.Nm VOP_IOCTL , 53.Nm VOP_FCNTL , 54.Nm VOP_POLL , 55.Nm VOP_REVOKE , 56.Nm VOP_MMAP , 57.Nm VOP_FSYNC , 58.Nm VOP_SEEK , 59.Nm VOP_REMOVE , 60.Nm VOP_LINK , 61.Nm VOP_RENAME , 62.Nm VOP_MKDIR , 63.Nm VOP_RMDIR , 64.Nm VOP_SYMLINK , 65.Nm VOP_READDIR , 66.Nm VOP_READLINK , 67.Nm VOP_ABORTOP , 68.Nm VOP_INACTIVE , 69.Nm VOP_RECLAIM , 70.Nm VOP_LOCK , 71.Nm VOP_UNLOCK , 72.Nm VOP_ISLOCKED , 73.Nm VOP_BMAP , 74.Nm VOP_PRINT , 75.Nm VOP_PATHCONF , 76.Nm VOP_ADVLOCK , 77.Nm VOP_BLKATOFF , 78.Nm VOP_VALLOC , 79.Nm VOP_BALLOC , 80.Nm VOP_REALLOCBLKS , 81.Nm VOP_VFREE , 82.Nm VOP_TRUNCATE , 83.Nm VOP_UPDATE , 84.Nm VOP_LEASE , 85.Nm VOP_WHITEOUT , 86.Nm VOP_GETPAGES , 87.Nm VOP_PUTPAGES , 88.Nm VOP_STRATEGY , 89.Nm VOP_BWRITE , 90.Nm VOP_GETEXTATTR , 91.Nm VOP_SETEXTATTR , 92.Nm VOP_LISTEXTATTR , 93.Nd vnode operations 94.Sh SYNOPSIS 95.In sys/param.h 96.In sys/buf.h 97.In sys/dirent.h 98.In sys/lock.h 99.In sys/vnode.h 100.In sys/mount.h 101.In sys/namei.h 102.In sys/unistd.h 103.In sys/fcntl.h 104.In sys/lockf.h 105.In sys/extattr.h 106.Ft int 107.Fn VOP_LOOKUP "struct vnode *dvp" "struct vnode **vpp" \ 108"struct componentname *cnp" 109.Ft int 110.Fn VOP_CREATE "struct vnode *dvp" "struct vnode **vpp" \ 111"struct componentname *cnp" "struct vattr *vap" 112.Ft int 113.Fn VOP_MKNOD "struct vnode *dvp" "struct vnode **vpp" \ 114"struct componentname *cnp" "struct vattr *vap" 115.Ft int 116.Fn VOP_OPEN "struct vnode *vp" "int mode" "struct ucred *cred" \ 117"struct proc *p" 118.Ft int 119.Fn VOP_CLOSE "struct vnode *vp" "int fflag" "struct ucred *cred" \ 120"struct proc *p" 121.Ft int 122.Fn VOP_ACCESS "struct vnode *vp" "int mode" "struct ucred *cred" \ 123"struct proc *p" 124.Ft int 125.Fn VOP_GETATTR "struct vnode *vp" "struct vattr *vap" \ 126"struct ucred *cred" "struct proc *p" 127.Ft int 128.Fn VOP_SETATTR "struct vnode *vp" "struct vattr *vap" \ 129"struct ucred *cred" "struct proc *p" 130.Ft int 131.Fn VOP_READ "struct vnode *vp" "struct uio *uio" "int ioflag" \ 132"struct ucred *cred" 133.Ft int 134.Fn VOP_WRITE "struct vnode *vp" "struct uio *uio" "int ioflag" \ 135"struct ucred *cred" 136.Ft int 137.Fn VOP_IOCTL "struct vnode *vp" "u_long command" "void *data" \ 138"int fflag" "struct ucred *cred" "struct proc *p" 139.Ft int 140.Fn VOP_FCNTL "struct vnode *vp" "u_int command" "void *data" \ 141"int fflag" "struct ucred *cred" "struct proc *p" 142.Ft int 143.Fn VOP_POLL "struct vnode *vp" "int events" "struct proc *p" 144.Ft int 145.Fn VOP_REVOKE "struct vnode *vp" "int flags" 146.Ft int 147.Fn VOP_MMAP "struct vnode *vp" "int fflags" \ 148"struct ucred *cred" "struct proc *p" 149.Ft int 150.Fn VOP_FSYNC "struct vnode *vp" "struct ucred *cred" "int flags" \ 151"off_t offlo" "off_t offhi" "struct proc *p" 152.Ft int 153.Fn VOP_SEEK "struct vnode *vp" "off_t oldoff" "off_t newoff" \ 154"struct ucred *cred" 155.Ft int 156.Fn VOP_REMOVE "struct vnode *vp" "struct vnode *vp" \ 157"struct componentname *cnp" 158.Ft int 159.Fn VOP_LINK "struct vnode *dvp" "struct vnode *vp" \ 160"struct componentname *cnp" 161.Ft int 162.Fn VOP_RENAME "struct vnode *fdvp" "struct vnode *vp" \ 163"struct componentname *fcnp" "struct componentname *tdvp" \ 164"struct vnode *tvp" "struct componentname *tcnp" 165.Ft int 166.Fn VOP_MKDIR "struct vnode *vp" "struct vnode **vpp" \ 167"struct componentname *cnp" "struct vattr *vap" 168.Ft int 169.Fn VOP_RMDIR "struct vnode *vp" "struct vnode *vp" \ 170"struct componentname *cnp" 171.Ft int 172.Fn VOP_SYMLINK "struct vnode *dvp" "struct vnode **vpp" \ 173"struct componentname *cnp" "struct vattr *vap" "char *target" 174.Ft int 175.Fn VOP_READDIR "struct vnode *vp" "struct uio *uio" \ 176"struct ucred *cred" "int *eofflag" "cookies" "ncookies" 177.Ft int 178.Fn VOP_READLINK "struct vnode *vp" "struct uio *uio" "struct ucred *cred" 179.Ft int 180.Fn VOP_ABORTOP "struct vnode *dvp" "struct componentname *cnp" 181.Ft int 182.Fn VOP_INACTIVE "struct vnode *vp" "struct proc *p" 183.Ft int 184.Fn VOP_RECLAIM "struct vnode *vp" "struct proc *p" 185.Ft int 186.Fn VOP_LOCK "struct vnode *vp" "int flags" 187.Ft int 188.Fn VOP_UNLOCK "struct vnode *vp" "int flags" 189.Ft int 190.Fn VOP_ISLOCKED "struct vnode *vp" 191.Ft int 192.Fn VOP_BMAP "struct vnode *vp" "daddr_t bn" "struct vnode **vpp" \ 193"daddr_t *bnp" "int *runp" 194.Ft int 195.Fn VOP_PRINT "struct vnode *vp" 196.Ft int 197.Fn VOP_PATHCONF "struct vnode *vp" "int name" "register_t *retval" 198.Ft int 199.Fn VOP_ADVLOCK "struct vnode *vp" "void *id" "int op" \ 200"struct flock *fl" "int flags" 201.Ft int 202.Fn VOP_BLKATOFF "struct vnode *vp" "off_t offset" "char **res" \ 203"struct buf **bpp" 204.Ft int 205.Fn VOP_VALLOC "struct vnode *pvp" "int mode" "struct ucred *cred" \ 206"struct vnode **vpp" 207.Ft int 208.Fn VOP_BALLOC "struct vnode *vp" "off_t startoffset" "int size" \ 209"struct ucred *cred" "int flags" "struct buf **bpp" 210.Ft int 211.Fn VOP_REALLOCBLKS "struct vnode *vp" "struct cluster_save *buflist" 212.Ft int 213.Fn VOP_VFREE "struct vnode *pvp" "ino_t ino" "int mode" 214.Ft int 215.Fn VOP_TRUNCATE "struct vnode *vp" "off_t length" "int flags" \ 216"struct ucred *cred" "struct proc *p" 217.Ft int 218.Fn VOP_UPDATE "struct vnode *vp" "struct timespec *access" \ 219"struct timespec *modify" "int flags" 220.Ft int 221.Fn VOP_LEASE "struct vnode *vp" "struct proc *p" "struct ucred *cred" \ 222"int flag" 223.Ft int 224.Fn VOP_WHITEOUT "struct vnode *dvp" "struct componentname *cnp" \ 225"int flags" 226.Ft int 227.Fn VOP_GETPAGES "struct vnode *vp" "voff_t offset" "struct vm_page **m" \ 228"int *count" "int centeridx" "vm_prot_t access_type" "int advice" "int flags" 229.Ft int 230.Fn VOP_PUTPAGES "struct vnode *vp" "voff_t offlo" "voff_t offlo" \ 231"int flags" 232.Ft int 233.Fn VOP_STRATEGY "struct vnode *vp" "struct buf *bp" 234.Ft int 235.Fn VOP_BWRITE "struct buf *bp" 236.Ft int 237.Fn VOP_GETEXTATTR "struct vnode *vp" "int attrnamespace" "const char *name" \ 238"struct uio *uio" "size_t *size" "struct ucred *cred" "struct proc *p" 239.Ft int 240.Fn VOP_SETEXTATTR "struct vnode *vp" "int attrnamespace" "const char *name" \ 241"struct uio *uio" "struct ucred *cred" "struct proc *p" 242.Ft int 243.Fn VOP_LISTEXTATTR "struct vnode *vp" "int attrnamespace" "struct uio *uio" \ 244"size_t *size" "struct ucred *cred" "struct proc *p" 245.Pp 246Not all header files are required for each function. 247.Sh DESCRIPTION 248The vnode operations vector describes what operations can be done to 249the file associated with the vnode. 250The system maintains one vnode operations vector for each file system 251type configured into the kernel. 252The vnode operations vector contains a pointer to a function for each 253operation supported by the file system. 254Many of the functions described in the vnode operations vector are 255closely related to their corresponding system calls. 256In most cases, they are called as a result of the system call 257associated with the operation being invoked. 258.Pp 259Functions in the vnode operations vector are invoked using specialised 260macros. 261The following table lists the elements of the vnode operations vector, 262the corresponding invocation macro, and a description of the element. 263.Pp 264.nf 265.ta \w'int (*vop_reallocblks)()'u+2n +\w'VOP_REALLOCBLKS'u+2n +\w'Map file into user address space'u 266\fIVector element\fP \fIMacro\fP \fIDescription\fP 267.ta \w'int (*vop_reallocblks)()'u+2n +\w'VOP_REALLOCBLKS'u+2n +\w'Map file into user address space'u+6nC 268.sp 5p 269int (*vop_lookup)() VOP_LOOKUP Lookup file name in name cache 270int (*vop_create)() VOP_CREATE Create a new file 271int (*vop_mknod)() VOP_MKNOD Make a new device 272int (*vop_open)() VOP_OPEN Open a file 273int (*vop_close)() VOP_CLOSE Close a file 274int (*vop_access)() VOP_ACCESS Determine file accessibility 275int (*vop_getattr)() VOP_GETATTR Get file attributes 276int (*vop_setattr)() VOP_SETATTR Set file attributes 277int (*vop_read)() VOP_READ Read from a file 278int (*vop_write)() VOP_WRITE Write to a file 279int (*vop_ioctl)() VOP_IOCTL Perform device-specific I/O 280int (*vop_fcntl)() VOP_FCNTL Perform file control 281int (*vop_poll)() VOP_POLL Test if poll event has occurred 282int (*vop_revoke)() VOP_REVOKE Eliminate vode activity 283int (*vop_mmap)() VOP_MMAP Map file into user address space 284int (*vop_fsync)() VOP_FSYNC Flush pending data to disk 285int (*vop_seek)() VOP_SEEK Test if file is seekable 286int (*vop_remove)() VOP_REMOVE Remove a file 287int (*vop_link)() VOP_LINK Link a file 288int (*vop_rename)() VOP_RENAME Rename a file 289int (*vop_mkdir)() VOP_MKDIR Make a new directory 290int (*vop_rmdir)() VOP_RMDIR Remove a directory 291int (*vop_symlink)() VOP_SYMLINK Create a symbolic link 292int (*vop_readdir)() VOP_READDIR Read directory entry 293int (*vop_readlink)() VOP_READLINK Read contents of a symlink 294int (*vop_abortop)() VOP_ABORTOP Abort pending operation 295int (*vop_inactive)() VOP_INACTIVE Release the inactive vnode 296int (*vop_reclaim)() VOP_RECLAIM Reclaim vnode for another file 297int (*vop_lock)() VOP_LOCK Sleep until vnode lock is free 298int (*vop_unlock)() VOP_UNLOCK Wake up process sleeping on lock 299int (*vop_islocked)() VOP_ISLOCKED Test if vnode is locked 300int (*vop_bmap)() VOP_BMAP Logical block number conversion 301int (*vop_print)() VOP_PRINT Print debugging information 302int (*vop_pathconf)() VOP_PATHCONF Return POSIX pathconf data 303int (*vop_advlock)() VOP_ADVLOCK Advisory record locking 304int (*vop_blkatoff)() VOP_BLKATOFF Retrieve buffer from offset 305int (*vop_valloc)() VOP_VALLOC Allocate fs-specific data 306int (*vop_balloc)() VOP_BALLOC Allocate physical blocks 307int (*vop_reallocblks)() VOP_REALLOCBLKS Rearrange blocks contiguously 308int (*vop_vfree)() VOP_VFREE Release file resources 309int (*vop_truncate)() VOP_TRUNCATE Truncate file and free blocks 310int (*vop_update)() VOP_UPDATE Update time on a file 311int (*vop_lease)() VOP_LEASE Validate vnode credentials 312int (*vop_whiteout)() VOP_WHITEOUT Whiteout vnode 313int (*vop_getpages)() VOP_GETPAGES Read VM pages from file 314int (*vop_putpages)() VOP_PUTPAGES Write VM pages to file 315int (*vop_strategy)() VOP_STRATEGY Read/write a file system buffer 316int (*vop_bwrite)() VOP_BWRITE Write a file system buffer 317int (*vop_getextattr)() VOP_GETEXTATTR Get extended attribute 318int (*vop_setextattr)() VOP_SETEXTATTR Set extended attribute 319int (*vop_listextattr)() VOP_LISTEXTATTR List extended attributes 320.fi 321.Pp 322The implementation details of the vnode operations vector are not 323quite what is described here. 324.Pp 325If the file system type does not support a specific operation, it must 326nevertheless assign an appropriate function in the vnode operations 327vector to do the minimum required of it. 328In most cases, such functions either do nothing or return an error 329value to the effect that it is not supported. 330.Pp 331Many of the functions in the vnode operations vector take a 332componentname structure. 333Is is used to encapsulate many parameters into a single function 334argument. 335It has the following structure: 336.Bd -literal 337struct componentname { 338 /* 339 * Arguments to lookup. 340 */ 341 u_long cn_nameiop; /* namei operation */ 342 u_long cn_flags; /* flags to namei */ 343 struct proc *cn_proc; /* process requesting lookup */ 344 struct ucred *cn_cred; /* credentials */ 345 /* 346 * Shared between lookup and commit routines. 347 */ 348 char *cn_pnbuf; /* pathname buffer */ 349 const char *cn_nameptr; /* pointer to looked up name */ 350 long cn_namelen; /* length of looked up component */ 351 u_long cn_hash; /* hash value of looked up name */ 352 long cn_consume; /* chars to consume in lookup() */ 353}; 354.Ed 355.Pp 356The top half of the structure is used exclusively for the pathname 357lookups using 358.Fn VOP_LOOKUP 359and is initialised by the caller. 360The semantics of the lookup are affected by the lookup operation 361specified in 362.Em cn_nameiop 363and the flags specified in 364.Em cn_flags . 365Valid operations are: 366.Pp 367.Bl -tag -offset indent -width LOOKUP -compact 368.It LOOKUP 369perform name lookup only 370.It CREATE 371set up for file creation 372.It DELETE 373set up for file deletion 374.It RENAME 375set up for file renaming 376.It OPMASK 377mask for operation 378.El 379.Pp 380Valid values for 381.Em cn-\*[Gt]cn_flags 382are: 383.Pp 384.Bl -tag -offset indent -width LOCKPARENT -compact 385.It LOCKLEAF 386lock inode on return 387.It LOCKPARENT 388want parent vnode returned locked 389.It WANTPARENT 390want parent vnode returned unlocked 391.It NOCACHE 392name must not be left in name cache (see 393.Xr namecache 9 ) 394.It FOLLOW 395follow symbolic links 396.It NOFOLLOW 397do not follow symbolic links (pseudo) 398.It MODMASK 399mask of operational modifiers 400.El 401.Pp 402No vnode operations may be called from interrupt context. 403Most operations also require the vnode to be locked on entry. 404To prevent deadlocks, when acquiring locks on multiple vnodes, the 405lock of parent directory must be acquired before the lock on the child 406directory. 407.Pp 408Vnode operations for a file system type generally should not be 409called directly from the kernel, but accessed indirectly through the 410high-level convenience functions discussed in 411.Xr vnsubr 9 . 412.Sh FUNCTIONS 413.Bl -tag -width compact 414.It Fn VOP_LOOKUP "dvp" "vpp" "cnp" 415Lookup a single pathname component in a given directory. 416The argument 417.Fa dvp 418is the locked vnode of the directory to search and 419.Fa cnp 420is the pathname component to be searched for. 421If the pathname component is found, the address of the resulting 422locked vnode is returned in 423.Fa vpp . 424The operation specified in 425.Em cnp-\*[Gt]cn_nameiop 426gives 427.Fn VOP_LOOKUP 428hints about the reason for requesting the lookup and uses it to cache 429file system type specific information in the vnode for subsequent 430operations. 431.Pp 432There are three types of lookups: ".", ".." (ISDOTDOT), and other. 433If the pathname component being searched for is ".", then 434.Fa dvp 435has an extra reference added to it and it is returned in 436.Fa *vpp . 437If the pathname component being search for is ".." (ISDOTDOT), 438.Fa dvp 439is unlocked, the ".." node is locked and then 440.Fa dvp 441is relocked if and only if LOCKPARENT and ISLASTCN is set in 442.Em cnp-\*[Gt]cn_flags . 443If LOCKPARENT or ISLASTCN is not set, 444.Fa dvp 445is returned unlocked on a successful lookup. 446This process preserves the protocol of always locking nodes from root 447downward and prevents deadlock. 448For other pathname components, 449.Fn VOP_LOOKUP 450checks the accessibility of the directory and searches the name cache 451for the pathname component. 452See 453.Xr namecache 9 . 454If the pathname is not found in the name cache, the directory is 455searched for the pathname. 456The resulting locked vnode is returned in 457.Fa vpp . 458If LOCKPARENT or ISLASTCN is not set, 459.Fa dvp 460is returned unlocked on a successful lookup. 461.Pp 462On failure 463.Fa *vpp 464is 465.Dv NULL , 466and 467.Fa *dvp 468is left locked. 469If there was an error relocking 470.Fa dvp 471(for instance in the ISDOTDOT case) the error is returned with 472PDIRUNLOCK set in 473.Em cnp-\*[Gt]cn_flags . 474This flag signals to the caller that 475.Fa dvp ' s 476lock state has changed. 477If the operation is successful 478.Fa *vpp 479is locked and zero is returned. 480Typically, if 481.Fa *vpp 482and 483.Fa dvp 484are the same vnode the caller will need to release twice (decrement 485the reference count) and unlock once. 486.It Fn VOP_CREATE "dvp" "vpp" "cnp" "vap" 487Create a new file in a given directory. 488The argument 489.Fa dvp 490is the locked vnode of the directory to create the new file in and 491.Fa cnp 492is the pathname component of the new file. 493The argument 494.Fa vap 495specifies the attributes that the new file should be created with. 496If the file is successfully created, the address of the resulting 497locked vnode is returned in 498.Fa vpp 499and zero is returned. 500.Pp 501This function is called after 502.Fn VOP_LOOKUP 503when a file is being created. 504Normally, 505.Fn VOP_LOOKUP 506will have set the SAVENAME flag in 507.Em cnp-\*[Gt]cn_flags 508to keep the memory pointed to by 509.Em cnp-\*[Gt]cn_pnbuf 510valid. 511If an error is detected when creating the file, this memory is 512released. 513If the file is created successfully it will be released unless the 514SAVESTART flags in specified in 515.Em cnp-\*[Gt]cn_flags . 516.It Fn VOP_MKNOD "dvp" "vpp" "cnp" "vap" 517Make a new device-special file in a given directory. 518The argument 519.Fa dvp 520is the locked vnode of the directory to create the new device-special 521file in and 522.Fa cnp 523is the pathname component of the new device-special file. 524The argument 525.Fa vap 526specifies the attributes that the new device-special file should be 527created with. 528If the file is successfully created, the address of the resulting 529locked vnode is returned in 530.Fa vpp 531and zero is returned. 532.Pp 533This function is called after 534.Fn VOP_LOOKUP 535when a device-special file is being created. 536Normally, 537.Fn VOP_LOOKUP 538will have set the SAVENAME flag in 539.Em cnp-\*[Gt]cn_flags 540to keep the memory pointed to by 541.Em cnp-\*[Gt]cn_pnbuf 542valid. 543If an error is detected when creating the device-special file, 544this memory is released. 545If the device-special file is created successfully it will be released 546unless the SAVESTART flags in specified in 547.Em cnp-\*[Gt]cn_flags . 548.It Fn VOP_OPEN "vp" "mode" "cred" "p" 549Open a file. 550The argument 551.Fa vp 552is the vnode of the file to open and 553.Fa mode 554specifies the access mode required by the calling process. 555The calling process and its credentials are specified by 556.Fa p 557and 558.Fa cred 559respectively. 560The access mode is a set of flags, including FREAD, FWRITE, 561O_NONBLOCK, O_APPEND, etc. 562.Fn VOP_OPEN 563must be called before a file can be accessed by a thread. 564The vnode reference count is incremented. 565.Pp 566.Fn VOP_OPEN 567expects the vnode 568.Fa vp 569to be locked on entry and will leave it locked on return. 570If the operation is successful zero is returned, otherwise an 571appropriate error code is returned. 572.It Fn VOP_CLOSE "vp" "fflag" "cred" "p" 573Close a file. 574The argument 575.Fa vp 576is the vnode of the file to close and 577.Fa fflags 578specifies the access mode by the calling process. 579The calling process and its credentials are specified by 580.Fa p 581and 582.Fa cred 583respectively. 584.Fn VOP_CLOSE 585must be called after a file is finished with. 586.Pp 587.Fn VOP_CLOSE 588expects at least a reference to be associated with the vnode and does 589not care whether the vnode is locked. 590The lock and reference state is left unchanged on return. 591.It Fn VOP_ACCESS "vp" "mode" "cred" "p" 592Determine the accessibility (permissions) of the file against the 593specified credentials. 594The argument 595.Fa vp 596is the vnode of the file to check, 597.Fa mode 598is the type of access required, 599.Fa cred 600contains the user credentials to check and 601.Fa p 602is the process which is checking the credentials. 603The argument 604.Fa mode 605is a mask which can contain VREAD, VWRITE or VEXEC. 606If the file is accessible in the specified way, zero is returned, 607otherwise an appropriate error code is returned. 608.Pp 609The vnode 610.Fa vp 611will be locked on entry and should remain locked on return. 612.It Fn VOP_GETATTR "vp" "vap" "cred" "p" 613Get specific vnode attributes on a file. 614The argument 615.Fa vp 616is the locked vnode of the file to get the attributes for. 617The arguments 618.Fa p 619and 620.Fa cred 621specifies the calling process and its credentials respectively. 622.Fn VOP_GETATTR 623uses the file system type specific data object 624.Em vp-\*[Gt]v_data 625to reference the underlying file attributes. 626Attributes associated with the file are collected by setting the 627required attribute bits in 628.Em vap-\*[Gt]va_mask . 629The attributes are returned in 630.Fa vap . 631Attributes which are not available are set to the value VNOVAL. 632.Pp 633For more information on vnode attributes see 634.Xr vattr 9 . 635.It Fn VOP_SETATTR "vp" "vap" "cred" "p" 636Set specific vnode attributes on a file. 637The argument 638.Fa vp 639is the locked vnode of the file to set the attributes for. 640The arguments 641.Fa p 642and 643.Fa cred 644specifies the calling process and its credentials respectively. 645.Fn VOP_SETATTR 646uses the file system type specific data object 647.Em vp-\*[Gt]v_data 648to reference the underlying file attributes. 649The new attributes are defined in 650.Fa vap . 651Attributes associated with the file are set by setting the required 652attribute bits in 653.Em vap-\*[Gt]va_mask . 654Attributes which are not being modified by 655.Fn VOP_SETATTR 656should be set to the value VNOVAL. 657If the operation is successful zero is returned, otherwise an 658appropriate error is returned. 659.Pp 660For more information on vnode attributes see 661.Xr vattr 9 . 662.It Fn VOP_READ "vp" "uio" "ioflag" "cred" 663Read the contents of a file. 664The argument 665.Fa vp 666is the vnode of the file to read from, 667.Fa uio 668is the location to read the data into, 669.Fa ioflag 670is a set of flags and 671.Fa cred 672are the credentials of the calling process. 673.Pp 674The 675.Fa ioflag 676argument is used to give directives and hints to the file system. 677When attempting a read, the high 16 bits are used to provide a 678read-ahead hint (in unit of file system blocks) that the file system 679should attempt. 680The low 16 bits are a bit mask which can contain the following flags: 681.Pp 682.Bl -tag -offset indent -width IO_NODELOCKED -compact 683.It IO_UNIT 684do I/O as atomic unit 685.It IO_APPEND 686append write to end 687.It IO_SYNC 688do I/O synchronously 689.It IO_NODELOCKED 690underlying node already locked 691.It IO_NDELAY 692FNDELAY flag set in file table 693.It IO_VMIO 694data already in VMIO space 695.El 696.Pp 697Zero is returned on success, otherwise an error is returned. 698The vnode should be locked on entry and remains locked on exit. 699.It Fn VOP_WRITE "vp" "uio" "ioflag" "cred" 700Write to a file. 701The argument 702.Fa vp 703is the vnode of the file to write to, 704.Fa uio 705is the location of the data to write, 706.Fa ioflag 707is a set of flags and 708.Fa cred 709are the credentials of the calling process. 710.Pp 711The 712.Fa ioflag 713argument is used to give directives and hints to the file system. 714The low 16 bits are a bit mask which can contain the same flags as 715.Fn VOP_READ . 716.Pp 717Zero is returned on success, otherwise an error is returned. 718The vnode should be locked on entry and remains locked on exit. 719.It Fn VOP_IOCTL "vp" "command" "data" "fflag" "cred" "p" 720Perform device-specific I/O. 721The argument 722.Fa vp 723is the locked vnode of the file, normally representing a device. 724The argument 725.Fa command 726specifies the device-specific operation to perform and 727.Fa cnp 728provides extra data for the specified operation. 729The argument 730.Fa fflags 731is a set of flags. 732The argument 733.Fa cred 734is the caller's credentials and 735.Fa p 736the calling process. 737If the operation is successful, zero is 738returned, otherwise an appropriate error code is returned. 739.Pp 740Most file systems do not supply a function for 741.Fn VOP_IOCTL . 742This function implements the 743.Xr ioctl 2 744system call. 745.It Fn VOP_FCNTL "vp" "command" "data" "fflag" "cred" "p" 746Perform file control. 747The argument 748.Fa vp 749is the locked vnode of the file. 750The argument 751.Fa command 752specifies the operation to perform and 753.Fa cnp 754provides extra data for the specified operation. 755The argument 756.Fa fflags 757is a set of flags. 758The argument 759.Fa cred 760is the caller's credentials and 761.Fa p 762the calling process. 763If the operation is successful, zero is returned, otherwise an 764appropriate error code is returned. 765.It Fn VOP_POLL "vp" "events" "p" 766Test if a poll event has occurred. 767The argument 768.Fa vp 769is the locked vnode of the file to poll and 770.Fa p 771is the calling process. 772It returns any events of interest as specified by 773.Fa events 774that may have occurred for the file. 775The argument 776.Fa events 777is a set of flags as specified by 778.Xr poll 2 . 779If the operation is successful zero is returned, otherwise an 780appropriate error code is returned. 781.It Fn VOP_REVOKE "vp" "flags" 782Eliminate all activity associated with the vnode 783.Fa vp . 784The argument 785.Fa flags 786is a set of flags. 787If REVOKEALL is set in 788.Fa flags 789all vnodes aliased to the vnode 790.Fa vp 791are also eliminated. 792If the operation is successful zero is returned, otherwise an 793appropriate error is returned. 794.It Fn VOP_MMAP "vp" "fflags" "cred" "p" 795Map file into user address space. 796The argument 797.Fa vp 798is the locked vnode of the file to map into an address space. 799The argument 800.Fa fflags 801is a set of flags. 802The argument 803.Fa cred 804is the caller's credentials and 805.Fa p 806the calling process requesting the map. 807If the operation is successful, zero is returned, otherwise an 808appropriate error code is returned. 809.Pp 810Most file systems do not supply a function for 811.Fn VOP_MMAP . 812This function implements the 813.Xr mmap 2 814system call. 815.It Fn VOP_FSYNC "vp" "cred" "flags" "offlo" "offhi" "p" 816Flush pending data buffers for a file to disk. 817The argument 818.Fa vp 819is the locked vnode of the file for flush. 820The argument 821.Fa cred 822is the caller's credentials and 823.Fa p 824the calling process. 825The argument 826.Fa flags 827is a set of flags. 828If FSYNC_WAIT is specified in 829.Fa flags , 830the function should wait for I/O to complete before returning. 831The argument 832.Fa offlo 833and 834.Fa offhi 835specify the range of file to flush. 836If the operation is successful zero is returned, otherwise an 837appropriate error code is returned. 838.Pp 839This function implements the 840.Xr sync 2 841and 842.Xr fsync 2 843system calls. 844.It Fn VOP_SEEK "vp" "oldoff" "newoff" "cred" 845Test if the file is seekable for the specified offset 846.Fa newoff . 847The argument 848.Fa vp 849is the locked vnode of the file to test. 850For most filesystems this function simply tests if 851.Fa newoff 852is valid. 853If the specified 854.Fa newoff 855is less than zero, the function returns error code EINVAL. 856.It Fn VOP_REMOVE "dvp" "vp" "cnp" 857Remove a file. 858The argument 859.Fa dvp 860is the locked vnode of the directory to remove the file from and 861.Fa vp 862is the locked vnode of the file to remove. 863The argument 864.Fa cnp 865is the pathname component about the file to remove. 866If the operation is successful zero is returned, otherwise an 867appropriate error code is returned. 868Both 869.Fa dvp 870and 871.Fa vp 872should be locked on entry and remain locked on return. 873.It Fn VOP_LINK "dvp" "vp" "cnp" 874Link to a file. 875The argument 876.Fa dvp 877is the locked node of the directory to create the new link and 878.Fa vp 879is the vnode of the file to be linked. 880The argument 881.Fa cnp 882is the pathname component of the new link. 883If the operation is successful zero is returned, otherwise an error 884code is returned. 885The directory vnode 886.Fa dvp 887should be locked on entry and will remain locked on return. 888The vnode 889.Fa vp 890should not be locked on entry and will remain unlocked on return. 891.It Fn VOP_RENAME "fdvp" "fvp" "fcnp" "tdvp" "tvp" "tcnp" 892Rename a file. 893The argument 894.Fa fdvp 895is the vnode of the old parent directory containing in the file to be 896renamed and 897.Fa fvp 898is the vnode of the file to be renamed. 899The argument 900.Fa fcnp 901is the pathname component about the file to be remained. 902The argument 903.Fa tdvp 904is the vnode of the new directory of the target file and 905.Fa tvp 906is the vnode of the target file (if it exists). 907The argument 908.Fa tcnp 909is the pathname component about the file's new name. 910If the operation is successful zero is returned, otherwise and error 911code is returned. 912.Pp 913The source directory and file vnodes should be unlocked and their 914reference counts should be incremented before entry. 915The target directory and file vnodes should both be locked on entry. 916.Fn VOP_RENAME 917updates the reference counts prior to returning. 918.It Fn VOP_MKDIR "dvp" "vpp" "cnp" "vap" 919Make a new directory in a given directory. 920The argument 921.Fa dvp 922is the locked vnode of the directory to create the new directory in and 923.Fa cnp 924is the pathname component of the new directory. 925The argument 926.Fa vap 927specifies the attributes that the new directory should be created 928with. 929If the file is successfully created, the address of the resulting 930locked vnode is returned in 931.Fa vpp 932and zero is returned. 933.Pp 934This function is called after 935.Fn VOP_LOOKUP 936when a directory is being created. 937Normally, 938.Fn VOP_LOOKUP 939will have set the SAVENAME flag in 940.Em cnp-\*[Gt]cn_flags 941to keep the memory pointed to by 942.Em cnp-\*[Gt]cn_pnbuf 943valid. 944If an error is detected when creating the directory, this memory is 945released. 946If the directory is created successfully it will be released unless 947the SAVESTART flags in specified in 948.Em cnp-\*[Gt]cn_flags . 949.It Fn VOP_RMDIR "dvp" "vp" "cnp" 950Remove a directory in a given directory. 951The argument 952.Fa dvp 953is the locked vnode of the directory to remove the directory from and 954.Fa vp 955is the locked vnode of the directory to remove. 956The argument 957.Fa cnp 958is the pathname component of the directory. 959Zero is returned on success, otherwise an error code is returned. 960Both 961.Fa dvp 962and 963.Fa vp 964should be locked on entry and remain locked on return. 965.It Fn VOP_SYMLINK "dvp" "vpp" "cnp" "vap" "target" 966Create a symbolic link in a given directory. 967The argument 968.Fa dvp 969is the locked vnode of the directory to create the symbolic link in 970and 971.Fa cnp 972is the pathname component of the symbolic link. 973The argument 974.Fa vap 975specifies the attributes that the symbolic link should be created 976with and 977.Fa target 978specifies the pathname of the target of the symbolic link. 979If the symbolic link is successfully created, the address of the 980resulting locked vnode is returned in 981.Fa vpp 982and zero is returned. 983.Pp 984This function is called after 985.Fn VOP_LOOKUP 986when a symbolic link is being created. 987Normally, 988.Fn VOP_LOOKUP 989will have set the SAVENAME flag in 990.Em cnp-\*[Gt]cn_flags 991to keep the memory pointed to by 992.Em cnp-\*[Gt]cn_pnbuf 993valid. 994If an error is detected when creating the symbolic link, this memory 995is released. 996If the symbolic link is created successfully it will be released 997unless the SAVESTART flags in specified in 998.Em cnp-\*[Gt]cn_flags . 999.It Fn VOP_READDIR "vp" "uio" "cred" "eofflag" "cookies" "ncookies" 1000Read directory entry. 1001The argument 1002.Fa vp 1003is the vnode of the directory to read the contents of and 1004.Fa uio 1005is the destination location to read the contents into. 1006The argument 1007.Fa cred 1008is the caller's credentials. 1009The argument 1010.Fa eofflag 1011is the pointer to a flag which is set by 1012.Fn VOP_READDIR 1013to indicate and end-of-file condition. 1014If 1015.Fa eofflag 1016is 1017.Dv NULL , 1018the end-of-file condition is not returned. 1019The arguments 1020.Fa cookies 1021and 1022.Fa ncookies 1023specify the addresses for the list and number of directory seek 1024cookies generated for NFS. 1025Both 1026.Fa cookies 1027and 1028.Fa ncookies 1029should be 1030.Dv NULL 1031if they aren't required to be returned by 1032.Fn VOP_READDIR . 1033The directory contents are read into struct dirent structures. 1034If the operation is successful zero is returned, otherwise an 1035appropriate error code is returned. 1036.Pp 1037The directory should be locked on entry and will remain locked on 1038return. 1039.Pp 1040If 1041.Fn VOP_READDIR 1042is called from the NFS server, the extra arguments 1043.Fa eofflag , 1044.Fa ncookies 1045and 1046.Fa cookies 1047are used. 1048The value of 1049.Fa *eofflag 1050will be set to TRUE if the end of the directory is reached while 1051reading. 1052The directory seek cookies are returned to the NFS client and may be 1053used later to restart a directory read part way through the directory. 1054There should be one cookie returned per directory entry. 1055The value of the cookie should be the offset within the directory 1056where the on-disk version of the appropriate directory entry starts. 1057.It Fn VOP_READLINK "vp" "uio" "cred" 1058Read the contents of a symbolic link. 1059The argument 1060.Fa vp 1061is the locked vnode of the symlink and 1062.Fa uio 1063is the destination location to read the contents into. 1064The argument 1065.Fa cred 1066is the credentials of the caller. 1067If the operation is successful zero is returned, otherwise an error 1068code is returned. 1069.Pp 1070The vnode should be locked on entry and will remain locked on return. 1071.It Fn VOP_ABORTOP "dvp" "cnp" 1072Abort pending operation on vnode 1073.Fa dvp . 1074This operation is rarely implemented in file systems. 1075.It Fn VOP_INACTIVE "vp" "p" 1076Release the inactive vnode. 1077.Fn VOP_INACTIVE 1078is called when the kernel is no longer using the vnode. 1079This may be because the reference count reaches zero or it may be that 1080the file system is being forcibly unmounted while there are open 1081files. 1082It can be used to reclaim space for open but deleted files. 1083The argument 1084.Fa vp 1085is the locked vnode to be released. 1086The argument 1087.Fa p 1088is the calling process. 1089If the operation is successful zero is returned, otherwise an 1090appropriate error code is returned. 1091The vnode 1092.Fa vp 1093must be locked on entry, and will be unlocked on return. 1094.It Fn VOP_RECLAIM "vp" "p" 1095Reclaim the vnode for another file system. 1096.Fn VOP_RECLAIM 1097is called when a vnode is being reused for a different file system. 1098Any file system specific resources associated with the vnode should be 1099freed. 1100The argument 1101.Fa vp 1102is the locked vnode to be reclaimed. 1103The argument 1104.Fa p 1105is the calling process. 1106If the operation is successful zero is returned, otherwise an 1107appropriate error code is returned. 1108The vnode 1109.Fa vp 1110should not be locked on entry, and will remain unlocked on return. 1111.It Fn VOP_LOCK "vp" "flags" 1112Sleep until vnode lock is free. 1113The argument 1114.Fa vp 1115is the vnode of the file to be locked. 1116The argument 1117.Fa flags 1118is a set of 1119.Xr lockmgr 9 1120flags. 1121If the operation is successful zero is returned, otherwise an 1122appropriate error code is returned. 1123.Fn VOP_LOCK 1124is used to serialise access to the file system such as to present two 1125writes to the same file from happening at the same time. 1126Kernel code should use 1127.Xr vn_lock 9 1128to lock a vnode rather than calling 1129.Fn VOP_LOCK 1130directly. 1131.It Fn VOP_UNLOCK "vp" "flags" 1132Wake up process sleeping on lock. 1133The argument 1134.Fa vp 1135is the vnode of the file to be unlocked. 1136The argument 1137.Fa flags 1138is a set of 1139.Xr lockmgr 9 1140flags. 1141If the operation is successful zero is returned, otherwise an 1142appropriate error code is returned. 1143.Fn VOP_UNLOCK 1144is used to serialise access to the file system such as to present two 1145writes to the same file from happening at the same time. 1146.It Fn VOP_ISLOCKED "vp" 1147Test if the vnode 1148.Fa vp 1149is locked. 1150A non-zero values is returned if the vnode is not locked, otherwise 1151zero is returned. 1152.It Fn VOP_BMAP "vp" "bn" "vpp" "bnp" "runp" 1153Convert the logical block number 1154.Fa bn 1155of a file specified by vnode 1156.Fa vp 1157to its physical block number on the disk. 1158If 1159.Fa vpp 1160is not 1161.Dv NULL , 1162the vnode of the device vnode for the file system is 1163returned in the address specified by 1164.Fa vpp . 1165If 1166.Fa runp 1167is not 1168.Dv NULL , 1169the maximum blocksize is returned in the address specified by 1170.Fa runp . 1171.It Fn VOP_PRINT "vp" 1172Print debugging information. 1173The argument 1174.Fa vp 1175is the vnode to print. 1176If the operation is successful zero is returned, otherwise an 1177appropriate error code is returned. 1178.It Fn VOP_PATHCONF "vp" "name" "retval" 1179Implement POSIX 1180.Xr pathconf 2 1181and 1182.Xr fpathconf 2 1183support. 1184The argument 1185.Fa vp 1186is the locked vnode to get information about. 1187The argument 1188.Fa name 1189specified the type of information to return. 1190The information is returned in the address specified by 1191.Fa retval . 1192Valid values for 1193.Fa name 1194are: 1195.Pp 1196.Bl -tag -offset indent -width _PC_CHOWN_RESTRICTED -compact 1197.It _PC_LINK_MAX 1198return the maximum number of links to a file 1199.It _PC_NAME_MAX 1200return the maximum number of bytes in a file name 1201.It _PC_PATH_MAX 1202return the maximum number of bytes in a pathname 1203.It _PC_PIPE_BUF 1204return the maximum number of bytes which will be written atomically to 1205a pipe 1206.It _PC_CHOWN_RESTRICTED 1207return 1 if appropriate privileges are required for the 1208.Xr chown 2 1209system call, otherwise zero 1210.It _PC_NO_TRUNC 1211return if file names longer than KERN_NAME_MAX are truncated 1212.El 1213.Pp 1214If 1215.Fa name 1216is recognised, 1217.Fa *retval 1218is set to the specified value and zero is returned, otherwise an 1219appropriate error is returned. 1220.It Fn VOP_ADVLOCK "vp" "id" "op" "fl" "flags" 1221Manipulate Advisory record locks on a file. 1222The argument 1223.Fa vp 1224is the vnode is the file for the advisory record lock. 1225The argument 1226.Fa id 1227is the id token which is changing the lock and 1228.Fa op 1229is the 1230.Xr fcntl 2 1231operation to perform. 1232Valid values are: 1233.Pp 1234.Bl -tag -offset indent -width F_UNLCK -compact 1235.It F_SETLK 1236set lock 1237.It F_GETLK 1238get the first conflicted lock 1239.It F_UNLCK 1240clear lock 1241.El 1242.Pp 1243The argument 1244.Fa fl 1245is a description of the lock. 1246The argument 1247.Fa flags 1248is the set of flags. 1249Valid values are: 1250.Pp 1251.Bl -tag -offset indent -width F_FLOCK -compact 1252.It F_WAIT 1253wait until lock is granted 1254.It F_FLOCK 1255use 1256.Xr flock 2 1257semantics for lock 1258.It F_POSIX 1259use POSIX semantics for lock 1260.El 1261.Pp 1262If the operation is successful zero is returned, otherwise an 1263appropriate error is returned. 1264.It Fn VOP_BLKATOFF "vp" "offset" "res" "bpp" 1265Return buffer 1266.Fa bpp 1267with the contents of block 1268.Fa offset 1269from the beginning of directory specified by vnode 1270.Fa vp . 1271If 1272.Fa res 1273is non-zero, fill it in with a pointer to the remaining space in the 1274directory. 1275.It Fn VOP_VALLOC "pvp" "mode" "cred" "vpp" 1276Allocate file system type specific data a new file in the file 1277system. 1278The argument 1279.Fa pvp 1280specifies the vnode of the directory to create the new file. 1281The argument 1282.Fa mode 1283specifies file system type specific flags 1284and 1285.Fa cred 1286are the credentials of the calling process. 1287The vnode of the new file is returned in the address specified by 1288.Fa vpp . 1289.It Fn VOP_BALLOC "vp" "startoffset" "size" "cred" "flags" "bpp" 1290Allocate the physical blocks on a device given the vnode 1291.Fa vp 1292and the offset 1293logical block number 1294.Fa startoffset 1295in a file. 1296The argument 1297.Fa size 1298specifies the size to be allocated. 1299The credentials of the calling processing are specified by 1300.Fa cred . 1301If the argument 1302.Fa bpp 1303is not 1304.Dv NULL , 1305the buffer is written to the allocated blocks. 1306The argument 1307.Fa flags 1308is a set of flags controlling the low-level allocation when the buffer 1309is written. 1310Valid values defined in 1311.Aq Pa sys/buf.h 1312are: 1313.Pp 1314.Bl -tag -offset indent -width B_CLRBUF -compact 1315.It B_CLRBUF 1316request allocated buffer be cleared 1317.It B_SYNC 1318do all allocations synchronously 1319.El 1320.P 1321If the operation is successful zero is returned, otherwise an 1322appropriate error is returned. 1323.It Fn VOP_REALLOCBLKS "vp" "buflist" 1324Rearrange block in a file to be contiguous. 1325The argument 1326.Fa vp 1327is the vnode of the file to manipulate. 1328The argument 1329.Fa buflist 1330is a list of buffers to rearrange. 1331If the operation is successful zero is returned, otherwise an 1332appropriate error is returned. 1333.It Fn VOP_VFREE "pvp" "ino" "mode" 1334Release file resources. 1335This function is used by the file system to release cached file system 1336specific data associated with the file when the vnode is recycled. 1337.It Fn VOP_TRUNCATE "vp" "length" "flags" "cred" "p" 1338Truncate the file specified by the vnode 1339.Fa vp 1340to at most 1341.Fa length 1342size and free the unused disk blocks. 1343The arguments 1344.Fa p 1345and 1346.Fa cred 1347is the calling process and its credentials respectively. 1348The argument 1349.Fa flags 1350is a set of I/O flags. 1351Valid values are: 1352.Pp 1353.Bl -tag -offset indent -width IO_ALTSEMANTICS -compact 1354.It IO_UNIT 1355do I/O as atomic unit 1356.It IO_APPEND 1357append write to end 1358.It IO_SYNC 1359sync I/O file integrity completion 1360.It IO_NODELOCKED 1361underlying node already locked 1362.It IO_NDELAY 1363FNDELAY flag set in file table 1364.It IO_DSYNC 1365sync I/O data integrity completion 1366.It IO_ALTSEMANTICS 1367use alternate i/o semantics 1368.El 1369.Pp 1370If the operation is successful zero is returned, otherwise an 1371appropriate error is returned. 1372.It Fn VOP_UPDATE "vp" "access" "modify" "flags" 1373Update times on file with vnode 1374.Fa vp . 1375The access and modification times are specified by the arguments 1376.Fa access 1377and 1378.Fa modify 1379respectively. 1380The change time is always taken from the current time. 1381The argument 1382.Fa flags 1383is a set of file system type dependent flags indicating how times 1384should be updated: 1385.Pp 1386.Bl -tag -offset indent -width UPDATE_DIROP -compact 1387.It UPDATE_WAIT 1388wait for completion 1389.It UPDATE_DIROP 1390hint to file system to wait or not 1391.El 1392.It Fn VOP_LEASE "vp" "p" "cred" "flags" 1393Validate vnode credentials and operation type. 1394The argument 1395.Fa vp 1396is the locked vnode of the file to validate credentials 1397.Fa cred . 1398The argument 1399.Fa p 1400specifies the calling process and 1401.Fa flags 1402specifies the operation flags. 1403If the operation is successful zero is returned, otherwise an 1404appropriate error code is returned. 1405The vnode must be locked on entry and remains locked on return. 1406.It Fn VOP_WHITEOUT "dvp" "cnp" "flags" 1407Whiteout pathname component in directory with vnode 1408.Fa dvp . 1409The argument 1410.Fa cnp 1411specifies the pathname component to whiteout. 1412.It Fn VOP_GETPAGES "vp" "offset" "m" "count" "centeridx" "access_type" "advice" "flags" 1413Read VM pages from file. 1414The argument 1415.Fa vp 1416is the locked vnode to read the VM pages from. 1417The argument 1418.Fa offset 1419is offset in the file to start accessing and 1420.Fa m 1421is an array of VM pages. 1422The argument 1423.Fa count 1424points a variable that specifies the number of pages to read. 1425If the operation is successful zero is returned, otherwise an 1426appropriate error code is returned. 1427If PGO_LOCKED is specified in 1428.Em flags , 1429.Fn VOP_GETPAGES 1430might return less pages than requested. 1431In that case, the variable pointed to by 1432.Em count 1433will be updated. 1434.Pp 1435This function is primarily used by the page-fault handing mechanism. 1436.It Fn VOP_PUTPAGES "vp" "offset" "len" "flags" 1437Write modified (dirty) VM pages to file. 1438The argument 1439.Fa vp 1440is the locked vnode to write the VM pages to and 1441.Fa offset 1442and 1443.Fa len 1444specifies the range of VM pages to write. 1445There seems to be some confusion in the code whether 1446.Fa offset 1447and 1448.Fa len 1449specify the start and length of the VM pages for the start and end of 1450the VM pages. 1451The argument 1452.Fa flags 1453specifies whether the pages should be written asynchronously and also 1454whether they should be marked invalid one the write back operation has 1455completed. 1456If the operation is successful zero is returned, otherwise an 1457appropriate error code is returned. 1458.Pp 1459The function is primarily used by the pageout handling mechanism. 1460.It Fn VOP_STRATEGY "vp" "bp" 1461Read/write a file system buffer. 1462The argument 1463.Fa vp 1464is the vnode to read/write to. 1465The argument 1466.Fa bp 1467is the buffer to be read or written. 1468.Fn VOP_STRATEGY 1469will either read or write data to the file depending on the value of 1470.Em bp-\*[Gt]b_flags . 1471If the operation is successful zero is returned, otherwise an 1472appropriate error code is returned. 1473.It Fn VOP_BWRITE "bp" 1474Write a file system buffer. 1475The argument 1476.Fa bp 1477specifies the buffer to be written. 1478If the operation is successful zero is returned, otherwise an 1479appropriate error code is returned. 1480.It Fn VOP_GETEXTATTR "vp" "attrnamespace" "name" "uio" "size" "cred" "p" 1481Get an extended attribute. 1482The argument 1483.Fa vp 1484is the locked vnode of the file or directory from which to retrieve the 1485attribute. 1486The argument 1487.Fa attrnamespace 1488specifies the extended attribute namespace. 1489The argument 1490.Fa name 1491is a nul-terminated character string naming the attribute to retrieve. 1492The argument 1493.Fa uio , 1494if not 1495.Dv NULL , 1496specifies where the extended attribute value is to be written. 1497The argument 1498.Fa size , 1499if not 1500.Dv NULL , 1501will contain the number of bytes required to read all of 1502the attribute data upon return. 1503In most cases, 1504.Fa uio 1505will be 1506.Dv NULL 1507when 1508.Fa size 1509is not, and vice versa. 1510The argument 1511.Fa cred 1512specifies the user credentials to use when authorizing the request. 1513The argument 1514.Fa p 1515specifies the process requesting the extended attribute. 1516.It Fn VOP_SETEXTATTR "vp" "attrnamespace" "name" "uio" "cred" "p" 1517Set an extended attribute. 1518The argument 1519.Fa vp 1520is the locked vnode of the file or directory to which to store the 1521attribute. 1522The argument 1523.Fa namespace 1524specifies the extended attribute namespace. 1525The argument 1526.Fa name 1527is a nul-terminated character string naming the attribute to store. 1528The argument 1529.Fa uio 1530specifies the source of the extended attribute data. 1531The argument 1532.Fa cred 1533specifies the user credentials to use when authorizing the request. 1534The argument 1535.Fa p 1536specifies the process setting the extended attribute. 1537.It Fn VOP_LISTEXTATTR "vp" "attrnamespace" "uio" "size" "cred" "p" 1538Retrieve the list of extended attributes. 1539The argument 1540.Fa vp 1541is the locked vnode of the file or directory whose attributes are to be listed. 1542The argument 1543.Fa attrnamespace 1544specifies the extended attribute namespace. 1545The argument 1546.Fa uio , 1547if not 1548.Dv NULL , 1549specifies where the extended attribute list is to be written. 1550The argument 1551.Fa size , 1552if not 1553.Dv NULL , 1554will contain the number of bytes required to read all of 1555the attribute names upon return. 1556In most cases, 1557.Fa uio 1558will be 1559.Dv NULL 1560when 1561.Fa size 1562is not, and vice versa. 1563The argument 1564.Fa cred 1565specifies the user credentials to use when authorizing the request. 1566The argument 1567.Fa p 1568specifies the process requesting the extended attribute list. 1569.El 1570.Sh ERRORS 1571.Bl -tag -width Er 1572.It Bq Er ENOATTR 1573The requested attribute is not defined for this vnode. 1574.It Bq Er ENOTDIR 1575The vnode does not represent a directory. 1576.It Bq Er ENOENT 1577The component was not found in the directory. 1578.It Bq Er ENOSPC 1579The file system is full. 1580.It Bq Er EDQUOT 1581Quota exceeded. 1582.It Bq Er EACCES 1583Access for the specified operation is denied. 1584.It Bq Er EJUSTRETURN 1585A CREATE or RENAME operation would be successful. 1586.It Bq Er EPERM 1587an attempt was made to change an immutable file 1588.It Bq Er ENOTEMPTY 1589attempt to remove a directory which is not empty 1590.It Bq Er EINVAL 1591attempt to read from an illegal offset in the directory; unrecognised 1592input 1593.It Bq Er EIO 1594a read error occurred while reading the directory or reading the 1595contents of a symbolic link 1596.It Bq Er EROFS 1597the filesystem is read-only 1598.El 1599.Sh SEE ALSO 1600.Xr extattr 9 , 1601.Xr intro 9 , 1602.Xr lock 9 , 1603.Xr namei 9 , 1604.Xr vattr 9 , 1605.Xr vfs 9 , 1606.Xr vfsops 9 , 1607.Xr vnode 9 1608.Sh HISTORY 1609The vnode operations vector, its functions and the corresponding 1610macros appeared in 1611.Bx 4.3 . 1612