xref: /freebsd/share/man/man9/VOP_ATTRIB.9 (revision 66fcbd9556b0053253a945638ae360ffc9040c82)
1fab63cc4SDoug Rabson.\" -*- nroff -*-
2fab63cc4SDoug Rabson.\"
3fab63cc4SDoug Rabson.\" Copyright (c) 1996 Doug Rabson
4fab63cc4SDoug Rabson.\"
5fab63cc4SDoug Rabson.\" All rights reserved.
6fab63cc4SDoug Rabson.\"
7fab63cc4SDoug Rabson.\" This program is free software.
8fab63cc4SDoug Rabson.\"
9fab63cc4SDoug Rabson.\" Redistribution and use in source and binary forms, with or without
10fab63cc4SDoug Rabson.\" modification, are permitted provided that the following conditions
11fab63cc4SDoug Rabson.\" are met:
12fab63cc4SDoug Rabson.\" 1. Redistributions of source code must retain the above copyright
13fab63cc4SDoug Rabson.\"    notice, this list of conditions and the following disclaimer.
14fab63cc4SDoug Rabson.\" 2. Redistributions in binary form must reproduce the above copyright
15fab63cc4SDoug Rabson.\"    notice, this list of conditions and the following disclaimer in the
16fab63cc4SDoug Rabson.\"    documentation and/or other materials provided with the distribution.
17fab63cc4SDoug Rabson.\"
18fab63cc4SDoug Rabson.\" THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY EXPRESS OR
19fab63cc4SDoug Rabson.\" IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
20fab63cc4SDoug Rabson.\" OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
21fab63cc4SDoug Rabson.\" IN NO EVENT SHALL THE DEVELOPERS BE LIABLE FOR ANY DIRECT, INDIRECT,
22fab63cc4SDoug Rabson.\" INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
23fab63cc4SDoug Rabson.\" NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
24fab63cc4SDoug Rabson.\" DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
25fab63cc4SDoug Rabson.\" THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
26fab63cc4SDoug Rabson.\" (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
27fab63cc4SDoug Rabson.\" THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
28fab63cc4SDoug Rabson.\"
292b68eb8eSMateusz Guzik.Dd October 2, 2021
30fab63cc4SDoug Rabson.Dt VOP_ATTRIB 9
31aa12cea2SUlrich Spörlein.Os
32fab63cc4SDoug Rabson.Sh NAME
33fab63cc4SDoug Rabson.Nm VOP_GETATTR ,
34fab63cc4SDoug Rabson.Nm VOP_SETATTR
35fab63cc4SDoug Rabson.Nd get and set attributes on a file or directory
36fab63cc4SDoug Rabson.Sh SYNOPSIS
3732eef9aeSRuslan Ermilov.In sys/param.h
3832eef9aeSRuslan Ermilov.In sys/vnode.h
39fab63cc4SDoug Rabson.Ft int
40*66fcbd95SKonstantin Belousov.Fo VOP_GETATTR
41*66fcbd95SKonstantin Belousov.Fa struct vnode *vp
42*66fcbd95SKonstantin Belousov.Fa flags
43*66fcbd95SKonstantin Belousov.Fa struct vattr *vap
44*66fcbd95SKonstantin Belousov.Fa struct ucred *cred
45*66fcbd95SKonstantin Belousov.Fc
46fab63cc4SDoug Rabson.Ft int
47*66fcbd95SKonstantin Belousov.Fo VOP_SETATTR
48*66fcbd95SKonstantin Belousov.Fa struct vnode *vp
49*66fcbd95SKonstantin Belousov.Fa struct vattr *vap
50*66fcbd95SKonstantin Belousov.Fa struct ucred *cred
51*66fcbd95SKonstantin Belousov.Fc
5251ea7beaSMateusz Guzik.Ft int
53*66fcbd95SKonstantin Belousov.Fo VOP_STAT
54*66fcbd95SKonstantin Belousov.Fa struct vnode *vp
55*66fcbd95SKonstantin Belousov.Fa struct stat *sb
56*66fcbd95SKonstantin Belousov.Fa flags
57*66fcbd95SKonstantin Belousov.Fa struct ucred *active_cred
58*66fcbd95SKonstantin Belousov.Fa struct ucred *file_cred
59*66fcbd95SKonstantin Belousov.Fc
60fab63cc4SDoug Rabson.Sh DESCRIPTION
61fab63cc4SDoug RabsonThese entry points manipulate various attributes of a file or directory,
62fab63cc4SDoug Rabsonincluding file permissions, owner, group, size,
63fab63cc4SDoug Rabsonaccess time and modification time.
64fab63cc4SDoug Rabson.Pp
6551ea7beaSMateusz Guzik.Fn VOP_STAT
6651ea7beaSMateusz Guzikreturns data in a format suitable for the
6751ea7beaSMateusz Guzik.Xr stat 2
6851ea7beaSMateusz Guziksystem call and by default is implemented as a wrapper around
6951ea7beaSMateusz Guzik.Fn VOP_GETATTR .
7051ea7beaSMateusz GuzikFilesystems may want to implement their own variant for performance reasons.
7151ea7beaSMateusz Guzik.Pp
7251ea7beaSMateusz GuzikFor
7351ea7beaSMateusz Guzik.Fn VOP_GETATTR
7451ea7beaSMateusz Guzikand
7551ea7beaSMateusz Guzik.Fn VOP_SETATTR
7651ea7beaSMateusz Guzikthe arguments are:
77fab63cc4SDoug Rabson.Bl -tag -width cred
78841b462fSRuslan Ermilov.It Fa vp
790a57ea7dSRuslan ErmilovThe vnode of the file.
80841b462fSRuslan Ermilov.It Fa vap
810a57ea7dSRuslan ErmilovThe attributes of the file.
82841b462fSRuslan Ermilov.It Fa cred
8351ea7beaSMateusz GuzikThe user credentials of the calling thread.
8451ea7beaSMateusz Guzik.El
8551ea7beaSMateusz Guzik.Pp
8651ea7beaSMateusz GuzikFor
8751ea7beaSMateusz Guzik.Fn VOP_STAT
8851ea7beaSMateusz Guzikthe arguments are:
8951ea7beaSMateusz Guzik.Bl -tag -width active_cred
9051ea7beaSMateusz Guzik.It Fa vp
9151ea7beaSMateusz GuzikThe vnode of the file.
9251ea7beaSMateusz Guzik.It Fa sb
9351ea7beaSMateusz GuzikThe attributes of the file.
9451ea7beaSMateusz Guzik.It Fa active_cred
9551ea7beaSMateusz GuzikThe user credentials of the calling thread.
9651ea7beaSMateusz Guzik.It Fa file_cred
9751ea7beaSMateusz GuzikThe credentials installed on the file description pointing to the vnode or NOCRED.
98fab63cc4SDoug Rabson.El
99fab63cc4SDoug Rabson.Pp
100fab63cc4SDoug RabsonAttributes which are not being modified by
101facc6767SRuslan Ermilov.Fn VOP_SETATTR
102fab63cc4SDoug Rabsonshould be set to the value
103cc0e5494SRobert Watson.Dv VNOVAL ;
10458616b1cSRobert Watson.Fn VATTR_NULL
105cc0e5494SRobert Watsonmay be used to clear all the values, and should generally be used to reset
106cc0e5494SRobert Watsonthe contents of
107841b462fSRuslan Ermilov.Fa *vap
108cc0e5494SRobert Watsonprior to setting specific values.
109fab63cc4SDoug Rabson.Sh LOCKS
11051ea7beaSMateusz GuzikBoth
111facc6767SRuslan Ermilov.Fn VOP_GETATTR
11251ea7beaSMateusz Guzikand
11351ea7beaSMateusz Guzik.Fn VOP_STAT
11451ea7beaSMateusz Guzikexpect the vnode to be locked on entry and will leave the vnode locked on
115b3b414b6SRobert Watsonreturn.
116cc0e5494SRobert WatsonThe lock type can be either shared or exclusive.
117bebac989SMatthew Dillon.Pp
118facc6767SRuslan Ermilov.Fn VOP_SETATTR
119bebac989SMatthew Dillonexpects the vnode to be locked on entry and will leave the vnode locked on
120bebac989SMatthew Dillonreturn.
121cc0e5494SRobert WatsonThe lock type must be exclusive.
122fab63cc4SDoug Rabson.Sh RETURN VALUES
123facc6767SRuslan Ermilov.Fn VOP_GETATTR
124cc0e5494SRobert Watsonreturns 0 if it was able to retrieve the attribute data via
125cc0e5494SRobert Watson.Fa *vap ,
126cc0e5494SRobert Watsonotherwise an appropriate error is returned.
127facc6767SRuslan Ermilov.Fn VOP_SETATTR
128fab63cc4SDoug Rabsonreturns zero if the attributes were changed successfully, otherwise an
129fab63cc4SDoug Rabsonappropriate error is returned.
13051ea7beaSMateusz Guzik.Fn VOP_STAT
13151ea7beaSMateusz Guzikreturns 0 if it was able to retrieve the attribute data
13251ea7beaSMateusz Guzik.Fa *sb ,
13351ea7beaSMateusz Guzikotherwise an appropriate error is returned.
134fab63cc4SDoug Rabson.Sh ERRORS
135eaa8b244SMike Pritchard.Bl -tag -width Er
136fab63cc4SDoug Rabson.It Bq Er EPERM
137cc258457SDon LewisThe file is immutable.
138fab63cc4SDoug Rabson.It Bq Er EACCES
13981f8d226SDon LewisThe caller does not have permission to modify the file or directory attributes.
140fab63cc4SDoug Rabson.It Bq Er EROFS
141cc258457SDon LewisThe file system is read-only.
142fab63cc4SDoug Rabson.El
143fab63cc4SDoug Rabson.Sh SEE ALSO
144841b462fSRuslan Ermilov.Xr VFS 9 ,
145fab63cc4SDoug Rabson.Xr vnode 9 ,
146841b462fSRuslan Ermilov.Xr VOP_ACCESS 9
147fab63cc4SDoug Rabson.Sh AUTHORS
148571dba6eSHiten PandyaThis manual page was written by
149aaf1f16eSPhilippe Charnier.An Doug Rabson .
150