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.\" 31fab63cc4SDoug Rabson.Dd July 24, 1996 32fab63cc4SDoug Rabson.Os 33fab63cc4SDoug Rabson.Dt VOP_ATTRIB 9 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 42c2508101SAndrew R. Reiter.Fn VOP_GETATTR "struct vnode *vp" "struct vattr *vap" "struct ucred *cred" "struct thread *td" 43fab63cc4SDoug Rabson.Ft int 44c2508101SAndrew R. Reiter.Fn VOP_SETATTR "struct vnode *vp" "struct vattr *vap" "struct ucred *cred" "struct thread *td" 45fab63cc4SDoug Rabson.Sh DESCRIPTION 46fab63cc4SDoug RabsonThese entry points manipulate various attributes of a file or directory, 47fab63cc4SDoug Rabsonincluding file permissions, owner, group, size, 48fab63cc4SDoug Rabsonaccess time and modification time. 49fab63cc4SDoug Rabson.Pp 50fab63cc4SDoug RabsonThe arguments are: 51fab63cc4SDoug Rabson.Bl -tag -width cred 52841b462fSRuslan Ermilov.It Fa vp 53fab63cc4SDoug Rabsonthe vnode of the file 54841b462fSRuslan Ermilov.It Fa vap 55fab63cc4SDoug Rabsonthe attributes of the file 56841b462fSRuslan Ermilov.It Fa cred 57fab63cc4SDoug Rabsonthe user credentials of the calling process 58841b462fSRuslan Ermilov.It Fa td 59c2508101SAndrew R. Reiterthe thread 60fab63cc4SDoug Rabson.El 61fab63cc4SDoug Rabson.Pp 62fab63cc4SDoug RabsonAttributes which are not being modified by 63fab63cc4SDoug Rabson.Xr VOP_SETATTR 9 64fab63cc4SDoug Rabsonshould be set to the value 65cc0e5494SRobert Watson.Dv VNOVAL ; 66841b462fSRuslan Ermilov.Fn VOP_NULL 67cc0e5494SRobert Watsonmay be used to clear all the values, and should generally be used to reset 68cc0e5494SRobert Watsonthe contents of 69841b462fSRuslan Ermilov.Fa *vap 70cc0e5494SRobert Watsonprior to setting specific values. 71fab63cc4SDoug Rabson.Sh LOCKS 72b3b414b6SRobert Watson.Xr VOP_GETATTR 9 73b3b414b6SRobert Watsonexpects the vnode to be locked on entry and will leave the vnode locked on 74b3b414b6SRobert Watsonreturn. 75cc0e5494SRobert WatsonThe lock type can be either shared or exclusive. 76bebac989SMatthew Dillon.Pp 77bebac989SMatthew Dillon.Xr VOP_SETATTR 9 78bebac989SMatthew Dillonexpects the vnode to be locked on entry and will leave the vnode locked on 79bebac989SMatthew Dillonreturn. 80cc0e5494SRobert WatsonThe lock type must be exclusive. 81fab63cc4SDoug Rabson.Sh RETURN VALUES 82fab63cc4SDoug Rabson.Xr VOP_GETATTR 9 83cc0e5494SRobert Watsonreturns 0 if it was able to retrieve the attribute data via 84cc0e5494SRobert Watson.Fa *vap , 85cc0e5494SRobert Watsonotherwise an appropriate error is returned. 86fab63cc4SDoug Rabson.Xr VOP_SETATTR 9 87fab63cc4SDoug Rabsonreturns zero if the attributes were changed successfully, otherwise an 88fab63cc4SDoug Rabsonappropriate error is returned. 89fab63cc4SDoug Rabson.Sh PSEUDOCODE 90fab63cc4SDoug Rabson.Bd -literal 91fab63cc4SDoug Rabsonint 92bd79f842SChris Costellovop_getattr(struct vnode *vp, struct vattr *vap, 93c2508101SAndrew R. Reiter struct ucred *cred, struct thread *td) 94fab63cc4SDoug Rabson{ 95fab63cc4SDoug Rabson /* 96bd79f842SChris Costello * Fill in the contents of *vap with information from 97fab63cc4SDoug Rabson * the filesystem. 98fab63cc4SDoug Rabson */ 99fab63cc4SDoug Rabson ...; 100fab63cc4SDoug Rabson 101fab63cc4SDoug Rabson return 0; 102fab63cc4SDoug Rabson} 103fab63cc4SDoug Rabson 104fab63cc4SDoug Rabsonint 105bd79f842SChris Costellovop_setattr(struct vnode *vp, struct vattr *vap, 106c2508101SAndrew R. Reiter struct ucred *cred, struct thread *td) 107fab63cc4SDoug Rabson{ 108fab63cc4SDoug Rabson /* 109fab63cc4SDoug Rabson * Check for unsettable attributes. 110fab63cc4SDoug Rabson */ 111fab63cc4SDoug Rabson if ((vap->va_type != VNON) || (vap->va_nlink != VNOVAL) || 112fab63cc4SDoug Rabson (vap->va_fsid != VNOVAL) || (vap->va_fileid != VNOVAL) || 113fab63cc4SDoug Rabson (vap->va_blocksize != VNOVAL) || (vap->va_rdev != VNOVAL) || 114fab63cc4SDoug Rabson ((int)vap->va_bytes != VNOVAL) || (vap->va_gen != VNOVAL)) { 115fab63cc4SDoug Rabson return (EINVAL); 116fab63cc4SDoug Rabson } 117fab63cc4SDoug Rabson 118fab63cc4SDoug Rabson if (vap->va_flags != VNOVAL) { 119fab63cc4SDoug Rabson /* 120fab63cc4SDoug Rabson * Set the immutable and append flags of the file. 121fab63cc4SDoug Rabson */ 122fab63cc4SDoug Rabson } 123fab63cc4SDoug Rabson 124fab63cc4SDoug Rabson if (vap->va_uid != (uid_t)VNOVAL || vap->va_gid != (gid_t)VNOVAL) { 125fab63cc4SDoug Rabson /* 126fab63cc4SDoug Rabson * Change owner and/or group of the file. 127fab63cc4SDoug Rabson */ 128fab63cc4SDoug Rabson } 129fab63cc4SDoug Rabson 130fab63cc4SDoug Rabson if (vap->va_size != VNOVAL) { 131fab63cc4SDoug Rabson /* 132fab63cc4SDoug Rabson * Truncate the file to the specified size. 133fab63cc4SDoug Rabson */ 134fab63cc4SDoug Rabson } 135fab63cc4SDoug Rabson 13650e7a72dSMike Pritchard if (vap->va_atime.tv_sec != VNOVAL || vap->va_mtime.tv_sec != VNOVAL) { 137fab63cc4SDoug Rabson /* 138fab63cc4SDoug Rabson * Change access and/or modification time of file. 139fab63cc4SDoug Rabson */ 140fab63cc4SDoug Rabson } 141fab63cc4SDoug Rabson 142fab63cc4SDoug Rabson if (vap->va_mode != (mode_t)VNOVAL) { 143fab63cc4SDoug Rabson /* 144fab63cc4SDoug Rabson * Change permissions of file. 145fab63cc4SDoug Rabson */ 146fab63cc4SDoug Rabson } 147fab63cc4SDoug Rabson 148fab63cc4SDoug Rabson return 0; 149fab63cc4SDoug Rabson} 150fab63cc4SDoug Rabson.Ed 151fab63cc4SDoug Rabson.Sh ERRORS 152eaa8b244SMike Pritchard.Bl -tag -width Er 153fab63cc4SDoug Rabson.It Bq Er EPERM 154fab63cc4SDoug RabsonThe file is immutable 155fab63cc4SDoug Rabson.It Bq Er EACCES 156fab63cc4SDoug RabsonPermission denied 157fab63cc4SDoug Rabson.It Bq Er EROFS 158b82af3f5SMike PritchardThe filesystem is read-only 159fab63cc4SDoug Rabson.El 160fab63cc4SDoug Rabson.Sh SEE ALSO 161841b462fSRuslan Ermilov.Xr VFS 9 , 162fab63cc4SDoug Rabson.Xr vnode 9 , 163841b462fSRuslan Ermilov.Xr VOP_ACCESS 9 164fab63cc4SDoug Rabson.Sh AUTHORS 165aaf1f16eSPhilippe CharnierThis man page was written by 166aaf1f16eSPhilippe Charnier.An Doug Rabson . 167