1 .\" $NetBSD: vnodeops.9,v 1.76 2009/03/15 13:45:04 joerg Exp $
3 .\" Copyright (c) 2001, 2005, 2006 The NetBSD Foundation, Inc.
4 .\" All rights reserved.
6 .\" This code is derived from software contributed to The NetBSD Foundation
7 .\" by Gregory McGarry.
9 .\" Redistribution and use in source and binary forms, with or without
10 .\" modification, are permitted provided that the following conditions
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.
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.
94 .Fn VOP_LOOKUP "struct vnode *dvp" "struct vnode **vpp" \
95 "struct componentname *cnp"
97 .Fn VOP_CREATE "struct vnode *dvp" "struct vnode **vpp" \
98 "struct componentname *cnp" "struct vattr *vap"
100 .Fn VOP_MKNOD "struct vnode *dvp" "struct vnode **vpp" \
101 "struct componentname *cnp" "struct vattr *vap"
103 .Fn VOP_OPEN "struct vnode *vp" "int mode" "kauth_cred_t cred"
105 .Fn VOP_CLOSE "struct vnode *vp" "int fflag" "kauth_cred_t cred"
107 .Fn VOP_ACCESS "struct vnode *vp" "int mode" "kauth_cred_t cred"
109 .Fn VOP_GETATTR "struct vnode *vp" "struct vattr *vap" "kauth_cred_t cred"
111 .Fn VOP_SETATTR "struct vnode *vp" "struct vattr *vap" "kauth_cred_t cred"
113 .Fn VOP_READ "struct vnode *vp" "struct uio *uio" "int ioflag" \
116 .Fn VOP_WRITE "struct vnode *vp" "struct uio *uio" "int ioflag" \
119 .Fn VOP_IOCTL "struct vnode *vp" "u_long command" "void *data" \
120 "int fflag" "kauth_cred_t cred"
122 .Fn VOP_FCNTL "struct vnode *vp" "u_int command" "void *data" \
123 "int fflag" "kauth_cred_t cred"
125 .Fn VOP_POLL "struct vnode *vp" "int events"
127 .Fn VOP_KQFILTER "struct vnode *vp" "struct knote *kn"
129 .Fn VOP_REVOKE "struct vnode *vp" "int flags"
131 .Fn VOP_MMAP "struct vnode *vp" "vm_prot_t prot" "kauth_cred_t cred"
133 .Fn VOP_FSYNC "struct vnode *vp" "kauth_cred_t cred" "int flags" \
134 "off_t offlo" "off_t offhi"
136 .Fn VOP_SEEK "struct vnode *vp" "off_t oldoff" "off_t newoff" \
139 .Fn VOP_REMOVE "struct vnode *vp" "struct vnode *vp" \
140 "struct componentname *cnp"
142 .Fn VOP_LINK "struct vnode *dvp" "struct vnode *vp" \
143 "struct componentname *cnp"
145 .Fn VOP_RENAME "struct vnode *fdvp" "struct vnode *fvp" \
146 "struct componentname *fcnp" "struct vnode *tdvp" \
147 "struct vnode *tvp" "struct componentname *tcnp"
149 .Fn VOP_MKDIR "struct vnode *dvp" "struct vnode **vpp" \
150 "struct componentname *cnp" "struct vattr *vap"
152 .Fn VOP_RMDIR "struct vnode *dvp" "struct vnode *vp" \
153 "struct componentname *cnp"
155 .Fn VOP_SYMLINK "struct vnode *dvp" "struct vnode **vpp" \
156 "struct componentname *cnp" "struct vattr *vap" "char *target"
158 .Fn VOP_READDIR "struct vnode *vp" "struct uio *uio" \
159 "kauth_cred_t cred" "int *eofflag" "off_t **cookies" "int *ncookies"
161 .Fn VOP_READLINK "struct vnode *vp" "struct uio *uio" "kauth_cred_t cred"
163 .Fn VOP_ABORTOP "struct vnode *dvp" "struct componentname *cnp"
165 .Fn VOP_INACTIVE "struct vnode *vp"
167 .Fn VOP_RECLAIM "struct vnode *vp"
169 .Fn VOP_LOCK "struct vnode *vp" "int flags"
171 .Fn VOP_UNLOCK "struct vnode *vp" "int flags"
173 .Fn VOP_ISLOCKED "struct vnode *vp"
175 .Fn VOP_BMAP "struct vnode *vp" "daddr_t bn" "struct vnode **vpp" \
176 "daddr_t *bnp" "int *runp"
178 .Fn VOP_PRINT "struct vnode *vp"
180 .Fn VOP_PATHCONF "struct vnode *vp" "int name" "register_t *retval"
182 .Fn VOP_ADVLOCK "struct vnode *vp" "void *id" "int op" \
183 "struct flock *fl" "int flags"
185 .Fn VOP_LEASE "struct vnode *vp" "kauth_cred_t cred" \
188 .Fn VOP_WHITEOUT "struct vnode *dvp" "struct componentname *cnp" \
191 .Fn VOP_GETPAGES "struct vnode *vp" "voff_t offset" "struct vm_page **m" \
192 "int *count" "int centeridx" "vm_prot_t access_type" "int advice" "int flags"
194 .Fn VOP_PUTPAGES "struct vnode *vp" "voff_t offlo" "voff_t offhi" \
197 .Fn VOP_STRATEGY "struct vnode *vp" "struct buf *bp"
199 .Fn VOP_BWRITE "struct buf *bp"
201 .Fn VOP_GETEXTATTR "struct vnode *vp" "int attrnamespace" "const char *name" \
202 "struct uio *uio" "size_t *size" "kauth_cred_t cred"
204 .Fn VOP_SETEXTATTR "struct vnode *vp" "int attrnamespace" "const char *name" \
205 "struct uio *uio" "kauth_cred_t cred"
207 .Fn VOP_LISTEXTATTR "struct vnode *vp" "int attrnamespace" "struct uio *uio" \
208 "size_t *size" "kauth_cred_t cred"
210 Not all header files are required for each function.
212 The vnode operations vector describes what operations can be done to
213 the file associated with the vnode.
214 The system maintains one vnode operations vector for each file system
215 type configured into the kernel.
216 The vnode operations vector contains a pointer to a function for each
217 operation supported by the file system.
218 Many of the functions described in the vnode operations vector are
219 closely related to their corresponding system calls.
220 In most cases, they are called as a result of the system call
221 associated with the operation being invoked.
223 Functions in the vnode operations vector are invoked using specialized
225 The following table lists the elements of the vnode operations vector,
226 the corresponding invocation macro, and a description of the element.
228 .Bl -column "int (*vop_strategy)()" "VOP_LISTEXTATTR" "Wake up process sleeping on lock" -compact
229 .It Sy Vector element Ta Sy Macro Ta Sy Description
230 .It int (*vop_lookup)() VOP_LOOKUP Lookup file name in name cache
231 .It int (*vop_create)() VOP_CREATE Create a new file
232 .It int (*vop_mknod)() VOP_MKNOD Make a new device
233 .It int (*vop_open)() VOP_OPEN Open a file
234 .It int (*vop_close)() VOP_CLOSE Close a file
235 .It int (*vop_access)() VOP_ACCESS Determine file accessibility
236 .It int (*vop_getattr)() VOP_GETATTR Get file attributes
237 .It int (*vop_setattr)() VOP_SETATTR Set file attributes
238 .It int (*vop_read)() VOP_READ Read from a file
239 .It int (*vop_write)() VOP_WRITE Write to a file
240 .It int (*vop_ioctl)() VOP_IOCTL Perform device-specific I/O
241 .It int (*vop_fcntl)() VOP_FCNTL Perform file control
242 .It int (*vop_poll)() VOP_POLL Test if poll event has occurred
243 .It int (*vop_kqfilter)() VOP_KQFILTER Register a knote
244 .It int (*vop_revoke)() VOP_REVOKE Eliminate vode activity
245 .It int (*vop_mmap)() VOP_MMAP Map file into user address space
246 .It int (*vop_fsync)() VOP_FSYNC Flush pending data to disk
247 .It int (*vop_seek)() VOP_SEEK Test if file is seekable
248 .It int (*vop_remove)() VOP_REMOVE Remove a file
249 .It int (*vop_link)() VOP_LINK Link a file
250 .It int (*vop_rename)() VOP_RENAME Rename a file
251 .It int (*vop_mkdir)() VOP_MKDIR Make a new directory
252 .It int (*vop_rmdir)() VOP_RMDIR Remove a directory
253 .It int (*vop_symlink)() VOP_SYMLINK Create a symbolic link
254 .It int (*vop_readdir)() VOP_READDIR Read directory entry
255 .It int (*vop_readlink)() VOP_READLINK Read contents of a symlink
256 .It int (*vop_abortop)() VOP_ABORTOP Abort pending operation
257 .It int (*vop_inactive)() VOP_INACTIVE Release the inactive vnode
258 .It int (*vop_reclaim)() VOP_RECLAIM Reclaim vnode for another file
259 .It int (*vop_lock)() VOP_LOCK Sleep until vnode lock is free
260 .It int (*vop_unlock)() VOP_UNLOCK Wake up process sleeping on lock
261 .It int (*vop_islocked)() VOP_ISLOCKED Test if vnode is locked
262 .It int (*vop_bmap)() VOP_BMAP Logical block number conversion
263 .It int (*vop_print)() VOP_PRINT Print debugging information
264 .It int (*vop_pathconf)() VOP_PATHCONF Return POSIX pathconf data
265 .It int (*vop_advlock)() VOP_ADVLOCK Advisory record locking
266 .It int (*vop_lease)() VOP_LEASE Validate vnode credentials
267 .It int (*vop_whiteout)() VOP_WHITEOUT Whiteout vnode
268 .It int (*vop_getpages)() VOP_GETPAGES Read VM pages from file
269 .It int (*vop_putpages)() VOP_PUTPAGES Write VM pages to file
270 .It int (*vop_strategy)() VOP_STRATEGY Read/write a file system buffer
271 .It int (*vop_bwrite)() VOP_BWRITE Write a file system buffer
272 .It int (*vop_getextattr)() VOP_GETEXTATTR Get extended attribute
273 .It int (*vop_setextattr)() VOP_SETEXTATTR Set extended attribute
274 .It int (*vop_listextattr)() VOP_LISTEXTATTR List extended attributes
277 The implementation details of the vnode operations vector are not
278 quite what is described here.
280 If the file system type does not support a specific operation, it must
281 nevertheless assign an appropriate function in the vnode operations
282 vector to do the minimum required of it.
283 In most cases, such functions either do nothing or return an error
284 value to the effect that it is not supported.
286 Many of the functions in the vnode operations vector take a
287 componentname structure.
288 It is used to encapsulate many parameters into a single function
290 It has the following structure:
292 struct componentname {
294 * Arguments to lookup.
296 uint32_t cn_nameiop; /* namei operation */
297 uint32_t cn_flags; /* flags to namei */
298 kauth_cred_t cn_cred; /* credentials */
300 * Shared between lookup and commit routines.
302 char *cn_pnbuf; /* pathname buffer */
303 const char *cn_nameptr; /* pointer to looked up name */
304 size_t cn_namelen; /* length of looked up component */
305 u_long cn_hash; /* hash value of looked up name */
306 size_t cn_consume; /* chars to consume in lookup() */
310 The top half of the structure is used exclusively for the pathname
313 and is initialized by the caller.
314 The semantics of the lookup are affected by the lookup operation
317 and the flags specified in
319 Valid operations are:
321 .Bl -tag -offset indent -width LOOKUP -compact
323 perform name lookup only
325 set up for file creation
327 set up for file deletion
329 set up for file renaming
335 .Em cn-\*[Gt]cn_flags
338 .Bl -tag -offset indent -width LOCKPARENT -compact
342 want parent vnode returned locked
344 name must not be left in name cache (see
347 follow symbolic links
349 do not follow symbolic links (pseudo)
351 mask of operational modifiers
354 No vnode operations may be called from interrupt context.
355 Most operations also require the vnode to be locked on entry.
356 To prevent deadlocks, when acquiring locks on multiple vnodes, the
357 lock of parent directory must be acquired before the lock on the child
360 Vnode operations for a file system type generally should not be
361 called directly from the kernel, but accessed indirectly through the
362 high-level convenience functions discussed in
365 .Bl -tag -width compact
366 .It Fn VOP_LOOKUP "dvp" "vpp" "cnp"
367 Lookup a single pathname component in a given directory.
370 is the locked vnode of the directory to search and
372 is the pathname component to be searched for.
373 If the pathname component is found, the address of the resulting
374 locked vnode is returned in
376 The operation specified in
377 .Em cnp-\*[Gt]cn_nameiop
380 hints about the reason for requesting the lookup and uses it to cache
381 file system type specific information in the vnode for subsequent
384 There are three types of lookups: ".", ".." (ISDOTDOT), and other.
385 If the pathname component being searched for is ".", then
387 has an extra reference added to it and it is returned in
389 If the pathname component being search for is ".." (ISDOTDOT),
391 is unlocked, the ".." node is locked and then
394 This process preserves the protocol of always locking nodes from root
395 downward and prevents deadlock.
396 For other pathname components,
398 checks the accessibility of the directory and searches the name cache
399 for the pathname component.
402 If the pathname is not found in the name cache, the directory is
403 searched for the pathname.
404 The resulting locked vnode is returned in
407 is always returned locked.
416 If the operation is successful
418 is locked and zero is returned.
423 are the same vnode the caller will need to release twice (decrement
424 the reference count) and unlock once.
425 .It Fn VOP_CREATE "dvp" "vpp" "cnp" "vap"
426 Create a new file in a given directory.
429 is the locked vnode of the directory to create the new file in and
431 is the pathname component of the new file.
434 specifies the attributes that the new file should be created with.
435 If the file is successfully created, the address of the resulting
436 locked vnode is returned in
438 and zero is returned.
439 Regardless of the return value, the directory vnode
441 will be unlocked on return.
443 This function is called after
445 when a file is being created.
448 will have set the SAVENAME flag in
449 .Em cnp-\*[Gt]cn_flags
450 to keep the memory pointed to by
451 .Em cnp-\*[Gt]cn_pnbuf
453 If an error is detected when creating the file, this memory is
455 If the file is created successfully it will be released unless the
456 SAVESTART flags in specified in
457 .Em cnp-\*[Gt]cn_flags .
458 .It Fn VOP_MKNOD "dvp" "vpp" "cnp" "vap"
459 Make a new device-special file in a given directory.
462 is the locked vnode of the directory to create the new device-special
465 is the pathname component of the new device-special file.
468 specifies the attributes that the new device-special file should be
470 If the file is successfully created, the address of the resulting
471 locked vnode is returned in
473 and zero is returned.
475 This function is called after
477 when a device-special file is being created.
480 will have set the SAVENAME flag in
481 .Em cnp-\*[Gt]cn_flags
482 to keep the memory pointed to by
483 .Em cnp-\*[Gt]cn_pnbuf
485 If an error is detected when creating the device-special file,
486 this memory is released.
487 If the device-special file is created successfully it will be released
488 unless the SAVESTART flags in specified in
489 .Em cnp-\*[Gt]cn_flags .
490 .It Fn VOP_OPEN "vp" "mode" "cred"
494 is the vnode of the file to open and
496 specifies the access mode required by the calling process.
497 The calling credentials are specified by
499 The access mode is a set of flags, including FREAD, FWRITE,
500 O_NONBLOCK, O_APPEND, etc.
502 must be called before a file can be accessed by a thread.
503 The vnode reference count is incremented.
508 to be locked on entry and will leave it locked on return.
509 If the operation is successful zero is returned, otherwise an
510 appropriate error code is returned.
511 .It Fn VOP_CLOSE "vp" "fflag" "cred"
515 is the vnode of the file to close and
517 specifies the access mode by the calling process.
518 The possible flags are
523 The calling credentials are specified by
526 frees resources allocated by
531 will be locked on entry and should remain locked on return.
532 .It Fn VOP_ACCESS "vp" "mode" "cred"
533 Determine the accessibility (permissions) of the file against the
534 specified credentials.
537 is the vnode of the file to check,
539 is the type of access required and
541 contains the user credentials to check.
544 is a mask which can contain VREAD, VWRITE or VEXEC.
545 If the file is accessible in the specified way, zero is returned,
546 otherwise an appropriate error code is returned.
550 will be locked on entry and should remain locked on return.
551 .It Fn VOP_GETATTR "vp" "vap" "cred"
552 Get specific vnode attributes on a file.
555 is the vnode of the file to get the attributes for.
558 specifies the calling credentials.
560 uses the file system type specific data object
562 to reference the underlying file attributes.
563 Attributes associated with the file are collected by setting the
564 required attribute bits in
565 .Em vap-\*[Gt]va_mask .
566 The attributes are returned in
568 Attributes which are not available are set to the value VNOVAL.
570 For more information on vnode attributes see
572 .It Fn VOP_SETATTR "vp" "vap" "cred"
573 Set specific vnode attributes on a file.
576 is the locked vnode of the file to set the attributes for.
579 specifies the calling credentials.
581 uses the file system type specific data object
583 to reference the underlying file attributes.
584 The new attributes are defined in
586 Attributes associated with the file are set by setting the required
588 .Em vap-\*[Gt]va_mask .
589 Attributes which are not being modified by
591 should be set to the value VNOVAL.
592 If the operation is successful zero is returned, otherwise an
593 appropriate error is returned.
595 For more information on vnode attributes see
597 .It Fn VOP_READ "vp" "uio" "ioflag" "cred"
598 Read the contents of a file.
601 is the vnode of the file to read from,
603 is the location to read the data into,
605 is a set of flags and
607 are the credentials of the calling process.
611 argument is used to give directives and hints to the file system.
612 When attempting a read, the high 16 bits are used to provide a
613 read-ahead hint (in unit of file system blocks) that the file system
615 The low 16 bits are a bit mask which can contain the following flags:
617 .Bl -tag -offset indent -width IO_ALTSEMANTICS -compact
619 do I/O as atomic unit
623 sync I/O file integrity completion
625 underlying node already locked
627 FNDELAY flag set in file table
629 sync I/O data integrity completion
631 use alternate I/O semantics
633 operate on regular data
635 operate on extended attributes
637 do not buffer data in the kernel
640 Zero is returned on success, otherwise an error is returned.
641 The vnode should be locked on entry and remains locked on exit.
642 .It Fn VOP_WRITE "vp" "uio" "ioflag" "cred"
646 is the vnode of the file to write to,
648 is the location of the data to write,
650 is a set of flags and
652 are the credentials of the calling process.
656 argument is used to give directives and hints to the file system.
657 The low 16 bits are a bit mask which can contain the same flags as
660 Zero is returned on success, otherwise an error is returned.
661 The vnode should be locked on entry and remains locked on exit.
662 .It Fn VOP_IOCTL "vp" "command" "data" "fflag" "cred"
663 Perform device-specific I/O.
666 is the locked vnode of the file, normally representing a device.
669 specifies the device-specific operation to perform and
671 provides extra data for the specified operation.
677 is the caller's credentials.
678 If the operation is successful, zero is
679 returned, otherwise an appropriate error code is returned.
681 Most file systems do not supply a function for
683 This function implements the
686 .It Fn VOP_FCNTL "vp" "command" "data" "fflag" "cred"
687 Perform file control.
690 is the locked vnode of the file.
693 specifies the operation to perform and
695 provides extra data for the specified operation.
701 is the caller's credentials.
702 If the operation is successful, zero is returned, otherwise an
703 appropriate error code is returned.
704 .It Fn VOP_POLL "vp" "events"
705 Test if a poll event has occurred.
708 is the vnode of the file to poll.
709 It returns any events of interest as specified by
711 that may have occurred for the file.
714 is a set of flags as specified by
716 .It Fn VOP_KQFILTER "vp" "kn"
721 If the operation is successful zero is returned, otherwise an
722 appropriate error code is returned.
723 .It Fn VOP_REVOKE "vp" "flags"
724 Eliminate all activity associated with the vnode
729 If REVOKEALL is set in
731 all vnodes aliased to the vnode
734 If the operation is successful zero is returned, otherwise an
735 appropriate error is returned.
736 .It Fn VOP_MMAP "vp" "prot" "cred"
737 Inform file system that
739 is in the process of being memory mapped.
742 specifies the vm access protection the vnode is going to be mapped with.
745 is the caller's credentials.
746 If the file system allows the memory mapping, zero is returned, otherwise
747 an appropriate error code is returned.
749 Most file systems do not supply a function for
753 to default for success.
754 Only file systems which do not integrate with the page cache at all
755 typically want to disallow memory mapping.
756 .It Fn VOP_FSYNC "vp" "cred" "flags" "offlo" "offhi"
757 Flush pending data buffers for a file to disk.
760 is the locked vnode of the file for flush.
763 is the caller's credentials.
767 If FSYNC_WAIT is specified in
769 the function should wait for I/O to complete before returning.
774 specify the range of file to flush.
775 If the operation is successful zero is returned, otherwise an
776 appropriate error code is returned.
778 This function implements the
783 .It Fn VOP_SEEK "vp" "oldoff" "newoff" "cred"
784 Test if the file is seekable for the specified offset
788 is the locked vnode of the file to test.
789 For most file systems this function simply tests if
794 is less than zero, the function returns error code EINVAL.
795 .It Fn VOP_REMOVE "dvp" "vp" "cnp"
799 is the locked vnode of the directory to remove the file from and
801 is the locked vnode of the file to remove.
804 is the pathname component about the file to remove.
805 If the operation is successful zero is returned, otherwise an
806 appropriate error code is returned.
811 are locked on entry and are to be unlocked before returning.
812 .It Fn VOP_LINK "dvp" "vp" "cnp"
816 is the locked node of the directory to create the new link and
818 is the vnode of the file to be linked.
821 is the pathname component of the new link.
822 If the operation is successful zero is returned, otherwise an error
826 should be locked on entry and will be released and unlocked on return.
829 should not be locked on entry and will remain unlocked on return.
830 .It Fn VOP_RENAME "fdvp" "fvp" "fcnp" "tdvp" "tvp" "tcnp"
834 is the vnode of the old parent directory containing in the file to be
837 is the vnode of the file to be renamed.
840 is the pathname component about the file to be renamed.
843 is the vnode of the new directory of the target file and
845 is the vnode of the target file (if it exists).
848 is the pathname component about the file's new name.
849 If the operation is successful zero is returned, otherwise and error
852 The source directory and file vnodes should be unlocked and their
853 reference counts should be incremented before entry.
854 The target directory and file vnodes should both be locked on entry.
856 updates the reference counts prior to returning.
857 .It Fn VOP_MKDIR "dvp" "vpp" "cnp" "vap"
858 Make a new directory in a given directory.
861 is the locked vnode of the directory to create the new directory in and
863 is the pathname component of the new directory.
866 specifies the attributes that the new directory should be created
868 If the file is successfully created, the address of the resulting
869 locked vnode is returned in
871 and zero is returned.
873 This function is called after
875 when a directory is being created.
878 will have set the SAVENAME flag in
879 .Em cnp-\*[Gt]cn_flags
880 to keep the memory pointed to by
881 .Em cnp-\*[Gt]cn_pnbuf
883 If an error is detected when creating the directory, this memory is
885 If the directory is created successfully it will be released unless
886 the SAVESTART flags in specified in
887 .Em cnp-\*[Gt]cn_flags .
888 .It Fn VOP_RMDIR "dvp" "vp" "cnp"
889 Remove a directory in a given directory.
892 is the locked vnode of the directory to remove the directory from and
894 is the locked vnode of the directory to remove.
897 is the pathname component of the directory.
898 Zero is returned on success, otherwise an error code is returned.
903 should be locked on entry and will be released and unlocked on return.
904 .It Fn VOP_SYMLINK "dvp" "vpp" "cnp" "vap" "target"
905 Create a symbolic link in a given directory.
908 is the locked vnode of the directory to create the symbolic link in
911 is the pathname component of the symbolic link.
914 specifies the attributes that the symbolic link should be created
917 specifies the pathname of the target of the symbolic link.
918 If the symbolic link is successfully created, the address of the
919 resulting locked vnode is returned in
921 and zero is returned.
923 This function is called after
925 when a symbolic link is being created.
928 will have set the SAVENAME flag in
929 .Em cnp-\*[Gt]cn_flags
930 to keep the memory pointed to by
931 .Em cnp-\*[Gt]cn_pnbuf
933 If an error is detected when creating the symbolic link, this memory
935 If the symbolic link is created successfully it will be released
936 unless the SAVESTART flags in specified in
937 .Em cnp-\*[Gt]cn_flags .
938 .It Fn VOP_READDIR "vp" "uio" "cred" "eofflag" "cookies" "ncookies"
939 Read directory entry.
942 is the vnode of the directory to read the contents of and
944 is the destination location to read the contents into.
947 is the caller's credentials.
950 is the pointer to a flag which is set by
952 to indicate an end-of-file condition.
957 the end-of-file condition is not returned.
962 specify the addresses for the list and number of directory seek
963 cookies generated for NFS.
970 if they aren't required to be returned by
972 The directory contents are read into struct dirent structures and
973 .Fa uio-\*[Gt]uio_offset
974 is set to the offset of the next unread directory entry.
975 This offset may be used in a following invocation to continue a
976 sequential read of the directory contents.
977 If the operation is successful zero is returned, otherwise an
978 appropriate error code is returned.
980 The directory should be locked on entry and will remain locked on
987 are supplied, one cookie should be returned per directory entry.
988 The value of the cookie for each directory entry should be the offset
989 within the directory where the on-disk version of the following
990 directory entry starts.
991 That is, for each directory entry
993 the corresponding cookie should refer to the offset of directory entry
998 array must be allocated by the callee using the M_TEMP malloc type as
1001 must be able to free the allocation.
1002 .It Fn VOP_READLINK "vp" "uio" "cred"
1003 Read the contents of a symbolic link.
1006 is the locked vnode of the symlink and
1008 is the destination location to read the contents into.
1011 is the credentials of the caller.
1012 If the operation is successful zero is returned, otherwise an error
1015 The vnode should be locked on entry and will remain locked on return.
1016 .It Fn VOP_ABORTOP "dvp" "cnp"
1017 Abort pending operation on vnode
1019 and free resources allocated in
1022 This operation is rarely implemented in file systems and
1024 is typically used instead.
1025 .It Fn VOP_INACTIVE "vp"
1026 Release the inactive vnode.
1028 is called when the kernel is no longer using the vnode.
1029 This may be because the reference count reaches zero or it may be that
1030 the file system is being forcibly unmounted while there are open
1032 It can be used to reclaim space for open but deleted files.
1035 is the locked vnode to be released.
1036 If the operation is successful zero is returned, otherwise an
1037 appropriate error code is returned.
1040 must be locked on entry, and will be unlocked on return.
1041 .It Fn VOP_RECLAIM "vp"
1042 Reclaim the vnode for another file system.
1044 is called when a vnode is being reused for a different file system.
1045 Any file system specific resources associated with the vnode should be
1049 is the vnode to be reclaimed.
1050 If the operation is successful zero is returned, otherwise an
1051 appropriate error code is returned.
1054 should not be locked on entry, and will remain unlocked on return.
1055 .It Fn VOP_LOCK "vp" "flags"
1056 Sleep until vnode lock is free.
1059 is the vnode of the file to be locked.
1065 If the operation is successful zero is returned, otherwise an
1066 appropriate error code is returned.
1068 is used to serialize access to the file system such as to prevent two
1069 writes to the same file from happening at the same time.
1070 Kernel code should use
1072 to lock a vnode rather than calling
1075 .It Fn VOP_UNLOCK "vp" "flags"
1076 Wake up process sleeping on lock.
1079 is the vnode of the file to be unlocked.
1085 If the operation is successful zero is returned, otherwise an
1086 appropriate error code is returned.
1088 is used to serialize access to the file system such as to prevent two
1089 writes to the same file from happening at the same time.
1090 .It Fn VOP_ISLOCKED "vp"
1094 Possible return values are
1097 or 0 for lock held exclusively by the calling thread, shared lock held
1098 by anyone or unlocked, respectively.
1099 .It Fn VOP_BMAP "vp" "bn" "vpp" "bnp" "runp"
1100 Convert the logical block number
1102 of a file specified by vnode
1104 to its physical block number on the disk.
1105 The physical block is returned in
1107 In case the logical block is not allocated, \-1 is used.
1113 the vnode of the device vnode for the file system is
1114 returned in the address specified by
1120 the number of contiguous blocks starting from the next block after
1121 the queried block will be returned in
1123 .It Fn VOP_PRINT "vp"
1124 Print debugging information.
1127 is the vnode to print.
1128 If the operation is successful zero is returned, otherwise an
1129 appropriate error code is returned.
1130 .It Fn VOP_PATHCONF "vp" "name" "retval"
1138 is the locked vnode to get information about.
1141 specified the type of information to return.
1142 The information is returned in the address specified by
1148 .Bl -tag -offset indent -width _PC_CHOWN_RESTRICTED -compact
1150 return the maximum number of links to a file
1152 return the maximum number of bytes in a file name
1154 return the maximum number of bytes in a pathname
1156 return the maximum number of bytes which will be written atomically to
1158 .It _PC_CHOWN_RESTRICTED
1159 return 1 if appropriate privileges are required for the
1161 system call, otherwise zero
1163 return if file names longer than KERN_NAME_MAX are truncated
1170 is set to the specified value and zero is returned, otherwise an
1171 appropriate error is returned.
1172 .It Fn VOP_ADVLOCK "vp" "id" "op" "fl" "flags"
1173 Manipulate Advisory record locks on a vnode.
1176 is the vnode on which locks are manipulated.
1179 is the id token which is changing the lock and
1183 operation to perform.
1186 .Bl -tag -offset indent -width F_UNLCK -compact
1190 get the first conflicted lock
1197 is a description of the lock.
1200 The caller should add the current file offset to
1201 fl-\*[Gt]l_start beforehand.
1210 is the set of flags.
1213 .Bl -tag -offset indent -width F_FLOCK -compact
1215 wait until lock is granted
1221 use POSIX semantics for lock
1224 If the operation is successful zero is returned, otherwise an
1225 appropriate error is returned.
1226 .It Fn VOP_LEASE "vp" "cred" "flags"
1227 Validate vnode credentials and operation type.
1230 is the locked vnode of the file to validate credentials
1234 specifies the operation flags.
1235 If the operation is successful zero is returned, otherwise an
1236 appropriate error code is returned.
1237 The vnode must be locked on entry and remains locked on return.
1238 .It Fn VOP_WHITEOUT "dvp" "cnp" "flags"
1239 Whiteout pathname component in directory with vnode
1243 specifies the pathname component to whiteout.
1244 .It Fn VOP_GETPAGES "vp" "offset" "m" "count" "centeridx" "access_type" "advice" "flags"
1245 Read VM pages from file.
1248 is the locked vnode to read the VM pages from.
1251 is offset in the file to start accessing and
1253 is an array of VM pages.
1256 points a variable that specifies the number of pages to read.
1257 If the operation is successful zero is returned, otherwise an
1258 appropriate error code is returned.
1259 If PGO_LOCKED is specified in
1262 might return less pages than requested.
1263 In that case, the variable pointed to by
1267 This function is primarily used by the page-fault handing mechanism.
1268 .It Fn VOP_PUTPAGES "vp" "offlo" "offhi" "flags"
1269 Write modified (dirty) VM pages to file.
1272 is the vnode to write the VM pages to.
1273 The vnode's vm object lock
1274 .Va ( v_uobj.vmobjlock )
1275 must be held by the caller and will be released upon return.
1280 specify the range of VM pages to write.
1283 is given as 0, all pages at and after the start offset
1290 controls the behavior of the routine and takes the vm pager's
1292 .Dv ( PGO_ -prefixed ) .
1293 If the operation is successful zero is returned, otherwise an
1294 appropriate error code is returned.
1296 The function is primarily used by the pageout handling mechanism and
1297 is commonly implemented indirectly
1304 .It Fn VOP_STRATEGY "vp" "bp"
1305 Read/write a file system buffer.
1308 is the vnode to read/write to.
1311 is the buffer to be read or written.
1313 will either read or write data to the file depending on the value of
1314 .Em bp-\*[Gt]b_flags .
1315 If the operation is successful zero is returned, otherwise an
1316 appropriate error code is returned.
1317 .It Fn VOP_BWRITE "bp"
1318 Write a file system buffer.
1321 specifies the buffer to be written.
1322 If the operation is successful zero is returned, otherwise an
1323 appropriate error code is returned.
1324 .It Fn VOP_GETEXTATTR "vp" "attrnamespace" "name" "uio" "size" "cred"
1325 Get an extended attribute.
1328 is the locked vnode of the file or directory from which to retrieve the
1332 specifies the extended attribute namespace.
1335 is a nul-terminated character string naming the attribute to retrieve.
1340 specifies where the extended attribute value is to be written.
1345 will contain the number of bytes required to read all of
1346 the attribute data upon return.
1353 is not, and vice versa.
1356 specifies the user credentials to use when authorizing the request.
1357 .It Fn VOP_SETEXTATTR "vp" "attrnamespace" "name" "uio" "cred"
1358 Set an extended attribute.
1361 is the locked vnode of the file or directory to which to store the
1365 specifies the extended attribute namespace.
1368 is a nul-terminated character string naming the attribute to store.
1371 specifies the source of the extended attribute data.
1374 specifies the user credentials to use when authorizing the request.
1375 .It Fn VOP_LISTEXTATTR "vp" "attrnamespace" "uio" "size" "cred"
1376 Retrieve the list of extended attributes.
1379 is the locked vnode of the file or directory whose attributes are to be listed.
1382 specifies the extended attribute namespace.
1387 specifies where the extended attribute list is to be written.
1392 will contain the number of bytes required to read all of
1393 the attribute names upon return.
1400 is not, and vice versa.
1403 specifies the user credentials to use when authorizing the request.
1408 Access for the specified operation is denied.
1412 attempt to read from an illegal offset in the directory; unrecognized
1415 a read error occurred while reading the directory or reading the
1416 contents of a symbolic link
1417 .It Bq Er EJUSTRETURN
1418 A CREATE or RENAME operation would be successful.
1420 The requested attribute is not defined for this vnode.
1422 The component was not found in the directory.
1424 The file system is full.
1426 The vnode does not represent a directory.
1428 attempt to remove a directory which is not empty
1430 an attempt was made to change an immutable file
1432 the file system is read-only
1444 The vnode operations vector, its functions and the corresponding