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