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