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