1.\" $NetBSD: vnodeops.9,v 1.9 2002/02/13 08:18:56 ross Exp $ 2.\" 3.\" Copyright (c) 2001 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 October 16, 2001 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.Nd vnode operations 91.Sh SYNOPSIS 92.Fd #include \*[Lt]sys/param.h\*[Gt] 93.Fd #include \*[Lt]sys/buf.h\*[Gt] 94.Fd #include \*[Lt]sys/dirent.h\*[Gt] 95.Fd #include \*[Lt]sys/lock.h\*[Gt] 96.Fd #include \*[Lt]sys/vnode.h\*[Gt] 97.Fd #include \*[Lt]sys/mount.h\*[Gt] 98.Fd #include \*[Lt]sys/namei.h\*[Gt] 99.Fd #include \*[Lt]sys/unistd.h\*[Gt] 100.Fd #include \*[Lt]sys/fcntl.h\*[Gt] 101.Fd #include \*[Lt]sys/lockf.h\*[Gt] 102.Ft int 103.Fn VOP_LOOKUP "struct vnode *dvp" "struct vnode **vpp" \ 104"struct componentname *cnp" 105.Ft int 106.Fn VOP_CREATE "struct vnode *dvp" "struct vnode **vpp" \ 107"struct componentname *cnp" "struct vattr *vap" 108.Ft int 109.Fn VOP_MKNOD "struct vnode *dvp" "struct vnode **vpp" \ 110"struct componentname *cnp" "struct vattr *vap" 111.Ft int 112.Fn VOP_OPEN "struct vnode *vp" "int mode" "struct ucred *cred" \ 113"struct proc *p" 114.Ft int 115.Fn VOP_CLOSE "struct vnode *vp" "int fflag" "struct ucred *cred" \ 116"struct proc *p" 117.Ft int 118.Fn VOP_ACCESS "struct vnode *vp" "int mode" "struct ucred *cred" \ 119"struct proc *p" 120.Ft int 121.Fn VOP_GETATTR "struct vnode *vp" "struct vattr *vap" \ 122"struct ucred *cred" "struct proc *p" 123.Ft int 124.Fn VOP_SETATTR "struct vnode *vp" "struct vattr *vap" \ 125"struct ucred *cred" "struct proc *p" 126.Ft int 127.Fn VOP_READ "struct vnode *vp" "struct uio *uio" "int ioflag" \ 128"struct ucred *cred" 129.Ft int 130.Fn VOP_WRITE "struct vnode *vp" "struct uio *uio" "int ioflag" \ 131"struct ucred *cred" 132.Ft int 133.Fn VOP_IOCTL "struct vnode *vp" "u_long command" "caddr_t data" \ 134"int fflag" "struct ucred *cred" "struct proc *p" 135.Ft int 136.Fn VOP_FCNTL "struct vnode *vp" "u_int command" "caddr_t data" \ 137"int fflag" "struct ucred *cred" "struct proc *p" 138.Ft int 139.Fn VOP_POLL "struct vnode *vp" "int events" "struct proc *p" 140.Ft int 141.Fn VOP_REVOKE "struct vnode *vp" "int flags" 142.Ft int 143.Fn VOP_MMAP "struct vnode *vp" "int fflags" \ 144"struct ucred *cred" "struct proc *p" 145.Ft int 146.Fn VOP_FSYNC "struct vnode *vp" "struct ucred *cred" "int flags" \ 147"off_t offlo" "off_t offhi" "struct proc *p" 148.Ft int 149.Fn VOP_SEEK "struct vnode *vp" "off_t oldoff" "off_t newoff" \ 150"struct ucred *cred" 151.Ft int 152.Fn VOP_REMOVE "struct vnode *vp" "struct vnode *vp" \ 153"struct componentname *cnp" 154.Ft int 155.Fn VOP_LINK "struct vnode *dvp" "struct vnode *vp" \ 156"struct componentname *cnp" 157.Ft int 158.Fn VOP_RENAME "struct vnode *fdvp" "struct vnode *vp" \ 159"struct componentname *fcnp" "struct componentname *tdvp" \ 160"struct vnode *tvp" "struct componentname *tcnp" 161.Ft int 162.Fn VOP_MKDIR "struct vnode *vp" "struct vnode **vpp" \ 163"struct componentname *cnp" "struct vattr *vap" 164.Ft int 165.Fn VOP_RMDIR "struct vnode *vp" "struct vnode *vp" \ 166"struct componentname *cnp" 167.Ft int 168.Fn VOP_SYMLINK "struct vnode *dvp" "struct vnode **vpp" \ 169"struct componentname *cnp" "struct vattr *vap" "char *target" 170.Ft int 171.Fn VOP_READDIR "struct vnode *vp" "struct uio *uio" \ 172"struct ucred *cred" "int *eofflag" "cookies" "ncookies" 173.Ft int 174.Fn VOP_READLINK "struct vnode *vp" "struct uio *uio" "struct ucred *cred" 175.Ft int 176.Fn VOP_ABORTOP "struct vnode *dvp" "struct componentname *cnp" 177.Ft int 178.Fn VOP_INACTIVE "struct vnode *vp" "struct proc *p" 179.Ft int 180.Fn VOP_RECLAIM "struct vnode *vp" "struct proc *p" 181.Ft int 182.Fn VOP_LOCK "struct vnode *vp" "int flags" 183.Ft int 184.Fn VOP_UNLOCK "struct vnode *vp" "int flags" 185.Ft int 186.Fn VOP_ISLOCKED "struct vnode *vp" 187.Ft int 188.Fn VOP_BMAP "struct vnode *vp" "daddr_t bn" "struct vnode **vpp" \ 189"daddr_t *bnp" "int *runp" 190.Ft int 191.Fn VOP_PRINT "struct vnode *vp" 192.Ft int 193.Fn VOP_PATHCONF "struct vnode *vp" "int name" "register_t *retval" 194.Ft int 195.Fn VOP_ADVLOCK "struct vnode *vp" "caddr_t id" "int op" \ 196"struct flock *fl" "int flags" 197.Ft int 198.Fn VOP_BLKATOFF "struct vnode *vp" "off_t offset" "char **res" \ 199"struct buf **bpp" 200.Ft int 201.Fn VOP_VALLOC "struct vnode *pvp" "int mode" "struct ucred *cred" \ 202"struct vnode **vpp" 203.Ft int 204.Fn VOP_BALLOC "struct vnode *vp" "off_t startoffset" "int size" \ 205"struct ucred *cred" "int flags" "struct buf **bpp" 206.Ft int 207.Fn VOP_REALLOCBLKS "struct vnode *vp" "struct cluster_save *buflist" 208.Ft int 209.Fn VOP_VFREE "struct vnode *pvp" "ino_t ino" "int mode" 210.Ft int 211.Fn VOP_TRUNCATE "struct vnode *vp" "off_t length" "int flags" \ 212"struct ucred *cred" "struct proc *p" 213.Ft int 214.Fn VOP_UPDATE "struct vnode *vp" "struct timespec *access" \ 215"struct timespec *modify" "int flags" 216.Ft int 217.Fn VOP_LEASE "struct vnode *vp" "struct proc *p" "struct ucred *cred" \ 218"int flag" 219.Ft int 220.Fn VOP_WHITEOUT "struct vnode *dvp" "struct componentname *cnp" \ 221"int flags" 222.Ft int 223.Fn VOP_GETPAGES "struct vnode *vp" "voff_t offset" "struct vm_page **m" \ 224"int *centeridx" "int access_type" "vm_prot_t advice" "int flags" 225.Ft int 226.Fn VOP_PUTPAGES "struct vnode *vp" "voff_t offlo" "voff_t offlo" \ 227"int flags" 228.Ft int 229.Fn VOP_STRATEGY "struct buf *bp" 230.Ft int 231.Fn VOP_BWRITE "struct buf *bp" 232.Pp 233Not all header files are required for each function. 234.Sh DESCRIPTION 235The vnode operations vector describes what operations can be done to 236the file associated with the vnode. The system maintains one vnode 237operations vector for each file system type configured into the 238kernel. The vnode operations vector contains a pointer to a function 239for each operation supported by the file system. Many of the 240functions described in the vnode operations vector are closely related 241to their corresponding system calls. In most cases, they are called 242as a result of the system call associated with the operation being 243invoked. 244.Pp 245Functions in the vnode operations vector are invoked using specialised 246macros. The following table lists the elements of the vnode 247operations vector, the corresponding invocation macro, and a 248description of the element. 249.Pp 250.nf 251.ta \w'int (*vop_reallocblks)()'u+2n +\w'VOP_REALLOCBLKS'u+2n +\w'rearrange blocks as contiguous'u 252\fIVector element\fP \fIMacro\fP \fIDescription\fP 253.ta \w'int (*vop_reallocblks)()'u+2n +\w'VOP_REALLOCBLKS'u+2n +\w'rearrange blocks as contiguous'u+6nC 254.sp 5p 255int (*vop_lookup)() VOP_LOOKUP Lookup file name in name cache 256int (*vop_create)() VOP_CREATE Create a new file 257int (*vop_mknod)() VOP_MKNOD Make a new device 258int (*vop_open)() VOP_OPEN Open a file 259int (*vop_close)() VOP_CLOSE Close a file 260int (*vop_access)() VOP_ACCESS Determine file accessibility 261int (*vop_getattr)() VOP_GETATTR Get file attributes 262int (*vop_setattr)() VOP_SETATTR Set file attributes 263int (*vop_read)() VOP_READ Read from a file 264int (*vop_write)() VOP_WRITE Write to a file 265int (*vop_ioctl)() VOP_IOCTL Perform device-specific I/O 266int (*vop_fcntl)() VOP_FCNTL Perform file control 267int (*vop_poll)() VOP_POLL Test if poll event has occurred 268int (*vop_revoke)() VOP_REVOKE Eliminate vode activity 269int (*vop_mmap)() VOP_MMAP Map file into user address space 270int (*vop_fsync)() VOP_FSYNC Flush pending data to disk 271int (*vop_seek)() VOP_SEEK Test if file is seekable 272int (*vop_remove)() VOP_REMOVE Remove a file 273int (*vop_link)() VOP_LINK Link a file 274int (*vop_rename)() VOP_RENAME Rename a file 275int (*vop_mkdir)() VOP_MKDIR Make a new directory 276int (*vop_rmdir)() VOP_RMDIR Remove a directory 277int (*vop_symlink)() VOP_SYMLINK Create a symbolic link 278int (*vop_readdir)() VOP_READDIR Read directory entry 279int (*vop_readlink)() VOP_READLINK Read contents of a symlink 280int (*vop_abortop)() VOP_ABORTOP Abort pending operation 281int (*vop_inactive)() VOP_INACTIVE Release the inactive vnode 282int (*vop_reclaim)() VOP_RECLAIM Reclaim vnode for another file 283int (*vop_lock)() VOP_LOCK Sleep until vnode lock is free 284int (*vop_unlock)() VOP_UNLOCK Wake up process sleeping on lock 285int (*vop_islocked)() VOP_ISLOCKED Test if vnode is locked 286int (*vop_bmap)() VOP_BMAP Logical block number conversion 287int (*vop_print)() VOP_PRINT Print debugging information 288int (*vop_pathconf)() VOP_PATHCONF Implement POSIX pathconf support 289int (*vop_advlock)() VOP_ADVLOCK Advisory record locking 290int (*vop_blkatoff)() VOP_BLKATOFF Retrieve buffer from offset 291int (*vop_valloc)() VOP_VALLOC Allocate fs-specific data 292int (*vop_balloc)() VOP_BALLOC Allocate physical blocks 293int (*vop_reallocblks)() VOP_REALLOCBLKS rearrange blocks as contiguous 294int (*vop_vfree)() VOP_VFREE Release file resources 295int (*vop_truncate)() VOP_TRUNCATE Truncate file and free blocks 296int (*vop_update)() VOP_UPDATE Update time on a file 297int (*vop_lease)() VOP_LEASE Validate vnode credentials 298int (*vop_whiteout)() VOP_WHITEOUT Whiteout vnode 299int (*vop_getpages)() VOP_GETPAGES Read VM pages from file 300int (*vop_putpages)() VOP_PUTPAGES Write VM pages to file 301int (*vop_strategy)() VOP_STRATEGY Read/write a file system buffer 302int (*vop_bwrite)() VOP_BWRITE Write a file system buffer 303.fi 304.Pp 305The implementation details of the vnode operations vector are not 306quite what is described here. 307.Pp 308If the file system type does not support a specific operation, it must 309nevertheless assign an appropriate function in the vnode operations 310vector to do the minimum required of it. In most cases, such 311functions either do nothing or return an error value to the effect 312that it is not supported. 313.Pp 314Many of the functions in the vnode operations vector take a 315componentname structure. Is is used to encapsulate many parameters 316into a singla function argument. It has the following structure: 317.Bd -literal 318struct componentname { 319 /* 320 * Arguments to lookup. 321 */ 322 u_long cn_nameiop; /* namei operation */ 323 u_long cn_flags; /* flags to namei */ 324 struct proc *cn_proc; /* process requesting lookup */ 325 struct ucred *cn_cred; /* credentials */ 326 /* 327 * Shared between lookup and commit routines. 328 */ 329 char *cn_pnbuf; /* pathname buffer */ 330 const char *cn_nameptr; /* pointer to looked up name */ 331 long cn_namelen; /* length of looked up component */ 332 u_long cn_hash; /* hash value of looked up name */ 333 long cn_consume; /* chars to consume in lookup() */ 334}; 335.Ed 336.Pp 337The top half of the structure is used exclusively for the pathname 338lookups using 339.Fn VOP_LOOKUP 340and is initialised by the caller. The semantics of the lookup are 341affected by the lookup operation specified in 342.Em cn_nameiop 343and the flags specified in 344.Em cn_flags . 345Valid operations are: 346.Pp 347.Bl -tag -offset indent -width LOOKUP -compact 348.It LOOKUP 349perform name lookup only 350.It CREATE 351setup for file creation 352.It DELETE 353setup for file deletion 354.It RENAME 355setup for file renaming 356.It OPMASK 357mask for operation 358.El 359.Pp 360Valid values for 361.Em cn-\*[Gt]cn_flags 362are: 363.Pp 364.Bl -tag -offset indent -width LOCKPARENT -compact 365.It LOCKLEAF 366lock inode on return 367.It LOCKPARENT 368want parent vnode returned locked 369.It WANTPARENT 370want parent vnode returned unlocked 371.It NOCACHE 372name must not be left in name cache (see 373.Xr namecache 9 ) 374.It FOLLOW 375follow symbolic links 376.It NOFOLLOW 377do not follow symbolic links (pseudo) 378.It MODMASK 379mask of operational modifiers 380.El 381.Pp 382No vnode operations may be called from interrupt context. Most 383operations also require the vnode to be locked on entry. To prevent 384deadlocks, when acquiring locks on multiple vnodes, the lock of parent 385directory must be acquired before the lock on the child directory. 386.Pp 387Vnode operations for a file system type generally should not be 388called directly from the kernel, but accessed indirectly through the 389high-level convenience functions discussed in 390.Xr vnsubr 9 . 391.Sh FUNCTIONS 392.Bl -tag -width compact 393.It Fn VOP_LOOKUP "dvp" "vpp" "cnp" 394Lookup a single pathname component in a given directory. The argument 395.Fa dvp 396is the locked vnode of the directory to search and 397.Fa cnp 398is the pathname component to be searched for. If the pathname 399component is found, the address of the resulting locked vnode is 400returned in 401.Fa vpp . 402The operation specified in 403.Em cnp-\*[Gt]cn_nameiop 404gives 405.Fn VOP_LOOKUP 406hints about the reason for requesting the lookup and uses it to cache 407file system type specific information in the vnode for subsequent 408operations. 409.Pp 410There are three types of lookups: ".", ".." (ISDOTDOT), and other. If 411the pathname component being searched for is ".", then 412.Fa dvp 413has an extra reference added to it and it is returned in 414.Fa *vpp . 415If the pathname component being search for is ".." (ISDOTDOT), 416.Fa dvp 417is unlocked, the ".." node is locked and then 418.Fa dvp 419is relocked if and only if LOCKPARENT and ISLASTCN is set in 420.Em cnp-\*[Gt]cn_flags . 421If LOCKPARENT or ISLATCN is not set, 422.Fa dvp 423is returned unlocked on a successful lookup. This process preserves 424the protocol of always locking nodes from root downward and prevents 425deadlock. For other pathname components, 426.Fn VOP_LOOKUP 427checks the accessibility of the directory and searches the name cache 428for the pathname component. See 429.Xr namecache 9 . 430If the pathname is not found in the name cache, the directory is 431searched for the pathname. The resulting locked vnode is returned in 432.Fa vpp . 433If LOCKPARENT or ISLATCN is not set, 434.Fa dvp 435is returned unlocked on a successful lookup. 436.Pp 437On failure 438.Fa *vpp 439is NULL, and 440.Fa *dvp 441is left locked. If there was an error relocking 442.Fa dvp 443(for instance in the ISDOTDOT case) the error is returned with 444PDIRUNLOCK set in 445.Em cnp-\*[Gt]cn_flags . 446This flag signals to the caller that 447.Fa dvp ' s 448lock state has changed. If the operation is successful 449.Fa *vpp 450is locked and zero is returned. Typically, if 451.Fa *vpp 452and 453.Fa dvp 454are the same vnode the caller will need to release twice (decrement 455the reference count) and unlock once. 456.It Fn VOP_CREATE "dvp" "vpp" "cnp" "vap" 457Create a new file in a given directory. The argument 458.Fa dvp 459is the locked vnode of the directory to create the new file in and 460.Fa cnp 461is the pathname component of the new file. The argument 462.Fa vap 463specifies the attributes that the new file should be created with. If 464the file is successfully created, the address of the resulting locked 465vnode is returned in 466.Fa vpp 467and zero is returned. 468.Pp 469This function is called after 470.Fn VOP_LOOKUP 471when a file is being created. Normally, 472.Fn VOP_LOOKUP 473will have set the SAVENAME flag in 474.Em cnp-\*[Gt]cn_flags 475to keep the memory pointed to by 476.Em cnp-\*[Gt]cn_pnbuf 477valid. If an error is detected when creating the file, this memory is 478released. If the file is created successfully it will be released 479unless the SAVESTART flags in specified in 480.Em cnp-\*[Gt]cn_flags . 481.It Fn VOP_MKNOD "dvp" "vpp" "cnp" "vap" 482Make a new device-special file in a given directory. The argument 483.Fa dvp 484is the locked vnode of the directory to create the new device-special 485file in and 486.Fa cnp 487is the pathname component of the new device-special file. The 488argument 489.Fa vap 490specifies the attributes that the new device-special file should be 491created with. If the file is successfully created, the address of the 492resulting locked vnode is returned in 493.Fa vpp 494and zero is returned. 495.Pp 496This function is called after 497.Fn VOP_LOOKUP 498when a device-special file is being created. Normally, 499.Fn VOP_LOOKUP 500will have set the SAVENAME flag in 501.Em cnp-\*[Gt]cn_flags 502to keep the memory pointed to by 503.Em cnp-\*[Gt]cn_pnbuf 504valid. If an error is detected when creating the device-special file, 505this memory is released. If the device-special file is created 506successfully it will be released unless the SAVESTART flags in 507specified in 508.Em cnp-\*[Gt]cn_flags . 509.It Fn VOP_OPEN "vp" "mode" "cred" "p" 510Open a file. The argument 511.Fa vp 512is the vnode of the file to open and 513.Fa mode 514specifies the access mode required by the calling process. The 515calling process and its credentials are specified by 516.Fa p 517and 518.Fa cred 519respectively. The access mode is a set of flags, including FREAD, 520FWRITE, O_NONBLOCK, O_APPEND, etc. 521.Fn VOP_OPEN 522must be called before a file can be accessed by a thread. The vnode 523reference count is incremented. 524.Pp 525.Fn VOP_OPEN 526expects the vnode 527.Fa vp 528to be locked on entry and will leave it locked on return. If the 529operation is successful zero is returned, otherwise an appropriate 530error code is returned. 531.It Fn VOP_CLOSE "vp" "fflag" "cred" "p" 532Close a file. The argument 533.Fa vp 534is the vnode of the file to close and 535.Fa fflags 536specifies the access mode by the calling process. The calling process 537and its credentials are specified by 538.Fa p 539and 540.Fa cred 541respectively. 542.Fn VOP_CLOSE 543must be called after a file is finished with. 544.Pp 545.Fn VOP_CLOSE 546expects at least a reference to be associated with the vnode and does 547not care whether the vnode is locked. The lock and reference state is 548left unchanged on return. 549.It Fn VOP_ACCESS "vp" "mode" "cred" "p" 550Determine the accessibility (permissions) of the file against the 551specified credentials. The argument 552.Fa vp 553is the vnode of the file to check, 554.Fa mode 555is the type of access required, 556.Fa cred 557contains the user credentials to check and 558.Fa p 559is the process which is checking the credentials. The argument 560.Fa mode 561is a mask which can contain VREAD, VWRITE or VEXEC. 562If the file is accessible in the specified way, zero is returned, 563otherwise an appropriate error code is returned. 564.Pp 565The vnode 566.Fa vp 567will be locked on entry and should remain locked on return. 568.It Fn VOP_GETATTR "vp" "vap" "cred" "p" 569Get specific vnode attributes on a file. The argument 570.Fa vp 571is the locked vnode of the file to get the attributes for. The 572arguments 573.Fa p 574and 575.Fa cred 576specifies the calling process and its credentials respectively. 577.Fn VOP_GETATTR 578uses the file system type specific data object 579.Em vp-\*[Gt]v_data 580to reference the underlying file attributes. 581Attributes associated with the file are collected by setting the 582required attribute bits in 583.Em vap-\*[Gt]va_mask . 584The attributes are returned in 585.Fa vap . 586Attributes which are not available are set to the value VNOVAL. 587.Pp 588For more information on vnode attributes see 589.Xr vattr 9 . 590.It Fn VOP_SETATTR "vp" "vap" "cred" "p" 591Set specific vnode attributes on a file. The argument 592.Fa vp 593is the locked vnode of the file to set the attributes for. The 594arguments 595.Fa p 596and 597.Fa cred 598specifies the calling process and its credentials respectively. 599.Fn VOP_SETATTR 600uses the file system type specific data object 601.Em vp-\*[Gt]v_data 602to reference the underlying file attributes. The new attributes are 603defined in 604.Fa vap . 605Attributes associated with the file are set by setting the required 606attribute bits in 607.Em vap-\*[Gt]va_mask . 608Attributes which are not being modified by 609.Fn VOP_SETATTR 610should be set to the value VNOVAL. If the operation is successful 611zero is returned, otherwise an appropriate error is returned. 612.Pp 613For more information on vnode attributes see 614.Xr vattr 9 . 615.It Fn VOP_READ "vp" "uio" "ioflag" "cred" 616Read the contents of a file. The argument 617.Fa vp 618is the vnode of the file to read from, 619.Fa uio 620is the location to read the data into, 621.Fa ioflag 622is a set of flags and 623.Fa cred 624are the credentials of the calling process. 625.Pp 626The 627.Fa ioflag 628argument is used to give directives and hints to the file system. When 629attempting a read, the high 16 bits are used to provide a read-ahead 630hint (in unit of file system blocks) that the file system should 631attempt. The low 16 bits are a bit mask which can contain the 632following flags: 633.Pp 634.Bl -tag -offset indent -width IO_NODELOCKED -compact 635.It IO_UNIT 636do I/O as atomic unit 637.It IO_APPEND 638append write to end 639.It IO_SYNC 640do I/O synchronously 641.It IO_NODELOCKED 642underlying node already locked 643.It IO_NDELAY 644FNDELAY flag set in file table 645.It IO_VMIO 646data already in VMIO space 647.El 648.Pp 649Zero is returned on success, otherwise an error is returned. The vnode 650should be locked on entry and remains locked on exit. 651.It Fn VOP_WRITE "vp" "uio" "ioflag" "cred" 652Write to a file. The argument 653.Fa vp 654is the vnode of the file to write to, 655.Fa uio 656is the location of the data to write, 657.Fa ioflag 658is a set of flags and 659.Fa cred 660are the credentials of the calling process. 661.Pp 662The 663.Fa ioflag 664argument is used to give directives and hints to the file system. The 665low 16 bits are a bit mask which can contain the same flags as 666.Fn VOP_READ . 667.Pp 668Zero is returned on success, otherwise an error is returned. The vnode 669should be locked on entry and remains locked on exit. 670.It Fn VOP_IOCTL "vp" "command" "data" "fflag" "cred" "p" 671Perform device-specific I/O. The argument 672.Fa vp 673is the locked vnode of the file, normally representing a device. The 674argument 675.Fa command 676specifies the device-specific operation to perform and 677.Fa cnp 678provides extra data for the specified operation. The argument 679.Fa fflags 680is a set of flags. The argument 681.Fa cred 682is the caller's credentials and 683.Fa p 684the calling process. If the operation is successful, zero is 685returned, otherwise an appropriate error code is returned. 686.Pp 687Most file systems do not supply a function for 688.Fn VOP_IOCTL . 689This function implments the 690.Xr ioctl 2 691system call. 692.It Fn VOP_FCNTL "vp" "command" "data" "fflag" "cred" "p" 693Perform file control. The argument 694.Fa vp 695is the locked vnode of the file. The 696argument 697.Fa command 698specifies the operation to perform and 699.Fa cnp 700provides extra data for the specified operation. The argument 701.Fa fflags 702is a set of flags. The argument 703.Fa cred 704is the caller's credentials and 705.Fa p 706the calling process. If the operation is successful, zero is 707returned, otherwise an appropriate error code is returned. 708.It Fn VOP_POLL "vp" "events" "p" 709Test if a poll event has occurred. The argument 710.Fa vp 711is the locked vnode of the file to poll and 712.Fa p 713is the callling process. It returns any events of interest as 714specified by 715.Fa events 716that may have occurred for the file. The argument 717.Fa events 718is a set of flags as specified by 719.Xr poll 2 . 720If the operation is successful zero is returned, otherwise an 721appropriate error code is returned. 722.It Fn VOP_REVOKE "vp" "flags" 723Eliminate all activity associated with the vnode 724.Fa vp . 725The argument 726.Fa flags 727is a set of flags. If REVOKEALL is set in 728.Fa flags 729all vnodes aliased to the vnode 730.Fa vp 731are also eliminated. If the operation is successful zero is returned, 732otherwise an appropriate error is returned. 733.It Fn VOP_MMAP "vp" "fflags" "cred" "p" 734Map file into user address space. The argument 735.Fa vp 736is the locked vnode of the file to map into an address space. The 737argument 738.Fa fflags 739is a set of flags. The argument 740.Fa cred 741is the caller's credentials and 742.Fa p 743the calling process requesting the map. If the operation is 744successful, zero is returned, otherwise an appropriate error code is 745returned. 746.Pp 747Most file systems do not supply a function for 748.Fn VOP_MMAP . 749This function implements the 750.Xr mmap 2 751system call. 752.It Fn VOP_FSYNC "vp" "cred" "flags" "offlo" "offhi" "p" 753Flush pending data buffers for a file to disk. The argument 754.Fa vp 755is the locked vnode of the file for flush. The argument 756.Fa cred 757is the caller's credentials and 758.Fa p 759the calling process. The argument 760.Fa flags 761is a set of flags. If FSYNC_WAIT is specified in 762.Fa flags , 763the function should wait for I/O to complete before returning. 764The argument 765.Fa offlo 766and 767.Fa offhi 768specify the range of file to flush. If the 769operation is successful zero is returned, otherwise an appropriate 770error code is returned. 771.Pp 772This function implements the 773.Xr sync 2 774and 775.Xr fsync 2 776system calls. 777.It Fn VOP_SEEK "vp" "oldoff" "newoff" "cred" 778Test if the file is seekable for the specified offset 779.Fa oldoff . 780The argument 781.Fa vp 782is the locked vnode of the file to test. For most filesystems this 783function simply tests if 784.Fa oldoff 785is valid. If the specified 786.Fa oldoff 787is less than zero, the function returns error code EINVAL. 788.It Fn VOP_REMOVE "dvp" "vp" "cnp" 789Remove a file. The argument 790.Fa dvp 791is the locked vnode of the directory to remove the file from and 792.Fa vp 793is the locked vnode of the file to remove. The argument 794.Fa cnp 795is the pathname component about the file to remove. If the operation 796is successful zero is returned, otherwise an appropriate error code is 797returned. Both 798.Fa dvp 799and 800.Fa vp 801should be locked on entry and remain locked on return. 802.It Fn VOP_LINK "dvp" "vp" "cnp" 803Link to a file. The argument 804.Fa dvp 805is the locked node of the directory to create the new link and 806.Fa vp 807is the vnode of the file to be linked. The argument 808.Fa cnp 809is the pathname component of the the new link. If the operation is 810successful zero is returned, otherwise an error code is returned. The 811directory vnode 812.Fa dvp 813should be locked on entry and will remain locked on return. The vnode 814.Fa vp 815should not be locked on entry and will remain unlocked on return. 816.It Fn VOP_RENAME "fdvp" "fvp" "fcnp" "tdvp" "tvp" "tcnp" 817Rename a file. The argument 818.Fa fdvp 819is the vnode of the old parent directory containing in the file to be 820renamed and 821.Fa fvp 822is the vnode of the file to be renamed. The argument 823.Fa fcnp 824is the pathname component about the file to be remained. The argument 825.Fa tdvp 826is the vnode of the new directory of the target file and 827.Fa tvp 828is the vnode of the target file (if it exists). The argument 829.Fa tcnp 830is the pathname component about the file's new name. If the operation 831is successful zero is returned, otherwise and error code is returned. 832.Pp 833The source directory and file vnodes should be unlocked and their 834reference counts should be incremented before entry. The target 835directory and file vnodes should both be locked on entry. 836.Fn VOP_RENAME 837updates the reference counts prior to returning. 838.It Fn VOP_MKDIR "dvp" "vpp" "cnp" "vap" 839Make a new directory in a given directory. The argument 840.Fa dvp 841is the locked vnode of the directory to create the new directory in and 842.Fa cnp 843is the pathname component of the new directory. The argument 844.Fa vap 845specifies the attributes that the new directory should be created with. If 846the file is successfully created, the address of the resulting locked 847vnode is returned in 848.Fa vpp 849and zero is returned. 850.Pp 851This function is called after 852.Fn VOP_LOOKUP 853when a directory is being created. Normally, 854.Fn VOP_LOOKUP 855will have set the SAVENAME flag in 856.Em cnp-\*[Gt]cn_flags 857to keep the memory pointed to by 858.Em cnp-\*[Gt]cn_pnbuf 859valid. If an error is detected when creating the directory, this 860memory is released. If the directory is created successfully it will 861be released unless the SAVESTART flags in specified in 862.Em cnp-\*[Gt]cn_flags . 863.It Fn VOP_RMDIR "dvp" "vp" "cnp" 864Remove a directory in a given directory. The argument 865.Fa dvp 866is the locked vnode of the directory to remove the directory from and 867.Fa vp 868is the locked vnode of the directory to remove. The argument 869.Fa cnp 870is the pathname component of the directory. Zero is returned on 871success, otherwise an error code is returned. Both 872.Fn dvp 873and 874.Fn vp 875should be locked on entry and remain locked on return. 876.It Fn VOP_SYMLINK "dvp" "vpp" "cnp" "vap" "target" 877Create a symbolic link in a given directory. The argument 878.Fa dvp 879is the locked vnode of the directory to create the symbolic link in 880and 881.Fa cnp 882is the pathname component of the symbolic link. The argument 883.Fa vap 884specifies the attributes that the symbolic link should be created 885with and 886.Fa target 887specifies the pathname of the target of the symbolic link. If the 888symbolic link is successfully created, the address of the resulting 889locked vnode is returned in 890.Fa vpp 891and zero is returned. 892.Pp 893This function is called after 894.Fn VOP_LOOKUP 895when a symbolic link is being created. Normally, 896.Fn VOP_LOOKUP 897will have set the SAVENAME flag in 898.Em cnp-\*[Gt]cn_flags 899to keep the memory pointed to by 900.Em cnp-\*[Gt]cn_pnbuf 901valid. If an error is detected when creating the symbolic link, this 902memory is released. If the symbolic link is created successfully it 903will be released unless the SAVESTART flags in specified in 904.Em cnp-\*[Gt]cn_flags . 905.It Fn VOP_READDIR "vp" "uio" "cred" "eofflag" "cookies" "ncookies" 906Read directory entry. The argument 907.Fa vp 908is the vnode of the directory to read the contents of and 909.Fa uio 910is the destination location to read the contents into. The argument 911.Fa cred 912is the caller's credientials. The argument 913.Fa eofflag 914is the pointer to a flag which is set by 915.Fn VOP_READDIR 916to indicate and end-of-file condition. If 917.Fa eofflag 918is NULL, the end-of-file condition is not returned. The arguments 919.Fa cookies 920and 921.Fa ncookies 922specify the addresses for the list and number of directory seek 923cookies generated for NFS. Both 924.Fa cookies 925and 926.Fa ncookies 927should be NULL if they aren't required to be returned by 928.Fn VOP_READDIR . 929The directory contents are read into struct dirent structures. If the 930operation is successful zero is returned, otherwise an appropriate 931error code is returned. 932.Pp 933The directory should be locked on entry and will remain locked on 934return. 935.Pp 936If 937.Fn VOP_READDIR 938is called from the NFS server, the extra arguments 939.Fa eofflag , 940.Fa ncookies 941and 942.Fa cookies 943are used. The value of 944.Fa *eofflag 945will be set to TRUE if the end of the directory is reached while 946reading. The directory seek cookies are returned to the NFS client 947and may be used later to restart a directory read part way through the 948directory. There should be one cookie returned per directory entry. 949The value of the cookie should be the offset within the directory 950where the on-disk version of the appropriate directory entry starts. 951.It Fn VOP_READLINK "vp" "uio" "cred" 952Read the contents of a symbolic link. The argument 953.Fa vp 954is the locked vnode of the symlink and 955.Fa uio 956is the destination location to read the contents into. The argument 957.Fa cred 958is the credentials of the caller. If the operation is successful zero 959is returned, otherwise an error code is returned. 960.Pp 961The vnode should be locked on entry and will remain locked on return. 962.It Fn VOP_ABORTOP "dvp" "cnp" 963Abort pending operation on vnode 964.Fa dvp . 965This operation is rarely implemented in file systems. 966.It Fn VOP_INACTIVE "vp" "p" 967Release the inactive vnode. 968.Fn VOP_INACTIVE 969is called when the kernel is no longer using the vnode. This may be 970because the reference count reaches zero or it may be that the file 971system is being forcibly unmounted while there are open files. It can 972be used to reclaim space for open but deleted files. The argument 973.Fa vp 974is the locked vnode to be released. The argument 975.Fa p 976is the calling process. If the operation is successful zero is 977returned, otherwise an appropriate error code is returned. The vnode 978.Fa vp 979must be locked on entry, and will be unlocked on return. 980.It Fn VOP_RECLAIM "vp" "p" 981Reclaim the vnode for another file system. 982.Fn VOP_RECLAIM 983is called when a vnode is being reused for a different file system. 984Any file system specific resources associated with the vnode should be 985freed. The argument 986.Fa vp 987is the locked vnode to be reclaimed. The argument 988.Fa p 989is the calling process. If the operation is successful zero is returned, 990otherwise an appropriate error code is returned. The vnode 991.Fa vp 992should not be locked on entry, and will remain unlocked on return. 993.It Fn VOP_LOCK "vp" "flags" 994Sleep until vnode lock is free. The argument 995.Fa vp 996is the vnode of the file to be locked. The argument 997.Fa flags 998is a set of 999.Xr lockmgr 9 1000flags. If the operation is successful zero is returned, otherwise an 1001appropriate error code is returned. 1002.Fn VOP_LOCK 1003is used to serialise access to the file system such as to present two 1004writes to the same file from happening at the same time. Kernel code 1005should use 1006.Xr vn_lock 9 1007to lock a vnode rather than calling 1008.Fn VOP_LOCK 1009directly. 1010.It Fn VOP_UNLOCK "vp" "flags" 1011Wake up process sleeping on lock. The argument 1012.Fa vp 1013is the vnode of the file to be unlocked. The argument 1014.Fa flags 1015is a set of 1016.Xr lockmgr 9 1017flags. If the operation is successful zero is returned, otherwise an 1018appropriate error code is returned. 1019.Fn VOP_UNLOCK 1020is used to serialise access to the file system such as to present two 1021writes to the same file from happening at the same time. 1022.It Fn VOP_ISLOCKED "vp" 1023Test if the vnode 1024.Fa vp 1025is locked. A non-zero values is returned if the vnode is not locked, 1026otherwise zero is returned. 1027.It Fn VOP_BMAP "vp" "bn" "vpp" "bnp" "runp" 1028Convert the logical block number 1029.Fa bn 1030of a file specified by vnode 1031.Fa vp 1032to its physical block number on the disk. If 1033.Fa vpp 1034is not NULL, the vnode of the device vnode for the file system is 1035returned in the address specified by 1036.Fa vpp . 1037If 1038.Fa runp 1039is not NULL, the maximum blocksize is returned in the address 1040specified by 1041.Fa runp . 1042.It Fn VOP_PRINT "vp" 1043Print debugging information. The argument 1044.Fa vp 1045is the vnode to print. If the operation is successful zero is 1046returned, otherwise an appropriate error code is returned. 1047.It Fn VOP_PATHCONF "vp" "name" "retval" 1048Implement POSIX 1049.Xr pathconf 2 1050and 1051.Xr fpathconf 2 1052support. The argument 1053.Fa vp 1054is the locked vnode to get information about. The argument 1055.Fa name 1056specified the type of information to return. The information 1057is returned in the address specified by 1058.Fa retval . 1059Valid values for 1060.Fa name 1061are: 1062.Pp 1063.Bl -tag -offset indent -width _PC_CHOWN_RESTRICTED -compact 1064.It _PC_LINK_MAX 1065return the maximum number of links to a file 1066.It _PC_NAME_MAX 1067return the maximum number of bytes in a file name 1068.It _PC_PATH_MAX 1069return the maximum number of bytes in a pathname 1070.It _PC_PIPE_BUF 1071return the maximum number of bytes which will be written atomically to 1072a pipe 1073.It _PC_CHOWN_RESTRICTED 1074return 1 if appropriate privileges are required for the 1075.Xr chown 2 1076system call, otherwise zero 1077.It _PC_NO_TRUNC 1078return if file names longer than KERN_NAME_MAX are truncated 1079.El 1080.Pp 1081If 1082.Fa name 1083is recognised, 1084.Fa *retval 1085is set to the specified value and zero is returned, otherwise an 1086appropriate error is returned. 1087.It Fn VOP_ADVLOCK "vp" "id" "op" "fl" "flags" 1088Manipulate Advisory record locks on a file. The argument 1089.Fa vp 1090is the vnode is the file for the advisory record lock. The argument 1091.Fa id 1092is the id token which is changing the lock and 1093.Fa op 1094is the 1095.Xr fcntl 2 1096operation to perform. The argument 1097.Fa fl 1098is a description of the lock. The argument 1099.Fa flags 1100is the set of flags. Valid values are: 1101.Pp 1102.Bl -tag -offset indent -width F_RDLCK -compact 1103.It F_RDLCK 1104shared or read lock 1105.It F_UNLCK 1106unlock 1107.It F_WRLCK 1108exclusive or write lock 1109.It F_WAIT 1110wait until lock is granted 1111.It F_FLOCK 1112use 1113.Xr flock 2 1114semantics for lock 1115.It F_POSIX 1116use POSIX semantics for lock 1117.El 1118.Pp 1119If the operation is successful zero is returned, otherwise an 1120appropriate error is returned. 1121.It Fn VOP_BLKATOFF "vp" "offset" "res" "bpp" 1122Return buffer 1123.Fa bpp 1124with the contents of block 1125.Fa offset 1126from the beginning of directory specified by vnode 1127.Fa vp . 1128If 1129.Fa res 1130is non-zero, fill it in with a pointer to the remaining space in the 1131directory. 1132.It Fn VOP_VALLOC "pvp" "mode" "cred" "vpp" 1133Allocate file system type specific data a new file in the file 1134system. The argument 1135.Fa pvp 1136specifies the vnode of the directory to create the new file. 1137The argument 1138.Fa mode 1139specifies file system type specific flags 1140and 1141.Fa cred 1142are the credentials of the calling process. The vnode of the new file 1143is returned in the address specified by 1144.Fa vpp . 1145.It Fn VOP_BALLOC "vp" "startoffset" "size" "cred" "flags" "bpp" 1146Allocate the physical blocks on a device given the vnode 1147.Fa vp 1148and the offset 1149logical block number 1150.Fa startoffset 1151in a file. The argument 1152.Fa size 1153specifies the size to be allocated. The credentials of the calling 1154processing are specified by 1155.Fa cred . 1156If the argument 1157.Fa bpp 1158is not NULL, the buffer is written to the allocated blocks. The 1159argument 1160.Fa flags 1161is a set of flags controlling the low-level allocation when the buffer 1162is written. Valid values defined in 1163.Pa \*[Lt]sys/buf.h\*[Gt] 1164are: 1165.Pp 1166.Bl -tag -offset indent -width B_CLRBUF -compact 1167.It B_CLRBUF 1168request allocated buffer be cleared 1169.It B_SYNC 1170do all allocations synchronously 1171.El 1172.P 1173If the operation is successful zero is returned, otherwise an 1174appropriate error is returned. 1175.It Fn VOP_REALLOCBLKS "vp" "buflist" 1176Rearrange block in a file to be contiguous. The argument 1177.Fa vp 1178is the vnode of the file to manipulate. The argument 1179.Fa buflist 1180is a list of buffers to rearrange. If the operation is successful 1181zero is returned, otherwise an appropriate error is returned. 1182.It Fn VOP_VFREE "pvp" "ino" "mode" 1183Release file resources. This function is used by the file system to 1184release cached file system specific data associated with the file when 1185the vnode is recycled. 1186.It Fn VOP_TRUNCATE "vp" "length" "flags" "cred" "p" 1187Truncate the file specified by the vnode 1188.Fa vp 1189to at most 1190.Fa length 1191size and free the unused disk blocks. The arguments 1192.Fa p 1193and 1194.Fa cred 1195is the calling process and its credentials respectively. The argument 1196.Fa flags 1197is a set of I/O flags. Valid values are: 1198.Pp 1199.Bl -tag -offset indent -width IO_ALTSEMANTICS -compact 1200.It IO_UNIT 1201do I/O as atomic unit 1202.It IO_APPEND 1203append write to end 1204.It IO_SYNC 1205sync I/O file integrity completion 1206.It IO_NODELOCKED 1207underlying node already locked 1208.It IO_NDELAY 1209FNDELAY flag set in file table 1210.It IO_DSYNC 1211sync I/O data integrity completion 1212.It IO_ALTSEMANTICS 1213use alternate i/o semantics 1214.El 1215.Pp 1216If the operation is successful zero is returned, otherwise an 1217appropriate error is returned. 1218.It Fn VOP_UPDATE "vp" "access" "modify" "flags" 1219Update times on file with vnode 1220.Fa vp . 1221The access and modification times are specified by the arguments 1222.Fa access 1223and 1224.Fa modify 1225respectively. The change time is always taken from the current time. 1226The argument 1227.Fa flags 1228is a set of file system type dependent flags indicating which times 1229should be updated. 1230.It Fn VOP_LEASE "vp" "p" "cred" "flag" 1231Validate vnode credentials and operation type. The argument 1232.Fa vp 1233is the locked vnode of the file to validate credentials 1234.Fa cred . 1235The argument 1236.Fa p 1237specifies the calling process and 1238.Fa flags 1239specifies the operation flags. If the operation is successful zero is 1240returned, otherwise an appropriate error code is returned. The vnode 1241must be locked on entry and remains locked on return. 1242.It Fn VOP_WHITEOUT "dvp" "cnp" "flags" 1243Whiteout pathname component in directory with vnode 1244.Fa dvp . 1245The argument 1246.Fa cnp 1247specifies the pathname component to whiteout. 1248.It Fo VOP_GETPAGES 1249.Fa "vp" "offset" "m" "count" "centeridx" 1250.Fa "access_type" "advice" "flags" 1251.Fc 1252Read VM pages from file. The argument 1253.Fa vp 1254is the locked vnode to read the VM pages from. The argument 1255.Fa offset 1256is offset in the file to start accessing and 1257.Fa m 1258is an array of VM pages. 1259The argument 1260.Fa count 1261specifies the number of pages to read. If the operation is successful 1262zero is returned, otherwise an appropriate error code is returned. 1263.Pp 1264This function is primarily used by the page-fault handing mechanism. 1265.It Fn VOP_PUTPAGES "vp" "offset" "len" "flags" 1266Write modified (dirty) VM pages to file. The argument 1267.Fa vp 1268is the locked vnode to write the VM pages to and 1269.Fa offset 1270and 1271.Fa len 1272specifies the range of VM pages to write. There seems to be some 1273confusion in the code whether 1274.Fa offset 1275and 1276.Fa len 1277specify the start and length of the VM pages for the start and end of 1278the VM pages. The argument 1279.Fa flags 1280specifies whether the pages should be written asynchronously and also 1281whether they should be marked invalid one the write back operation has 1282completed. If the operation is successful zero is returned, otherwise 1283an appropriate error code is returned. 1284.Pp 1285The function is primarily used by the pageout handling mechanism. 1286.It Fn VOP_STRATEGY "bp" 1287Read/write a file system buffer. The argument 1288.Fa bp 1289is the buffer to be read or written. 1290.Fn VOP_STRATEGY 1291will either read or write data to the file depending on the value of 1292.Em vp-\*[Gt]b_flags . 1293If the operation is successful zero is returned, otherwise an 1294appropriate error code is returned. 1295.It Fn VOP_BWRITE "bp" 1296Write a file system buffer. The argument 1297.Fa bp 1298specifies the buffer to be written. If the operation is successful 1299zero is returned, otherwise an appropriate error code is returned. 1300.El 1301.Sh ERRORS 1302.Bl -tag -width Er 1303.It Bq Er ENOTDIR 1304The vnode does not represent a directory. 1305.It Bq Er ENOENT 1306The component was not found in the directory. 1307.It Bq Er ENOSPC 1308The file system is full. 1309.It Bq Er EDQUOT 1310Quota exceeded. 1311.It Bq Er EACCES 1312Access for the specified operation is denied. 1313.It Bq Er EJUSTRETURN 1314A CREATE or RENAME operation would be successful. 1315.It Bq Er EPERM 1316an attempt was made to change an immutable file 1317.It Bq Er ENOTEMPTY 1318attempt to remove a directory which is not empty 1319.It Bq Er EINVAL 1320attempt to read from an illegal offset in the directory; unrecognised 1321input 1322.It Bq Er EIO 1323a read error occurred while reading the directory or reading the 1324contents of a symbolic link 1325.It Bq Er EROFS 1326the filesystem is read-only 1327.El 1328.Sh SEE ALSO 1329.Xr intro 9 , 1330.Xr lock 9 , 1331.Xr namei 9 , 1332.Xr vattr 9 , 1333.Xr vfs 9 , 1334.Xr vnode 9 1335.Sh HISTORY 1336The vnode operations vector, its functions and the corresponding 1337macros appeared in 1338.Bx 4.3 . 1339