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