xref: /netbsd-src/share/man/man9/vnodeops.9 (revision 7fa608457b817eca6e0977b37f758ae064f3c99c)
1.\"     $NetBSD: vnodeops.9,v 1.68 2007/08/24 09:57:03 pooka Exp $
2.\"
3.\" Copyright (c) 2001, 2005, 2006 The NetBSD Foundation, Inc.
4.\" All rights reserved.
5.\"
6.\" This code is derived from software contributed to The NetBSD Foundation
7.\" by Gregory McGarry.
8.\"
9.\" Redistribution and use in source and binary forms, with or without
10.\" modification, are permitted provided that the following conditions
11.\" are met:
12.\" 1. Redistributions of source code must retain the above copyright
13.\"    notice, this list of conditions and the following disclaimer.
14.\" 2. Redistributions in binary form must reproduce the above copyright
15.\"    notice, this list of conditions and the following disclaimer in the
16.\"    documentation and/or other materials provided with the distribution.
17.\" 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 August 24, 2007
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" "kauth_cred_t cred" \
111"struct lwp *l"
112.Ft int
113.Fn VOP_CLOSE "struct vnode *vp" "int fflag" "kauth_cred_t cred" \
114"struct lwp *l"
115.Ft int
116.Fn VOP_ACCESS "struct vnode *vp" "int mode" "kauth_cred_t cred" \
117"struct lwp *l"
118.Ft int
119.Fn VOP_GETATTR "struct vnode *vp" "struct vattr *vap" \
120"kauth_cred_t cred" "struct lwp *l"
121.Ft int
122.Fn VOP_SETATTR "struct vnode *vp" "struct vattr *vap" \
123"kauth_cred_t cred" "struct lwp *l"
124.Ft int
125.Fn VOP_READ "struct vnode *vp" "struct uio *uio" "int ioflag" \
126"kauth_cred_t cred"
127.Ft int
128.Fn VOP_WRITE "struct vnode *vp" "struct uio *uio" "int ioflag" \
129"kauth_cred_t cred"
130.Ft int
131.Fn VOP_IOCTL "struct vnode *vp" "u_long command" "void *data" \
132"int fflag" "kauth_cred_t cred" "struct lwp *l"
133.Ft int
134.Fn VOP_FCNTL "struct vnode *vp" "u_int command" "void *data" \
135"int fflag" "kauth_cred_t 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" "vm_prot_t prot" \
144"kauth_cred_t cred" "struct lwp *l"
145.Ft int
146.Fn VOP_FSYNC "struct vnode *vp" "kauth_cred_t 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"kauth_cred_t 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 *fvp" \
159"struct componentname *fcnp" "struct vnode *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"kauth_cred_t cred" "int *eofflag" "off_t **cookies" "int *ncookies"
173.Ft int
174.Fn VOP_READLINK "struct vnode *vp" "struct uio *uio" "kauth_cred_t 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" "kauth_cred_t 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 offhi" \
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" "kauth_cred_t cred" "struct lwp *l"
216.Ft int
217.Fn VOP_SETEXTATTR "struct vnode *vp" "int attrnamespace" "const char *name" \
218"struct uio *uio" "kauth_cred_t cred" "struct lwp *l"
219.Ft int
220.Fn VOP_LISTEXTATTR "struct vnode *vp" "int attrnamespace" "struct uio *uio" \
221"size_t *size" "kauth_cred_t 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.
304It 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  lwp *cn_lwp;    /* lwp requesting lookup */
315        kauth_cred_t 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 NOCACHE
361name must not be left in name cache (see
362.Xr namecache 9 )
363.It FOLLOW
364follow symbolic links
365.It NOFOLLOW
366do not follow symbolic links (pseudo)
367.It MODMASK
368mask of operational modifiers
369.El
370.Pp
371No vnode operations may be called from interrupt context.
372Most operations also require the vnode to be locked on entry.
373To prevent deadlocks, when acquiring locks on multiple vnodes, the
374lock of parent directory must be acquired before the lock on the child
375directory.
376.Pp
377Vnode operations for a file system type generally should not be
378called directly from the kernel, but accessed indirectly through the
379high-level convenience functions discussed in
380.Xr vnsubr 9 .
381.Sh FUNCTIONS
382.Bl -tag -width compact
383.It Fn VOP_LOOKUP "dvp" "vpp" "cnp"
384Lookup a single pathname component in a given directory.
385The argument
386.Fa dvp
387is the locked vnode of the directory to search and
388.Fa cnp
389is the pathname component to be searched for.
390If the pathname component is found, the address of the resulting
391locked vnode is returned in
392.Fa vpp .
393The operation specified in
394.Em cnp-\*[Gt]cn_nameiop
395gives
396.Fn VOP_LOOKUP
397hints about the reason for requesting the lookup and uses it to cache
398file system type specific information in the vnode for subsequent
399operations.
400.Pp
401There are three types of lookups: ".", ".." (ISDOTDOT), and other.
402If the pathname component being searched for is ".", then
403.Fa dvp
404has an extra reference added to it and it is returned in
405.Fa *vpp .
406If the pathname component being search for is ".." (ISDOTDOT),
407.Fa dvp
408is unlocked, the ".." node is locked and then
409.Fa dvp
410is relocked.
411This process preserves the protocol of always locking nodes from root
412downward and prevents deadlock.
413For other pathname components,
414.Fn VOP_LOOKUP
415checks the accessibility of the directory and searches the name cache
416for the pathname component.
417See
418.Xr namecache 9 .
419If the pathname is not found in the name cache, the directory is
420searched for the pathname.
421The resulting locked vnode is returned in
422.Fa vpp .
423.Fa dvp
424is always returned locked.
425.Pp
426On failure
427.Fa *vpp
428is
429.Dv NULL ,
430and
431.Fa *dvp
432is left locked.
433If the operation is successful
434.Fa *vpp
435is locked and zero is returned.
436Typically, if
437.Fa *vpp
438and
439.Fa dvp
440are the same vnode the caller will need to release twice (decrement
441the reference count) and unlock once.
442.It Fn VOP_CREATE "dvp" "vpp" "cnp" "vap"
443Create a new file in a given directory.
444The argument
445.Fa dvp
446is the locked vnode of the directory to create the new file in and
447.Fa cnp
448is the pathname component of the new file.
449The argument
450.Fa vap
451specifies the attributes that the new file should be created with.
452If the file is successfully created, the address of the resulting
453locked vnode is returned in
454.Fa vpp
455and zero is returned.
456Regardless of the return value, the directory vnode
457.Fa dvp
458will be unlocked on return.
459.Pp
460This function is called after
461.Fn VOP_LOOKUP
462when a file is being created.
463Normally,
464.Fn VOP_LOOKUP
465will have set the SAVENAME flag in
466.Em cnp-\*[Gt]cn_flags
467to keep the memory pointed to by
468.Em cnp-\*[Gt]cn_pnbuf
469valid.
470If an error is detected when creating the file, this memory is
471released.
472If the file is created successfully it will be released unless the
473SAVESTART flags in specified in
474.Em cnp-\*[Gt]cn_flags .
475.It Fn VOP_MKNOD "dvp" "vpp" "cnp" "vap"
476Make a new device-special file in a given directory.
477The argument
478.Fa dvp
479is the locked vnode of the directory to create the new device-special
480file in and
481.Fa cnp
482is the pathname component of the new device-special file.
483The argument
484.Fa vap
485specifies the attributes that the new device-special file should be
486created with.
487If the file is successfully created, the address of the resulting
488locked vnode is returned in
489.Fa vpp
490and zero is returned.
491.Pp
492This function is called after
493.Fn VOP_LOOKUP
494when a device-special file is being created.
495Normally,
496.Fn VOP_LOOKUP
497will have set the SAVENAME flag in
498.Em cnp-\*[Gt]cn_flags
499to keep the memory pointed to by
500.Em cnp-\*[Gt]cn_pnbuf
501valid.
502If an error is detected when creating the device-special file,
503this memory is released.
504If the device-special file is created successfully it will be released
505unless the SAVESTART flags in specified in
506.Em cnp-\*[Gt]cn_flags .
507.It Fn VOP_OPEN "vp" "mode" "cred" "l"
508Open a file.
509The argument
510.Fa vp
511is the vnode of the file to open and
512.Fa mode
513specifies the access mode required by the calling process.
514The calling process and its credentials are specified by
515.Fa l
516and
517.Fa cred
518respectively.
519The access mode is a set of flags, including FREAD, FWRITE,
520O_NONBLOCK, O_APPEND, etc.
521.Fn VOP_OPEN
522must be called before a file can be accessed by a thread.
523The vnode reference count is incremented.
524.Pp
525.Fn VOP_OPEN
526expects the vnode
527.Fa vp
528to be locked on entry and will leave it locked on return.
529If the operation is successful zero is returned, otherwise an
530appropriate error code is returned.
531.It Fn VOP_CLOSE "vp" "fflag" "cred" "l"
532Close a file.
533The argument
534.Fa vp
535is the vnode of the file to close and
536.Fa fflag
537specifies the access mode by the calling process.
538The possible flags are
539.Dv FREAD ,
540.Dv FWRITE
541and
542.Dv FNONBLOCK .
543The calling process and its credentials are specified by
544.Fa l
545and
546.Fa cred
547respectively.
548.Fn VOP_CLOSE
549frees resources allocated by
550.Fn VOP_OPEN .
551.Pp
552The vnode
553.Fa vp
554will be locked on entry and should remain locked on return.
555.It Fn VOP_ACCESS "vp" "mode" "cred" "l"
556Determine the accessibility (permissions) of the file against the
557specified credentials.
558The argument
559.Fa vp
560is the vnode of the file to check,
561.Fa mode
562is the type of access required,
563.Fa cred
564contains the user credentials to check and
565.Fa l
566is the process which is checking the credentials.
567The argument
568.Fa mode
569is a mask which can contain VREAD, VWRITE or VEXEC.
570If the file is accessible in the specified way, zero is returned,
571otherwise an appropriate error code is returned.
572.Pp
573The vnode
574.Fa vp
575will be locked on entry and should remain locked on return.
576.It Fn VOP_GETATTR "vp" "vap" "cred" "l"
577Get specific vnode attributes on a file.
578The argument
579.Fa vp
580is the vnode of the file to get the attributes for.
581The arguments
582.Fa l
583and
584.Fa cred
585specifies the calling process and its credentials respectively.
586.Fn VOP_GETATTR
587uses the file system type specific data object
588.Em vp-\*[Gt]v_data
589to reference the underlying file attributes.
590Attributes associated with the file are collected by setting the
591required attribute bits in
592.Em vap-\*[Gt]va_mask .
593The attributes are returned in
594.Fa vap .
595Attributes which are not available are set to the value VNOVAL.
596.Pp
597For more information on vnode attributes see
598.Xr vattr 9 .
599.It Fn VOP_SETATTR "vp" "vap" "cred" "l"
600Set specific vnode attributes on a file.
601The argument
602.Fa vp
603is the locked vnode of the file to set the attributes for.
604The arguments
605.Fa l
606and
607.Fa cred
608specifies the calling process and its credentials respectively.
609.Fn VOP_SETATTR
610uses the file system type specific data object
611.Em vp-\*[Gt]v_data
612to reference the underlying file attributes.
613The new attributes are defined in
614.Fa vap .
615Attributes associated with the file are set by setting the required
616attribute bits in
617.Em vap-\*[Gt]va_mask .
618Attributes which are not being modified by
619.Fn VOP_SETATTR
620should be set to the value VNOVAL.
621If the operation is successful zero is returned, otherwise an
622appropriate error is returned.
623.Pp
624For more information on vnode attributes see
625.Xr vattr 9 .
626.It Fn VOP_READ "vp" "uio" "ioflag" "cred"
627Read the contents of a file.
628The argument
629.Fa vp
630is the vnode of the file to read from,
631.Fa uio
632is the location to read the data into,
633.Fa ioflag
634is a set of flags and
635.Fa cred
636are the credentials of the calling process.
637.Pp
638The
639.Fa ioflag
640argument is used to give directives and hints to the file system.
641When attempting a read, the high 16 bits are used to provide a
642read-ahead hint (in unit of file system blocks) that the file system
643should attempt.
644The low 16 bits are a bit mask which can contain the following flags:
645.Pp
646.Bl -tag -offset indent -width IO_ALTSEMANTICS -compact
647.It IO_UNIT
648do I/O as atomic unit
649.It IO_APPEND
650append write to end
651.It IO_SYNC
652sync I/O file integrity completion
653.It IO_NODELOCKED
654underlying node already locked
655.It IO_NDELAY
656FNDELAY flag set in file table
657.It IO_DSYNC
658sync I/O data integrity completion
659.It IO_ALTSEMANTICS
660use alternate I/O semantics
661.It IO_NORMAL
662operate on regular data
663.It IO_EXT
664operate on extended attributes
665.It IO_DIRECT
666do not buffer data in the kernel
667.El
668.Pp
669Zero is returned on success, otherwise an error is returned.
670The vnode should be locked on entry and remains locked on exit.
671.It Fn VOP_WRITE "vp" "uio" "ioflag" "cred"
672Write to a file.
673The argument
674.Fa vp
675is the vnode of the file to write to,
676.Fa uio
677is the location of the data to write,
678.Fa ioflag
679is a set of flags and
680.Fa cred
681are the credentials of the calling process.
682.Pp
683The
684.Fa ioflag
685argument is used to give directives and hints to the file system.
686The low 16 bits are a bit mask which can contain the same flags as
687.Fn VOP_READ .
688.Pp
689Zero is returned on success, otherwise an error is returned.
690The vnode should be locked on entry and remains locked on exit.
691.It Fn VOP_IOCTL "vp" "command" "data" "fflag" "cred" "l"
692Perform device-specific I/O.
693The argument
694.Fa vp
695is the locked vnode of the file, normally representing a device.
696The argument
697.Fa command
698specifies the device-specific operation to perform and
699.Fa cnp
700provides extra data for the specified operation.
701The argument
702.Fa fflags
703is a set of flags.
704The argument
705.Fa cred
706is the caller's credentials and
707.Fa l
708the calling process.
709If the operation is successful, zero is
710returned, otherwise an appropriate error code is returned.
711.Pp
712Most file systems do not supply a function for
713.Fn VOP_IOCTL .
714This function implements the
715.Xr ioctl 2
716system call.
717.It Fn VOP_FCNTL "vp" "command" "data" "fflag" "cred" "l"
718Perform file control.
719The argument
720.Fa vp
721is the locked vnode of the file.
722The argument
723.Fa command
724specifies the operation to perform and
725.Fa cnp
726provides extra data for the specified operation.
727The argument
728.Fa fflags
729is a set of flags.
730The argument
731.Fa cred
732is the caller's credentials and
733.Fa l
734the calling process.
735If the operation is successful, zero is returned, otherwise an
736appropriate error code is returned.
737.It Fn VOP_POLL "vp" "events" "l"
738Test if a poll event has occurred.
739The argument
740.Fa vp
741is the vnode of the file to poll and
742.Fa l
743is the calling process.
744It returns any events of interest as specified by
745.Fa events
746that may have occurred for the file.
747The argument
748.Fa events
749is a set of flags as specified by
750.Xr poll 2 .
751.It Fn VOP_KQFILTER "vp" "kn"
752Register a knote
753.Fa kn
754with the vnode
755.Fa vn .
756If the operation is successful zero is returned, otherwise an
757appropriate error code is returned.
758.It Fn VOP_REVOKE "vp" "flags"
759Eliminate all activity associated with the vnode
760.Fa vp .
761The argument
762.Fa flags
763is a set of flags.
764If REVOKEALL is set in
765.Fa flags
766all vnodes aliased to the vnode
767.Fa vp
768are also eliminated.
769If the operation is successful zero is returned, otherwise an
770appropriate error is returned.
771.It Fn VOP_MMAP "vp" "prot" "cred" "l"
772Inform file system that
773.Fa vp
774is in the process of being memory mapped.
775The argument
776.Fa prot
777specifies the vm access protection the vnode is going to be mapped with.
778The argument
779.Fa cred
780is the caller's credentials and
781.Fa l
782the calling process requesting the map.
783If the file system allows the memory mapping, zero is returned, otherwise
784an appropriate error code is returned.
785.Pp
786Most file systems do not supply a function for
787.Fn VOP_MMAP
788and use
789.Fn genfs_mmap
790to default for success.
791Only file systems which do not integrate with the page cache at all
792typically want to disallow memory mapping.
793.It Fn VOP_FSYNC "vp" "cred" "flags" "offlo" "offhi" "l"
794Flush pending data buffers for a file to disk.
795The argument
796.Fa vp
797is the locked vnode of the file for flush.
798The argument
799.Fa cred
800is the caller's credentials and
801.Fa l
802the calling process.
803The argument
804.Fa flags
805is a set of flags.
806If FSYNC_WAIT is specified in
807.Fa flags ,
808the function should wait for I/O to complete before returning.
809The argument
810.Fa offlo
811and
812.Fa offhi
813specify the range of file to flush.
814If the operation is successful zero is returned, otherwise an
815appropriate error code is returned.
816.Pp
817This function implements the
818.Xr sync 2
819and
820.Xr fsync 2
821system calls.
822.It Fn VOP_SEEK "vp" "oldoff" "newoff" "cred"
823Test if the file is seekable for the specified offset
824.Fa newoff .
825The argument
826.Fa vp
827is the locked vnode of the file to test.
828For most filesystems this function simply tests if
829.Fa newoff
830is valid.
831If the specified
832.Fa newoff
833is less than zero, the function returns error code EINVAL.
834.It Fn VOP_REMOVE "dvp" "vp" "cnp"
835Remove a file.
836The argument
837.Fa dvp
838is the locked vnode of the directory to remove the file from and
839.Fa vp
840is the locked vnode of the file to remove.
841The argument
842.Fa cnp
843is the pathname component about the file to remove.
844If the operation is successful zero is returned, otherwise an
845appropriate error code is returned.
846Both
847.Fa dvp
848and
849.Fa vp
850are locked on entry and are to be unlocked before returning.
851.It Fn VOP_LINK "dvp" "vp" "cnp"
852Link to a file.
853The argument
854.Fa dvp
855is the locked node of the directory to create the new link and
856.Fa vp
857is the vnode of the file to be linked.
858The argument
859.Fa cnp
860is the pathname component of the new link.
861If the operation is successful zero is returned, otherwise an error
862code is returned.
863The directory vnode
864.Fa dvp
865should be locked on entry and will be released and unlocked on return.
866The vnode
867.Fa vp
868should not be locked on entry and will remain unlocked on return.
869.It Fn VOP_RENAME "fdvp" "fvp" "fcnp" "tdvp" "tvp" "tcnp"
870Rename a file.
871The argument
872.Fa fdvp
873is the vnode of the old parent directory containing in the file to be
874renamed and
875.Fa fvp
876is the vnode of the file to be renamed.
877The argument
878.Fa fcnp
879is the pathname component about the file to be renamed.
880The argument
881.Fa tdvp
882is the vnode of the new directory of the target file and
883.Fa tvp
884is the vnode of the target file (if it exists).
885The argument
886.Fa tcnp
887is the pathname component about the file's new name.
888If the operation is successful zero is returned, otherwise and error
889code is returned.
890.Pp
891The source directory and file vnodes should be unlocked and their
892reference counts should be incremented before entry.
893The target directory and file vnodes should both be locked on entry.
894.Fn VOP_RENAME
895updates the reference counts prior to returning.
896.It Fn VOP_MKDIR "dvp" "vpp" "cnp" "vap"
897Make a new directory in a given directory.
898The argument
899.Fa dvp
900is the locked vnode of the directory to create the new directory in and
901.Fa cnp
902is the pathname component of the new directory.
903The argument
904.Fa vap
905specifies the attributes that the new directory should be created
906with.
907If the file is successfully created, the address of the resulting
908locked vnode is returned in
909.Fa vpp
910and zero is returned.
911.Pp
912This function is called after
913.Fn VOP_LOOKUP
914when a directory is being created.
915Normally,
916.Fn VOP_LOOKUP
917will have set the SAVENAME flag in
918.Em cnp-\*[Gt]cn_flags
919to keep the memory pointed to by
920.Em cnp-\*[Gt]cn_pnbuf
921valid.
922If an error is detected when creating the directory, this memory is
923released.
924If the directory is created successfully it will be released unless
925the SAVESTART flags in specified in
926.Em cnp-\*[Gt]cn_flags .
927.It Fn VOP_RMDIR "dvp" "vp" "cnp"
928Remove a directory in a given directory.
929The argument
930.Fa dvp
931is the locked vnode of the directory to remove the directory from and
932.Fa vp
933is the locked vnode of the directory to remove.
934The argument
935.Fa cnp
936is the pathname component of the directory.
937Zero is returned on success, otherwise an error code is returned.
938Both
939.Fa dvp
940and
941.Fa vp
942should be locked on entry and will be released and unlocked on return.
943.It Fn VOP_SYMLINK "dvp" "vpp" "cnp" "vap" "target"
944Create a symbolic link in a given directory.
945The argument
946.Fa dvp
947is the locked vnode of the directory to create the symbolic link in
948and
949.Fa cnp
950is the pathname component of the symbolic link.
951The argument
952.Fa vap
953specifies the attributes that the symbolic link should be created
954with and
955.Fa target
956specifies the pathname of the target of the symbolic link.
957If the symbolic link is successfully created, the address of the
958resulting locked vnode is returned in
959.Fa vpp
960and zero is returned.
961.Pp
962This function is called after
963.Fn VOP_LOOKUP
964when a symbolic link is being created.
965Normally,
966.Fn VOP_LOOKUP
967will have set the SAVENAME flag in
968.Em cnp-\*[Gt]cn_flags
969to keep the memory pointed to by
970.Em cnp-\*[Gt]cn_pnbuf
971valid.
972If an error is detected when creating the symbolic link, this memory
973is released.
974If the symbolic link is created successfully it will be released
975unless the SAVESTART flags in specified in
976.Em cnp-\*[Gt]cn_flags .
977.It Fn VOP_READDIR "vp" "uio" "cred" "eofflag" "cookies" "ncookies"
978Read directory entry.
979The argument
980.Fa vp
981is the vnode of the directory to read the contents of and
982.Fa uio
983is the destination location to read the contents into.
984The argument
985.Fa cred
986is the caller's credentials.
987The argument
988.Fa eofflag
989is the pointer to a flag which is set by
990.Fn VOP_READDIR
991to indicate an end-of-file condition.
992If
993.Fa eofflag
994is
995.Dv NULL ,
996the end-of-file condition is not returned.
997The arguments
998.Fa cookies
999and
1000.Fa ncookies
1001specify the addresses for the list and number of directory seek
1002cookies generated for NFS.
1003Both
1004.Fa cookies
1005and
1006.Fa ncookies
1007should be
1008.Dv NULL
1009if they aren't required to be returned by
1010.Fn VOP_READDIR .
1011The directory contents are read into struct dirent structures and
1012.Fa uio->uio_offset
1013is set to the offset of the next unread directory entry.
1014This offset may be used in a following invocation to continue a
1015sequential read of the directory contents.
1016If the operation is successful zero is returned, otherwise an
1017appropriate error code is returned.
1018.Pp
1019The directory should be locked on entry and will remain locked on
1020return.
1021.Pp
1022If
1023.Fn VOP_READDIR
1024is called from the NFS server, the extra arguments
1025.Fa eofflag ,
1026.Fa ncookies
1027and
1028.Fa cookies
1029are used.
1030The value of
1031.Fa *eofflag
1032will be set to
1033.Dv true
1034if the end of the directory is reached while
1035reading.
1036The directory seek cookies are returned to the NFS client and may be
1037used later to restart a directory read part way through the directory.
1038There should be one cookie returned per directory entry.
1039The value of the cookie for each directory entry should be the offset
1040within the directory where the on-disk version of the following
1041directory entry starts.
1042That is, for each directory entry
1043.Fa i ,
1044the corresponding cookie should refer to the offset of directory entry
1045.Fa i + 1 .
1046.Pp
1047Note that the
1048.Fa cookies
1049array must be allocated by the callee using the M_TEMP malloc type as
1050callers of
1051.Fn VOP_READDIR
1052must be able to free the allocation.
1053.It Fn VOP_READLINK "vp" "uio" "cred"
1054Read the contents of a symbolic link.
1055The argument
1056.Fa vp
1057is the locked vnode of the symlink and
1058.Fa uio
1059is the destination location to read the contents into.
1060The argument
1061.Fa cred
1062is the credentials of the caller.
1063If the operation is successful zero is returned, otherwise an error
1064code is returned.
1065.Pp
1066The vnode should be locked on entry and will remain locked on return.
1067.It Fn VOP_ABORTOP "dvp" "cnp"
1068Abort pending operation on vnode
1069.Fa dvp .
1070This operation is rarely implemented in file systems.
1071.It Fn VOP_INACTIVE "vp" "l"
1072Release the inactive vnode.
1073.Fn VOP_INACTIVE
1074is called when the kernel is no longer using the vnode.
1075This may be because the reference count reaches zero or it may be that
1076the file system is being forcibly unmounted while there are open
1077files.
1078It can be used to reclaim space for open but deleted files.
1079The argument
1080.Fa vp
1081is the locked vnode to be released.
1082The argument
1083.Fa l
1084is the calling process.
1085If the operation is successful zero is returned, otherwise an
1086appropriate error code is returned.
1087The vnode
1088.Fa vp
1089must be locked on entry, and will be unlocked on return.
1090.It Fn VOP_RECLAIM "vp" "l"
1091Reclaim the vnode for another file system.
1092.Fn VOP_RECLAIM
1093is called when a vnode is being reused for a different file system.
1094Any file system specific resources associated with the vnode should be
1095freed.
1096The argument
1097.Fa vp
1098is the vnode to be reclaimed.
1099The argument
1100.Fa l
1101is the calling process.
1102If the operation is successful zero is returned, otherwise an
1103appropriate error code is returned.
1104The vnode
1105.Fa vp
1106should not be locked on entry, and will remain unlocked on return.
1107.It Fn VOP_LOCK "vp" "flags"
1108Sleep until vnode lock is free.
1109The argument
1110.Fa vp
1111is the vnode of the file to be locked.
1112The argument
1113.Fa flags
1114is a set of
1115.Xr lockmgr 9
1116flags.
1117If the operation is successful zero is returned, otherwise an
1118appropriate error code is returned.
1119.Fn VOP_LOCK
1120is used to serialise access to the file system such as to prevent two
1121writes to the same file from happening at the same time.
1122Kernel code should use
1123.Xr vn_lock 9
1124to lock a vnode rather than calling
1125.Fn VOP_LOCK
1126directly.
1127.It Fn VOP_UNLOCK "vp" "flags"
1128Wake up process sleeping on lock.
1129The argument
1130.Fa vp
1131is the vnode of the file to be unlocked.
1132The argument
1133.Fa flags
1134is a set of
1135.Xr lockmgr 9
1136flags.
1137If the operation is successful zero is returned, otherwise an
1138appropriate error code is returned.
1139.Fn VOP_UNLOCK
1140is used to serialise access to the file system such as to prevent two
1141writes to the same file from happening at the same time.
1142.It Fn VOP_ISLOCKED "vp"
1143Test if the vnode
1144.Fa vp
1145is locked.
1146A non-zero value is returned if the vnode is not locked, otherwise
1147zero is returned.
1148.It Fn VOP_BMAP "vp" "bn" "vpp" "bnp" "runp"
1149Convert the logical block number
1150.Fa bn
1151of a file specified by vnode
1152.Fa vp
1153to its physical block number on the disk.
1154If
1155.Fa vpp
1156is not
1157.Dv NULL ,
1158the vnode of the device vnode for the file system is
1159returned in the address specified by
1160.Fa vpp .
1161If
1162.Fa runp
1163is not
1164.Dv NULL ,
1165the number of contiguous blocks starting from the next block after
1166the queried block will be returned in
1167.Fa runp .
1168.It Fn VOP_PRINT "vp"
1169Print debugging information.
1170The argument
1171.Fa vp
1172is the vnode to print.
1173If the operation is successful zero is returned, otherwise an
1174appropriate error code is returned.
1175.It Fn VOP_PATHCONF "vp" "name" "retval"
1176Implement POSIX
1177.Xr pathconf 2
1178and
1179.Xr fpathconf 2
1180support.
1181The argument
1182.Fa vp
1183is the locked vnode to get information about.
1184The argument
1185.Fa name
1186specified the type of information to return.
1187The information is returned in the address specified by
1188.Fa retval .
1189Valid values for
1190.Fa name
1191are:
1192.Pp
1193.Bl -tag -offset indent -width _PC_CHOWN_RESTRICTED -compact
1194.It _PC_LINK_MAX
1195return the maximum number of links to a file
1196.It _PC_NAME_MAX
1197return the maximum number of bytes in a file name
1198.It _PC_PATH_MAX
1199return the maximum number of bytes in a pathname
1200.It _PC_PIPE_BUF
1201return the maximum number of bytes which will be written atomically to
1202a pipe
1203.It _PC_CHOWN_RESTRICTED
1204return 1 if appropriate privileges are required for the
1205.Xr chown 2
1206system call, otherwise zero
1207.It _PC_NO_TRUNC
1208return if file names longer than KERN_NAME_MAX are truncated
1209.El
1210.Pp
1211If
1212.Fa name
1213is recognised,
1214.Fa *retval
1215is set to the specified value and zero is returned, otherwise an
1216appropriate error is returned.
1217.It Fn VOP_ADVLOCK "vp" "id" "op" "fl" "flags"
1218Manipulate Advisory record locks on a vnode.
1219The argument
1220.Fa vp
1221is the vnode on which locks are manipulated.
1222The argument
1223.Fa id
1224is the id token which is changing the lock and
1225.Fa op
1226is the
1227.Xr fcntl 2
1228operation to perform.
1229Valid values are:
1230.Pp
1231.Bl -tag -offset indent -width F_UNLCK -compact
1232.It F_SETLK
1233set lock
1234.It F_GETLK
1235get the first conflicted lock
1236.It F_UNLCK
1237clear lock
1238.El
1239.Pp
1240The argument
1241.Fa fl
1242is a description of the lock.
1243In the case of
1244.Dv SEEK_CUR ,
1245The caller should add the current file offset to
1246fl-\*[Gt]l_start beforehand.
1247.Fn VOP_ADVLOCK
1248treats
1249.Dv SEEK_CUR
1250as
1251.Dv SEEK_SET .
1252.Pp
1253The argument
1254.Fa flags
1255is the set of flags.
1256Valid values are:
1257.Pp
1258.Bl -tag -offset indent -width F_FLOCK -compact
1259.It F_WAIT
1260wait until lock is granted
1261.It F_FLOCK
1262use
1263.Xr flock 2
1264semantics for lock
1265.It F_POSIX
1266use POSIX semantics for lock
1267.El
1268.Pp
1269If the operation is successful zero is returned, otherwise an
1270appropriate error is returned.
1271.It Fn VOP_LEASE "vp" "l" "cred" "flags"
1272Validate vnode credentials and operation type.
1273The argument
1274.Fa vp
1275is the locked vnode of the file to validate credentials
1276.Fa cred .
1277The argument
1278.Fa l
1279specifies the calling process and
1280.Fa flags
1281specifies the operation flags.
1282If the operation is successful zero is returned, otherwise an
1283appropriate error code is returned.
1284The vnode must be locked on entry and remains locked on return.
1285.It Fn VOP_WHITEOUT "dvp" "cnp" "flags"
1286Whiteout pathname component in directory with vnode
1287.Fa dvp .
1288The argument
1289.Fa cnp
1290specifies the pathname component to whiteout.
1291.It Fn VOP_GETPAGES "vp" "offset" "m" "count" "centeridx" "access_type" "advice" "flags"
1292Read VM pages from file.
1293The argument
1294.Fa vp
1295is the locked vnode to read the VM pages from.
1296The argument
1297.Fa offset
1298is offset in the file to start accessing and
1299.Fa m
1300is an array of VM pages.
1301The argument
1302.Fa count
1303points a variable that specifies the number of pages to read.
1304If the operation is successful zero is returned, otherwise an
1305appropriate error code is returned.
1306If PGO_LOCKED is specified in
1307.Em flags ,
1308.Fn VOP_GETPAGES
1309might return less pages than requested.
1310In that case, the variable pointed to by
1311.Em count
1312will be updated.
1313.Pp
1314This function is primarily used by the page-fault handing mechanism.
1315.It Fn VOP_PUTPAGES "vp" "offlo" "offhi" "flags"
1316Write modified (dirty) VM pages to file.
1317The argument
1318.Fa vp
1319is the vnode to write the VM pages to.
1320The vnode's vm object lock
1321.Va ( v_uobj.vmobjlock )
1322must be held by the caller and will be released upon return.
1323The arguments
1324.Fa offlo
1325and
1326.Fa offhi
1327specify the range of VM pages to write.
1328In case
1329.Fa offhi
1330is given as 0, all pages at and after the start offset
1331.Fa offlo
1332belonging the vnode
1333.Fa vp
1334will be written.
1335The argument
1336.Fa flags
1337controls the behaviour of the routine and takes the vm pager's
1338flags
1339.Dv ( PGO_ -prefixed).
1340If the operation is successful zero is returned, otherwise an
1341appropriate error code is returned.
1342.Pp
1343The function is primarily used by the pageout handling mechanism and
1344is commonly implemented indirectly
1345by
1346.Fn genfs_putpages
1347with the help of
1348.Fn VOP_STRATEGY
1349and
1350.Fn VOP_BMAP .
1351.It Fn VOP_STRATEGY "vp" "bp"
1352Read/write a file system buffer.
1353The argument
1354.Fa vp
1355is the vnode to read/write to.
1356The argument
1357.Fa bp
1358is the buffer to be read or written.
1359.Fn VOP_STRATEGY
1360will either read or write data to the file depending on the value of
1361.Em bp-\*[Gt]b_flags .
1362If the operation is successful zero is returned, otherwise an
1363appropriate error code is returned.
1364.It Fn VOP_BWRITE "bp"
1365Write a file system buffer.
1366The argument
1367.Fa bp
1368specifies the buffer to be written.
1369If the operation is successful zero is returned, otherwise an
1370appropriate error code is returned.
1371.It Fn VOP_GETEXTATTR "vp" "attrnamespace" "name" "uio" "size" "cred" "l"
1372Get an extended attribute.
1373The argument
1374.Fa vp
1375is the locked vnode of the file or directory from which to retrieve the
1376attribute.
1377The argument
1378.Fa attrnamespace
1379specifies the extended attribute namespace.
1380The argument
1381.Fa name
1382is a nul-terminated character string naming the attribute to retrieve.
1383The argument
1384.Fa uio ,
1385if not
1386.Dv NULL ,
1387specifies where the extended attribute value is to be written.
1388The argument
1389.Fa size ,
1390if not
1391.Dv NULL ,
1392will contain the number of bytes required to read all of
1393the attribute data upon return.
1394In most cases,
1395.Fa uio
1396will be
1397.Dv NULL
1398when
1399.Fa size
1400is not, and vice versa.
1401The argument
1402.Fa cred
1403specifies the user credentials to use when authorizing the request.
1404The argument
1405.Fa l
1406specifies the process requesting the extended attribute.
1407.It Fn VOP_SETEXTATTR "vp" "attrnamespace" "name" "uio" "cred" "l"
1408Set an extended attribute.
1409The argument
1410.Fa vp
1411is the locked vnode of the file or directory to which to store the
1412attribute.
1413The argument
1414.Fa namespace
1415specifies the extended attribute namespace.
1416The argument
1417.Fa name
1418is a nul-terminated character string naming the attribute to store.
1419The argument
1420.Fa uio
1421specifies the source of the extended attribute data.
1422The argument
1423.Fa cred
1424specifies the user credentials to use when authorizing the request.
1425The argument
1426.Fa l
1427specifies the process setting the extended attribute.
1428.It Fn VOP_LISTEXTATTR "vp" "attrnamespace" "uio" "size" "cred" "l"
1429Retrieve the list of extended attributes.
1430The argument
1431.Fa vp
1432is the locked vnode of the file or directory whose attributes are to be listed.
1433The argument
1434.Fa attrnamespace
1435specifies the extended attribute namespace.
1436The argument
1437.Fa uio ,
1438if not
1439.Dv NULL ,
1440specifies where the extended attribute list is to be written.
1441The argument
1442.Fa size ,
1443if not
1444.Dv NULL ,
1445will contain the number of bytes required to read all of
1446the attribute names upon return.
1447In most cases,
1448.Fa uio
1449will be
1450.Dv NULL
1451when
1452.Fa size
1453is not, and vice versa.
1454The argument
1455.Fa cred
1456specifies the user credentials to use when authorizing the request.
1457The argument
1458.Fa l
1459specifies the process requesting the extended attribute list.
1460.El
1461.Sh ERRORS
1462.Bl -tag -width Er
1463.It Bq Er ENOATTR
1464The requested attribute is not defined for this vnode.
1465.It Bq Er ENOTDIR
1466The vnode does not represent a directory.
1467.It Bq Er ENOENT
1468The component was not found in the directory.
1469.It Bq Er ENOSPC
1470The file system is full.
1471.It Bq Er EDQUOT
1472Quota exceeded.
1473.It Bq Er EACCES
1474Access for the specified operation is denied.
1475.It Bq Er EJUSTRETURN
1476A CREATE or RENAME operation would be successful.
1477.It Bq Er EPERM
1478an attempt was made to change an immutable file
1479.It Bq Er ENOTEMPTY
1480attempt to remove a directory which is not empty
1481.It Bq Er EINVAL
1482attempt to read from an illegal offset in the directory; unrecognised
1483input
1484.It Bq Er EIO
1485a read error occurred while reading the directory or reading the
1486contents of a symbolic link
1487.It Bq Er EROFS
1488the filesystem is read-only
1489.El
1490.Sh SEE ALSO
1491.Xr extattr 9 ,
1492.Xr intro 9 ,
1493.Xr lock 9 ,
1494.Xr namei 9 ,
1495.Xr vattr 9 ,
1496.Xr vfs 9 ,
1497.Xr vfsops 9 ,
1498.Xr vnode 9
1499.Sh HISTORY
1500The vnode operations vector, its functions and the corresponding
1501macros appeared in
1502.Bx 4.3 .
1503