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