1.\" $NetBSD: vnodeops.9,v 1.36 2005/08/19 10:56:29 jmmv 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 August 19, 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 *dvp" "struct vnode **vpp" \ 167"struct componentname *cnp" "struct vattr *vap" 168.Ft int 169.Fn VOP_RMDIR "struct vnode *dvp" "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" "off_t **cookies" "int *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_ALTSEMANTICS -compact 683.It IO_UNIT 684do I/O as atomic unit 685.It IO_APPEND 686append write to end 687.It IO_SYNC 688sync I/O file integrity completion 689.It IO_NODELOCKED 690underlying node already locked 691.It IO_NDELAY 692FNDELAY flag set in file table 693.It IO_DSYNC 694sync I/O data integrity completion 695.It IO_ALTSEMANTICS 696use alternate i/o semantics 697.It IO_NORMAL 698operate on regular data 699.It IO_EXT 700operate on extended attributes 701.El 702.Pp 703Zero is returned on success, otherwise an error is returned. 704The vnode should be locked on entry and remains locked on exit. 705.It Fn VOP_WRITE "vp" "uio" "ioflag" "cred" 706Write to a file. 707The argument 708.Fa vp 709is the vnode of the file to write to, 710.Fa uio 711is the location of the data to write, 712.Fa ioflag 713is a set of flags and 714.Fa cred 715are the credentials of the calling process. 716.Pp 717The 718.Fa ioflag 719argument is used to give directives and hints to the file system. 720The low 16 bits are a bit mask which can contain the same flags as 721.Fn VOP_READ . 722.Pp 723Zero is returned on success, otherwise an error is returned. 724The vnode should be locked on entry and remains locked on exit. 725.It Fn VOP_IOCTL "vp" "command" "data" "fflag" "cred" "p" 726Perform device-specific I/O. 727The argument 728.Fa vp 729is the locked vnode of the file, normally representing a device. 730The argument 731.Fa command 732specifies the device-specific operation to perform and 733.Fa cnp 734provides extra data for the specified operation. 735The argument 736.Fa fflags 737is a set of flags. 738The argument 739.Fa cred 740is the caller's credentials and 741.Fa p 742the calling process. 743If the operation is successful, zero is 744returned, otherwise an appropriate error code is returned. 745.Pp 746Most file systems do not supply a function for 747.Fn VOP_IOCTL . 748This function implements the 749.Xr ioctl 2 750system call. 751.It Fn VOP_FCNTL "vp" "command" "data" "fflag" "cred" "p" 752Perform file control. 753The argument 754.Fa vp 755is the locked vnode of the file. 756The argument 757.Fa command 758specifies the operation to perform and 759.Fa cnp 760provides extra data for the specified operation. 761The argument 762.Fa fflags 763is a set of flags. 764The argument 765.Fa cred 766is the caller's credentials and 767.Fa p 768the calling process. 769If the operation is successful, zero is returned, otherwise an 770appropriate error code is returned. 771.It Fn VOP_POLL "vp" "events" "p" 772Test if a poll event has occurred. 773The argument 774.Fa vp 775is the locked vnode of the file to poll and 776.Fa p 777is the calling process. 778It returns any events of interest as specified by 779.Fa events 780that may have occurred for the file. 781The argument 782.Fa events 783is a set of flags as specified by 784.Xr poll 2 . 785If the operation is successful zero is returned, otherwise an 786appropriate error code is returned. 787.It Fn VOP_REVOKE "vp" "flags" 788Eliminate all activity associated with the vnode 789.Fa vp . 790The argument 791.Fa flags 792is a set of flags. 793If REVOKEALL is set in 794.Fa flags 795all vnodes aliased to the vnode 796.Fa vp 797are also eliminated. 798If the operation is successful zero is returned, otherwise an 799appropriate error is returned. 800.It Fn VOP_MMAP "vp" "fflags" "cred" "p" 801Map file into user address space. 802The argument 803.Fa vp 804is the locked vnode of the file to map into an address space. 805The argument 806.Fa fflags 807is a set of flags. 808The argument 809.Fa cred 810is the caller's credentials and 811.Fa p 812the calling process requesting the map. 813If the operation is successful, zero is returned, otherwise an 814appropriate error code is returned. 815.Pp 816Most file systems do not supply a function for 817.Fn VOP_MMAP . 818This function implements the 819.Xr mmap 2 820system call. 821.It Fn VOP_FSYNC "vp" "cred" "flags" "offlo" "offhi" "p" 822Flush pending data buffers for a file to disk. 823The argument 824.Fa vp 825is the locked vnode of the file for flush. 826The argument 827.Fa cred 828is the caller's credentials and 829.Fa p 830the calling process. 831The argument 832.Fa flags 833is a set of flags. 834If FSYNC_WAIT is specified in 835.Fa flags , 836the function should wait for I/O to complete before returning. 837The argument 838.Fa offlo 839and 840.Fa offhi 841specify the range of file to flush. 842If the operation is successful zero is returned, otherwise an 843appropriate error code is returned. 844.Pp 845This function implements the 846.Xr sync 2 847and 848.Xr fsync 2 849system calls. 850.It Fn VOP_SEEK "vp" "oldoff" "newoff" "cred" 851Test if the file is seekable for the specified offset 852.Fa newoff . 853The argument 854.Fa vp 855is the locked vnode of the file to test. 856For most filesystems this function simply tests if 857.Fa newoff 858is valid. 859If the specified 860.Fa newoff 861is less than zero, the function returns error code EINVAL. 862.It Fn VOP_REMOVE "dvp" "vp" "cnp" 863Remove a file. 864The argument 865.Fa dvp 866is the locked vnode of the directory to remove the file from and 867.Fa vp 868is the locked vnode of the file to remove. 869The argument 870.Fa cnp 871is the pathname component about the file to remove. 872If the operation is successful zero is returned, otherwise an 873appropriate error code is returned. 874Both 875.Fa dvp 876and 877.Fa vp 878should be locked on entry and remain locked on return. 879.It Fn VOP_LINK "dvp" "vp" "cnp" 880Link to a file. 881The argument 882.Fa dvp 883is the locked node of the directory to create the new link and 884.Fa vp 885is the vnode of the file to be linked. 886The argument 887.Fa cnp 888is the pathname component of the new link. 889If the operation is successful zero is returned, otherwise an error 890code is returned. 891The directory vnode 892.Fa dvp 893should be locked on entry and will remain locked on return. 894The vnode 895.Fa vp 896should not be locked on entry and will remain unlocked on return. 897.It Fn VOP_RENAME "fdvp" "fvp" "fcnp" "tdvp" "tvp" "tcnp" 898Rename a file. 899The argument 900.Fa fdvp 901is the vnode of the old parent directory containing in the file to be 902renamed and 903.Fa fvp 904is the vnode of the file to be renamed. 905The argument 906.Fa fcnp 907is the pathname component about the file to be remained. 908The argument 909.Fa tdvp 910is the vnode of the new directory of the target file and 911.Fa tvp 912is the vnode of the target file (if it exists). 913The argument 914.Fa tcnp 915is the pathname component about the file's new name. 916If the operation is successful zero is returned, otherwise and error 917code is returned. 918.Pp 919The source directory and file vnodes should be unlocked and their 920reference counts should be incremented before entry. 921The target directory and file vnodes should both be locked on entry. 922.Fn VOP_RENAME 923updates the reference counts prior to returning. 924.It Fn VOP_MKDIR "dvp" "vpp" "cnp" "vap" 925Make a new directory in a given directory. 926The argument 927.Fa dvp 928is the locked vnode of the directory to create the new directory in and 929.Fa cnp 930is the pathname component of the new directory. 931The argument 932.Fa vap 933specifies the attributes that the new directory should be created 934with. 935If the file is successfully created, the address of the resulting 936locked vnode is returned in 937.Fa vpp 938and zero is returned. 939.Pp 940This function is called after 941.Fn VOP_LOOKUP 942when a directory is being created. 943Normally, 944.Fn VOP_LOOKUP 945will have set the SAVENAME flag in 946.Em cnp-\*[Gt]cn_flags 947to keep the memory pointed to by 948.Em cnp-\*[Gt]cn_pnbuf 949valid. 950If an error is detected when creating the directory, this memory is 951released. 952If the directory is created successfully it will be released unless 953the SAVESTART flags in specified in 954.Em cnp-\*[Gt]cn_flags . 955.It Fn VOP_RMDIR "dvp" "vp" "cnp" 956Remove a directory in a given directory. 957The argument 958.Fa dvp 959is the locked vnode of the directory to remove the directory from and 960.Fa vp 961is the locked vnode of the directory to remove. 962The argument 963.Fa cnp 964is the pathname component of the directory. 965Zero is returned on success, otherwise an error code is returned. 966Both 967.Fa dvp 968and 969.Fa vp 970should be locked on entry and remain locked on return. 971.It Fn VOP_SYMLINK "dvp" "vpp" "cnp" "vap" "target" 972Create a symbolic link in a given directory. 973The argument 974.Fa dvp 975is the locked vnode of the directory to create the symbolic link in 976and 977.Fa cnp 978is the pathname component of the symbolic link. 979The argument 980.Fa vap 981specifies the attributes that the symbolic link should be created 982with and 983.Fa target 984specifies the pathname of the target of the symbolic link. 985If the symbolic link is successfully created, the address of the 986resulting locked vnode is returned in 987.Fa vpp 988and zero is returned. 989.Pp 990This function is called after 991.Fn VOP_LOOKUP 992when a symbolic link is being created. 993Normally, 994.Fn VOP_LOOKUP 995will have set the SAVENAME flag in 996.Em cnp-\*[Gt]cn_flags 997to keep the memory pointed to by 998.Em cnp-\*[Gt]cn_pnbuf 999valid. 1000If an error is detected when creating the symbolic link, this memory 1001is released. 1002If the symbolic link is created successfully it will be released 1003unless the SAVESTART flags in specified in 1004.Em cnp-\*[Gt]cn_flags . 1005.It Fn VOP_READDIR "vp" "uio" "cred" "eofflag" "cookies" "ncookies" 1006Read directory entry. 1007The argument 1008.Fa vp 1009is the vnode of the directory to read the contents of and 1010.Fa uio 1011is the destination location to read the contents into. 1012The argument 1013.Fa cred 1014is the caller's credentials. 1015The argument 1016.Fa eofflag 1017is the pointer to a flag which is set by 1018.Fn VOP_READDIR 1019to indicate and end-of-file condition. 1020If 1021.Fa eofflag 1022is 1023.Dv NULL , 1024the end-of-file condition is not returned. 1025The arguments 1026.Fa cookies 1027and 1028.Fa ncookies 1029specify the addresses for the list and number of directory seek 1030cookies generated for NFS. 1031Both 1032.Fa cookies 1033and 1034.Fa ncookies 1035should be 1036.Dv NULL 1037if they aren't required to be returned by 1038.Fn VOP_READDIR . 1039The directory contents are read into struct dirent structures. 1040If the operation is successful zero is returned, otherwise an 1041appropriate error code is returned. 1042.Pp 1043The directory should be locked on entry and will remain locked on 1044return. 1045.Pp 1046If 1047.Fn VOP_READDIR 1048is called from the NFS server, the extra arguments 1049.Fa eofflag , 1050.Fa ncookies 1051and 1052.Fa cookies 1053are used. 1054The value of 1055.Fa *eofflag 1056will be set to TRUE if the end of the directory is reached while 1057reading. 1058The directory seek cookies are returned to the NFS client and may be 1059used later to restart a directory read part way through the directory. 1060There should be one cookie returned per directory entry. 1061The value of the cookie should be the offset within the directory 1062where the on-disk version of the appropriate directory entry starts. 1063.It Fn VOP_READLINK "vp" "uio" "cred" 1064Read the contents of a symbolic link. 1065The argument 1066.Fa vp 1067is the locked vnode of the symlink and 1068.Fa uio 1069is the destination location to read the contents into. 1070The argument 1071.Fa cred 1072is the credentials of the caller. 1073If the operation is successful zero is returned, otherwise an error 1074code is returned. 1075.Pp 1076The vnode should be locked on entry and will remain locked on return. 1077.It Fn VOP_ABORTOP "dvp" "cnp" 1078Abort pending operation on vnode 1079.Fa dvp . 1080This operation is rarely implemented in file systems. 1081.It Fn VOP_INACTIVE "vp" "p" 1082Release the inactive vnode. 1083.Fn VOP_INACTIVE 1084is called when the kernel is no longer using the vnode. 1085This may be because the reference count reaches zero or it may be that 1086the file system is being forcibly unmounted while there are open 1087files. 1088It can be used to reclaim space for open but deleted files. 1089The argument 1090.Fa vp 1091is the locked vnode to be released. 1092The argument 1093.Fa p 1094is the calling process. 1095If the operation is successful zero is returned, otherwise an 1096appropriate error code is returned. 1097The vnode 1098.Fa vp 1099must be locked on entry, and will be unlocked on return. 1100.It Fn VOP_RECLAIM "vp" "p" 1101Reclaim the vnode for another file system. 1102.Fn VOP_RECLAIM 1103is called when a vnode is being reused for a different file system. 1104Any file system specific resources associated with the vnode should be 1105freed. 1106The argument 1107.Fa vp 1108is the locked vnode to be reclaimed. 1109The argument 1110.Fa p 1111is the calling process. 1112If the operation is successful zero is returned, otherwise an 1113appropriate error code is returned. 1114The vnode 1115.Fa vp 1116should not be locked on entry, and will remain unlocked on return. 1117.It Fn VOP_LOCK "vp" "flags" 1118Sleep until vnode lock is free. 1119The argument 1120.Fa vp 1121is the vnode of the file to be locked. 1122The argument 1123.Fa flags 1124is a set of 1125.Xr lockmgr 9 1126flags. 1127If the operation is successful zero is returned, otherwise an 1128appropriate error code is returned. 1129.Fn VOP_LOCK 1130is used to serialise access to the file system such as to present two 1131writes to the same file from happening at the same time. 1132Kernel code should use 1133.Xr vn_lock 9 1134to lock a vnode rather than calling 1135.Fn VOP_LOCK 1136directly. 1137.It Fn VOP_UNLOCK "vp" "flags" 1138Wake up process sleeping on lock. 1139The argument 1140.Fa vp 1141is the vnode of the file to be unlocked. 1142The argument 1143.Fa flags 1144is a set of 1145.Xr lockmgr 9 1146flags. 1147If the operation is successful zero is returned, otherwise an 1148appropriate error code is returned. 1149.Fn VOP_UNLOCK 1150is used to serialise access to the file system such as to present two 1151writes to the same file from happening at the same time. 1152.It Fn VOP_ISLOCKED "vp" 1153Test if the vnode 1154.Fa vp 1155is locked. 1156A non-zero values is returned if the vnode is not locked, otherwise 1157zero is returned. 1158.It Fn VOP_BMAP "vp" "bn" "vpp" "bnp" "runp" 1159Convert the logical block number 1160.Fa bn 1161of a file specified by vnode 1162.Fa vp 1163to its physical block number on the disk. 1164If 1165.Fa vpp 1166is not 1167.Dv NULL , 1168the vnode of the device vnode for the file system is 1169returned in the address specified by 1170.Fa vpp . 1171If 1172.Fa runp 1173is not 1174.Dv NULL , 1175the maximum blocksize is returned in the address specified by 1176.Fa runp . 1177.It Fn VOP_PRINT "vp" 1178Print debugging information. 1179The argument 1180.Fa vp 1181is the vnode to print. 1182If the operation is successful zero is returned, otherwise an 1183appropriate error code is returned. 1184.It Fn VOP_PATHCONF "vp" "name" "retval" 1185Implement POSIX 1186.Xr pathconf 2 1187and 1188.Xr fpathconf 2 1189support. 1190The argument 1191.Fa vp 1192is the locked vnode to get information about. 1193The argument 1194.Fa name 1195specified the type of information to return. 1196The information is returned in the address specified by 1197.Fa retval . 1198Valid values for 1199.Fa name 1200are: 1201.Pp 1202.Bl -tag -offset indent -width _PC_CHOWN_RESTRICTED -compact 1203.It _PC_LINK_MAX 1204return the maximum number of links to a file 1205.It _PC_NAME_MAX 1206return the maximum number of bytes in a file name 1207.It _PC_PATH_MAX 1208return the maximum number of bytes in a pathname 1209.It _PC_PIPE_BUF 1210return the maximum number of bytes which will be written atomically to 1211a pipe 1212.It _PC_CHOWN_RESTRICTED 1213return 1 if appropriate privileges are required for the 1214.Xr chown 2 1215system call, otherwise zero 1216.It _PC_NO_TRUNC 1217return if file names longer than KERN_NAME_MAX are truncated 1218.El 1219.Pp 1220If 1221.Fa name 1222is recognised, 1223.Fa *retval 1224is set to the specified value and zero is returned, otherwise an 1225appropriate error is returned. 1226.It Fn VOP_ADVLOCK "vp" "id" "op" "fl" "flags" 1227Manipulate Advisory record locks on a file. 1228The argument 1229.Fa vp 1230is the vnode is the file for the advisory record lock. 1231The argument 1232.Fa id 1233is the id token which is changing the lock and 1234.Fa op 1235is the 1236.Xr fcntl 2 1237operation to perform. 1238Valid values are: 1239.Pp 1240.Bl -tag -offset indent -width F_UNLCK -compact 1241.It F_SETLK 1242set lock 1243.It F_GETLK 1244get the first conflicted lock 1245.It F_UNLCK 1246clear lock 1247.El 1248.Pp 1249The argument 1250.Fa fl 1251is a description of the lock. 1252The argument 1253.Fa flags 1254is the set of flags. 1255Valid values are: 1256.Pp 1257.Bl -tag -offset indent -width F_FLOCK -compact 1258.It F_WAIT 1259wait until lock is granted 1260.It F_FLOCK 1261use 1262.Xr flock 2 1263semantics for lock 1264.It F_POSIX 1265use POSIX semantics for lock 1266.El 1267.Pp 1268If the operation is successful zero is returned, otherwise an 1269appropriate error is returned. 1270.It Fn VOP_BLKATOFF "vp" "offset" "res" "bpp" 1271Return buffer 1272.Fa bpp 1273with the contents of block 1274.Fa offset 1275from the beginning of directory specified by vnode 1276.Fa vp . 1277If 1278.Fa res 1279is non-zero, fill it in with a pointer to the remaining space in the 1280directory. 1281.It Fn VOP_VALLOC "pvp" "mode" "cred" "vpp" 1282Allocate file system type specific data a new file in the file 1283system. 1284The argument 1285.Fa pvp 1286specifies the vnode of the directory to create the new file. 1287The argument 1288.Fa mode 1289specifies file system type specific flags 1290and 1291.Fa cred 1292are the credentials of the calling process. 1293The vnode of the new file is returned in the address specified by 1294.Fa vpp . 1295.It Fn VOP_BALLOC "vp" "startoffset" "size" "cred" "flags" "bpp" 1296Allocate the physical blocks on a device given the vnode 1297.Fa vp 1298and the offset 1299logical block number 1300.Fa startoffset 1301in a file. 1302The argument 1303.Fa size 1304specifies the size to be allocated. 1305The credentials of the calling processing are specified by 1306.Fa cred . 1307If the argument 1308.Fa bpp 1309is not 1310.Dv NULL , 1311the buffer is written to the allocated blocks. 1312The argument 1313.Fa flags 1314is a set of flags controlling the low-level allocation when the buffer 1315is written. 1316Valid values defined in 1317.Aq Pa sys/buf.h 1318are: 1319.Pp 1320.Bl -tag -offset indent -width B_CLRBUF -compact 1321.It B_CLRBUF 1322request allocated buffer be cleared 1323.It B_SYNC 1324do all allocations synchronously 1325.El 1326.P 1327If the operation is successful zero is returned, otherwise an 1328appropriate error is returned. 1329.It Fn VOP_REALLOCBLKS "vp" "buflist" 1330Rearrange block in a file to be contiguous. 1331The argument 1332.Fa vp 1333is the vnode of the file to manipulate. 1334The argument 1335.Fa buflist 1336is a list of buffers to rearrange. 1337If the operation is successful zero is returned, otherwise an 1338appropriate error is returned. 1339.It Fn VOP_VFREE "pvp" "ino" "mode" 1340Release file resources. 1341This function is used by the file system to release cached file system 1342specific data associated with the file when the vnode is recycled. 1343.It Fn VOP_TRUNCATE "vp" "length" "flags" "cred" "p" 1344Truncate the file specified by the vnode 1345.Fa vp 1346to at most 1347.Fa length 1348size and free the unused disk blocks. 1349The arguments 1350.Fa p 1351and 1352.Fa cred 1353is the calling process and its credentials respectively. 1354The argument 1355.Fa flags 1356is a set of I/O flags. 1357Valid values are: 1358.Pp 1359.Bl -tag -offset indent -width IO_ALTSEMANTICS -compact 1360.It IO_UNIT 1361do I/O as atomic unit 1362.It IO_APPEND 1363append write to end 1364.It IO_SYNC 1365sync I/O file integrity completion 1366.It IO_NODELOCKED 1367underlying node already locked 1368.It IO_NDELAY 1369FNDELAY flag set in file table 1370.It IO_DSYNC 1371sync I/O data integrity completion 1372.It IO_ALTSEMANTICS 1373use alternate i/o semantics 1374.El 1375.Pp 1376If the operation is successful zero is returned, otherwise an 1377appropriate error is returned. 1378.It Fn VOP_UPDATE "vp" "access" "modify" "flags" 1379Update times on file with vnode 1380.Fa vp . 1381The access and modification times are specified by the arguments 1382.Fa access 1383and 1384.Fa modify 1385respectively. 1386The change time is always taken from the current time. 1387The argument 1388.Fa flags 1389is a set of file system type dependent flags indicating how times 1390should be updated: 1391.Pp 1392.Bl -tag -offset indent -width UPDATE_DIROP -compact 1393.It UPDATE_WAIT 1394wait for completion 1395.It UPDATE_DIROP 1396hint to file system to wait or not 1397.El 1398.It Fn VOP_LEASE "vp" "p" "cred" "flags" 1399Validate vnode credentials and operation type. 1400The argument 1401.Fa vp 1402is the locked vnode of the file to validate credentials 1403.Fa cred . 1404The argument 1405.Fa p 1406specifies the calling process and 1407.Fa flags 1408specifies the operation flags. 1409If the operation is successful zero is returned, otherwise an 1410appropriate error code is returned. 1411The vnode must be locked on entry and remains locked on return. 1412.It Fn VOP_WHITEOUT "dvp" "cnp" "flags" 1413Whiteout pathname component in directory with vnode 1414.Fa dvp . 1415The argument 1416.Fa cnp 1417specifies the pathname component to whiteout. 1418.It Fn VOP_GETPAGES "vp" "offset" "m" "count" "centeridx" "access_type" "advice" "flags" 1419Read VM pages from file. 1420The argument 1421.Fa vp 1422is the locked vnode to read the VM pages from. 1423The argument 1424.Fa offset 1425is offset in the file to start accessing and 1426.Fa m 1427is an array of VM pages. 1428The argument 1429.Fa count 1430points a variable that specifies the number of pages to read. 1431If the operation is successful zero is returned, otherwise an 1432appropriate error code is returned. 1433If PGO_LOCKED is specified in 1434.Em flags , 1435.Fn VOP_GETPAGES 1436might return less pages than requested. 1437In that case, the variable pointed to by 1438.Em count 1439will be updated. 1440.Pp 1441This function is primarily used by the page-fault handing mechanism. 1442.It Fn VOP_PUTPAGES "vp" "offset" "len" "flags" 1443Write modified (dirty) VM pages to file. 1444The argument 1445.Fa vp 1446is the locked vnode to write the VM pages to and 1447.Fa offset 1448and 1449.Fa len 1450specifies the range of VM pages to write. 1451There seems to be some confusion in the code whether 1452.Fa offset 1453and 1454.Fa len 1455specify the start and length of the VM pages for the start and end of 1456the VM pages. 1457The argument 1458.Fa flags 1459specifies whether the pages should be written asynchronously and also 1460whether they should be marked invalid one the write back operation has 1461completed. 1462If the operation is successful zero is returned, otherwise an 1463appropriate error code is returned. 1464.Pp 1465The function is primarily used by the pageout handling mechanism. 1466.It Fn VOP_STRATEGY "vp" "bp" 1467Read/write a file system buffer. 1468The argument 1469.Fa vp 1470is the vnode to read/write to. 1471The argument 1472.Fa bp 1473is the buffer to be read or written. 1474.Fn VOP_STRATEGY 1475will either read or write data to the file depending on the value of 1476.Em bp-\*[Gt]b_flags . 1477If the operation is successful zero is returned, otherwise an 1478appropriate error code is returned. 1479.It Fn VOP_BWRITE "bp" 1480Write a file system buffer. 1481The argument 1482.Fa bp 1483specifies the buffer to be written. 1484If the operation is successful zero is returned, otherwise an 1485appropriate error code is returned. 1486.It Fn VOP_GETEXTATTR "vp" "attrnamespace" "name" "uio" "size" "cred" "p" 1487Get an extended attribute. 1488The argument 1489.Fa vp 1490is the locked vnode of the file or directory from which to retrieve the 1491attribute. 1492The argument 1493.Fa attrnamespace 1494specifies the extended attribute namespace. 1495The argument 1496.Fa name 1497is a nul-terminated character string naming the attribute to retrieve. 1498The argument 1499.Fa uio , 1500if not 1501.Dv NULL , 1502specifies where the extended attribute value is to be written. 1503The argument 1504.Fa size , 1505if not 1506.Dv NULL , 1507will contain the number of bytes required to read all of 1508the attribute data upon return. 1509In most cases, 1510.Fa uio 1511will be 1512.Dv NULL 1513when 1514.Fa size 1515is not, and vice versa. 1516The argument 1517.Fa cred 1518specifies the user credentials to use when authorizing the request. 1519The argument 1520.Fa p 1521specifies the process requesting the extended attribute. 1522.It Fn VOP_SETEXTATTR "vp" "attrnamespace" "name" "uio" "cred" "p" 1523Set an extended attribute. 1524The argument 1525.Fa vp 1526is the locked vnode of the file or directory to which to store the 1527attribute. 1528The argument 1529.Fa namespace 1530specifies the extended attribute namespace. 1531The argument 1532.Fa name 1533is a nul-terminated character string naming the attribute to store. 1534The argument 1535.Fa uio 1536specifies the source of the extended attribute data. 1537The argument 1538.Fa cred 1539specifies the user credentials to use when authorizing the request. 1540The argument 1541.Fa p 1542specifies the process setting the extended attribute. 1543.It Fn VOP_LISTEXTATTR "vp" "attrnamespace" "uio" "size" "cred" "p" 1544Retrieve the list of extended attributes. 1545The argument 1546.Fa vp 1547is the locked vnode of the file or directory whose attributes are to be listed. 1548The argument 1549.Fa attrnamespace 1550specifies the extended attribute namespace. 1551The argument 1552.Fa uio , 1553if not 1554.Dv NULL , 1555specifies where the extended attribute list is to be written. 1556The argument 1557.Fa size , 1558if not 1559.Dv NULL , 1560will contain the number of bytes required to read all of 1561the attribute names upon return. 1562In most cases, 1563.Fa uio 1564will be 1565.Dv NULL 1566when 1567.Fa size 1568is not, and vice versa. 1569The argument 1570.Fa cred 1571specifies the user credentials to use when authorizing the request. 1572The argument 1573.Fa p 1574specifies the process requesting the extended attribute list. 1575.El 1576.Sh ERRORS 1577.Bl -tag -width Er 1578.It Bq Er ENOATTR 1579The requested attribute is not defined for this vnode. 1580.It Bq Er ENOTDIR 1581The vnode does not represent a directory. 1582.It Bq Er ENOENT 1583The component was not found in the directory. 1584.It Bq Er ENOSPC 1585The file system is full. 1586.It Bq Er EDQUOT 1587Quota exceeded. 1588.It Bq Er EACCES 1589Access for the specified operation is denied. 1590.It Bq Er EJUSTRETURN 1591A CREATE or RENAME operation would be successful. 1592.It Bq Er EPERM 1593an attempt was made to change an immutable file 1594.It Bq Er ENOTEMPTY 1595attempt to remove a directory which is not empty 1596.It Bq Er EINVAL 1597attempt to read from an illegal offset in the directory; unrecognised 1598input 1599.It Bq Er EIO 1600a read error occurred while reading the directory or reading the 1601contents of a symbolic link 1602.It Bq Er EROFS 1603the filesystem is read-only 1604.El 1605.Sh SEE ALSO 1606.Xr extattr 9 , 1607.Xr intro 9 , 1608.Xr lock 9 , 1609.Xr namei 9 , 1610.Xr vattr 9 , 1611.Xr vfs 9 , 1612.Xr vfsops 9 , 1613.Xr vnode 9 1614.Sh HISTORY 1615The vnode operations vector, its functions and the corresponding 1616macros appeared in 1617.Bx 4.3 . 1618