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.\" 297f3dea24SPeter Wemm.\" $FreeBSD$ 30fab63cc4SDoug Rabson.\" 31*51ea7beaSMateusz Guzik.Dd August 8, 2020 32fab63cc4SDoug Rabson.Dt VOP_ATTRIB 9 33aa12cea2SUlrich Spörlein.Os 34fab63cc4SDoug Rabson.Sh NAME 35fab63cc4SDoug Rabson.Nm VOP_GETATTR , 36fab63cc4SDoug Rabson.Nm VOP_SETATTR 37fab63cc4SDoug Rabson.Nd get and set attributes on a file or directory 38fab63cc4SDoug Rabson.Sh SYNOPSIS 3932eef9aeSRuslan Ermilov.In sys/param.h 4032eef9aeSRuslan Ermilov.In sys/vnode.h 41fab63cc4SDoug Rabson.Ft int 420359a12eSAttilio Rao.Fn VOP_GETATTR "struct vnode *vp" "struct vattr *vap" "struct ucred *cred" 43fab63cc4SDoug Rabson.Ft int 440359a12eSAttilio Rao.Fn VOP_SETATTR "struct vnode *vp" "struct vattr *vap" "struct ucred *cred" 45*51ea7beaSMateusz Guzik.Ft int 46*51ea7beaSMateusz Guzik.Fn VOP_STAT "struct vnode *vp" "struct stat *sb" "struct ucred *active_cred" \ 47*51ea7beaSMateusz Guzik"struct ucred *file_cred" "struct thread *td" 48fab63cc4SDoug Rabson.Sh DESCRIPTION 49fab63cc4SDoug RabsonThese entry points manipulate various attributes of a file or directory, 50fab63cc4SDoug Rabsonincluding file permissions, owner, group, size, 51fab63cc4SDoug Rabsonaccess time and modification time. 52fab63cc4SDoug Rabson.Pp 53*51ea7beaSMateusz Guzik.Fn VOP_STAT 54*51ea7beaSMateusz Guzikreturns data in a format suitable for the 55*51ea7beaSMateusz Guzik.Xr stat 2 56*51ea7beaSMateusz Guziksystem call and by default is implemented as a wrapper around 57*51ea7beaSMateusz Guzik.Fn VOP_GETATTR . 58*51ea7beaSMateusz GuzikFilesystems may want to implement their own variant for performance reasons. 59*51ea7beaSMateusz Guzik.Pp 60*51ea7beaSMateusz GuzikFor 61*51ea7beaSMateusz Guzik.Fn VOP_GETATTR 62*51ea7beaSMateusz Guzikand 63*51ea7beaSMateusz Guzik.Fn VOP_SETATTR 64*51ea7beaSMateusz Guzikthe arguments are: 65fab63cc4SDoug Rabson.Bl -tag -width cred 66841b462fSRuslan Ermilov.It Fa vp 670a57ea7dSRuslan ErmilovThe vnode of the file. 68841b462fSRuslan Ermilov.It Fa vap 690a57ea7dSRuslan ErmilovThe attributes of the file. 70841b462fSRuslan Ermilov.It Fa cred 71*51ea7beaSMateusz GuzikThe user credentials of the calling thread. 72*51ea7beaSMateusz Guzik.El 73*51ea7beaSMateusz Guzik.Pp 74*51ea7beaSMateusz GuzikFor 75*51ea7beaSMateusz Guzik.Fn VOP_STAT 76*51ea7beaSMateusz Guzikthe arguments are: 77*51ea7beaSMateusz Guzik.Bl -tag -width active_cred 78*51ea7beaSMateusz Guzik.It Fa vp 79*51ea7beaSMateusz GuzikThe vnode of the file. 80*51ea7beaSMateusz Guzik.It Fa sb 81*51ea7beaSMateusz GuzikThe attributes of the file. 82*51ea7beaSMateusz Guzik.It Fa active_cred 83*51ea7beaSMateusz GuzikThe user credentials of the calling thread. 84*51ea7beaSMateusz Guzik.It Fa file_cred 85*51ea7beaSMateusz GuzikThe credentials installed on the file description pointing to the vnode or NOCRED. 86*51ea7beaSMateusz Guzik.It Fa td 87*51ea7beaSMateusz GuzikThe calling thread. 88fab63cc4SDoug Rabson.El 89fab63cc4SDoug Rabson.Pp 90fab63cc4SDoug RabsonAttributes which are not being modified by 91facc6767SRuslan Ermilov.Fn VOP_SETATTR 92fab63cc4SDoug Rabsonshould be set to the value 93cc0e5494SRobert Watson.Dv VNOVAL ; 9458616b1cSRobert Watson.Fn VATTR_NULL 95cc0e5494SRobert Watsonmay be used to clear all the values, and should generally be used to reset 96cc0e5494SRobert Watsonthe contents of 97841b462fSRuslan Ermilov.Fa *vap 98cc0e5494SRobert Watsonprior to setting specific values. 99fab63cc4SDoug Rabson.Sh LOCKS 100*51ea7beaSMateusz GuzikBoth 101facc6767SRuslan Ermilov.Fn VOP_GETATTR 102*51ea7beaSMateusz Guzikand 103*51ea7beaSMateusz Guzik.Fn VOP_STAT 104*51ea7beaSMateusz Guzikexpect the vnode to be locked on entry and will leave the vnode locked on 105b3b414b6SRobert Watsonreturn. 106cc0e5494SRobert WatsonThe lock type can be either shared or exclusive. 107bebac989SMatthew Dillon.Pp 108facc6767SRuslan Ermilov.Fn VOP_SETATTR 109bebac989SMatthew Dillonexpects the vnode to be locked on entry and will leave the vnode locked on 110bebac989SMatthew Dillonreturn. 111cc0e5494SRobert WatsonThe lock type must be exclusive. 112fab63cc4SDoug Rabson.Sh RETURN VALUES 113facc6767SRuslan Ermilov.Fn VOP_GETATTR 114cc0e5494SRobert Watsonreturns 0 if it was able to retrieve the attribute data via 115cc0e5494SRobert Watson.Fa *vap , 116cc0e5494SRobert Watsonotherwise an appropriate error is returned. 117facc6767SRuslan Ermilov.Fn VOP_SETATTR 118fab63cc4SDoug Rabsonreturns zero if the attributes were changed successfully, otherwise an 119fab63cc4SDoug Rabsonappropriate error is returned. 120*51ea7beaSMateusz Guzik.Fn VOP_STAT 121*51ea7beaSMateusz Guzikreturns 0 if it was able to retrieve the attribute data 122*51ea7beaSMateusz Guzik.Fa *sb , 123*51ea7beaSMateusz Guzikotherwise an appropriate error is returned. 124fab63cc4SDoug Rabson.Sh ERRORS 125eaa8b244SMike Pritchard.Bl -tag -width Er 126fab63cc4SDoug Rabson.It Bq Er EPERM 127cc258457SDon LewisThe file is immutable. 128fab63cc4SDoug Rabson.It Bq Er EACCES 12981f8d226SDon LewisThe caller does not have permission to modify the file or directory attributes. 130fab63cc4SDoug Rabson.It Bq Er EROFS 131cc258457SDon LewisThe file system is read-only. 132fab63cc4SDoug Rabson.El 133fab63cc4SDoug Rabson.Sh SEE ALSO 134841b462fSRuslan Ermilov.Xr VFS 9 , 135fab63cc4SDoug Rabson.Xr vnode 9 , 136841b462fSRuslan Ermilov.Xr VOP_ACCESS 9 137fab63cc4SDoug Rabson.Sh AUTHORS 138571dba6eSHiten PandyaThis manual page was written by 139aaf1f16eSPhilippe Charnier.An Doug Rabson . 140