186d7f5d3SJohn Marino.\" Copyright (c) 1996 Doug Rabson 286d7f5d3SJohn Marino.\" 386d7f5d3SJohn Marino.\" All rights reserved. 486d7f5d3SJohn Marino.\" 586d7f5d3SJohn Marino.\" This program is free software. 686d7f5d3SJohn Marino.\" 786d7f5d3SJohn Marino.\" Redistribution and use in source and binary forms, with or without 886d7f5d3SJohn Marino.\" modification, are permitted provided that the following conditions 986d7f5d3SJohn Marino.\" are met: 1086d7f5d3SJohn Marino.\" 1. Redistributions of source code must retain the above copyright 1186d7f5d3SJohn Marino.\" notice, this list of conditions and the following disclaimer. 1286d7f5d3SJohn Marino.\" 2. Redistributions in binary form must reproduce the above copyright 1386d7f5d3SJohn Marino.\" notice, this list of conditions and the following disclaimer in the 1486d7f5d3SJohn Marino.\" documentation and/or other materials provided with the distribution. 1586d7f5d3SJohn Marino.\" 1686d7f5d3SJohn Marino.\" THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY EXPRESS OR 1786d7f5d3SJohn Marino.\" IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES 1886d7f5d3SJohn Marino.\" OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. 1986d7f5d3SJohn Marino.\" IN NO EVENT SHALL THE DEVELOPERS BE LIABLE FOR ANY DIRECT, INDIRECT, 2086d7f5d3SJohn Marino.\" INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT 2186d7f5d3SJohn Marino.\" NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 2286d7f5d3SJohn Marino.\" DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 2386d7f5d3SJohn Marino.\" THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 2486d7f5d3SJohn Marino.\" (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF 2586d7f5d3SJohn Marino.\" THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 2686d7f5d3SJohn Marino.\" 2786d7f5d3SJohn Marino.\" $FreeBSD: src/share/man/man9/VOP_ATTRIB.9,v 1.9.2.2 2001/12/17 11:30:18 ru Exp $ 2886d7f5d3SJohn Marino.\" 2986d7f5d3SJohn Marino.Dd July 24, 1996 3086d7f5d3SJohn Marino.Dt VOP_ATTRIB 9 3186d7f5d3SJohn Marino.Os 3286d7f5d3SJohn Marino.Sh NAME 3386d7f5d3SJohn Marino.Nm VOP_GETATTR , 3486d7f5d3SJohn Marino.Nm VOP_SETATTR 3586d7f5d3SJohn Marino.Nd get and set attributes on a file or directory 3686d7f5d3SJohn Marino.Sh SYNOPSIS 3786d7f5d3SJohn Marino.In sys/param.h 3886d7f5d3SJohn Marino.In sys/vnode.h 3986d7f5d3SJohn Marino.Ft int 4086d7f5d3SJohn Marino.Fn VOP_GETATTR "struct vnode *vp" "struct vattr *vap" "struct ucred *cred" "struct proc *p" 4186d7f5d3SJohn Marino.Ft int 4286d7f5d3SJohn Marino.Fn VOP_SETATTR "struct vnode *vp" "struct vattr *vap" "struct ucred *cred" "struct proc *p" 4386d7f5d3SJohn Marino.Sh DESCRIPTION 4486d7f5d3SJohn MarinoThese entry points manipulate various attributes of a file or directory, 4586d7f5d3SJohn Marinoincluding file permissions, owner, group, size, 4686d7f5d3SJohn Marinoaccess time and modification time. 4786d7f5d3SJohn Marino.Pp 4886d7f5d3SJohn MarinoThe arguments are: 4986d7f5d3SJohn Marino.Bl -tag -width cred 5086d7f5d3SJohn Marino.It Ar vp 5186d7f5d3SJohn Marinothe vnode of the file 5286d7f5d3SJohn Marino.It Ar vap 5386d7f5d3SJohn Marinothe attributes of the file 5486d7f5d3SJohn Marino.It Ar cred 5586d7f5d3SJohn Marinothe user credentials of the calling process 5686d7f5d3SJohn Marino.It Ar p 5786d7f5d3SJohn Marinothe process 5886d7f5d3SJohn Marino.El 5986d7f5d3SJohn Marino.Pp 6086d7f5d3SJohn MarinoAttributes which are not being modified by 6186d7f5d3SJohn Marino.Xr VOP_SETATTR 9 6286d7f5d3SJohn Marinoshould be set to the value 6386d7f5d3SJohn Marino.Dv VNOVAL . 6486d7f5d3SJohn Marino.Sh LOCKS 6586d7f5d3SJohn Marino.Xr VOP_GETATTR 9 6686d7f5d3SJohn Marinoexpects the vnode to be locked on entry and will leave the vnode locked on 6786d7f5d3SJohn Marinoreturn. 6886d7f5d3SJohn Marino.Pp 6986d7f5d3SJohn Marino.Xr VOP_SETATTR 9 7086d7f5d3SJohn Marinoexpects the vnode to be locked on entry and will leave the vnode locked on 7186d7f5d3SJohn Marinoreturn. 7286d7f5d3SJohn Marino.Sh RETURN VALUES 7386d7f5d3SJohn Marino.Xr VOP_GETATTR 9 7486d7f5d3SJohn Marinoreturns information about the file in 7586d7f5d3SJohn Marino.Fa *vap . 7686d7f5d3SJohn Marino.Xr VOP_SETATTR 9 7786d7f5d3SJohn Marinoreturns zero if the attributes were changed successfully, otherwise an 7886d7f5d3SJohn Marinoappropriate error is returned. 7986d7f5d3SJohn Marino.Sh PSEUDOCODE 8086d7f5d3SJohn Marino.Bd -literal 8186d7f5d3SJohn Marinoint 8286d7f5d3SJohn Marinovop_getattr(struct vnode *vp, struct vattr *vap, 8386d7f5d3SJohn Marino struct ucred *cred, struct proc *p) 8486d7f5d3SJohn Marino{ 8586d7f5d3SJohn Marino /* 8686d7f5d3SJohn Marino * Fill in the contents of *vap with information from 8786d7f5d3SJohn Marino * the filesystem. 8886d7f5d3SJohn Marino */ 8986d7f5d3SJohn Marino ...; 9086d7f5d3SJohn Marino 9186d7f5d3SJohn Marino return 0; 9286d7f5d3SJohn Marino} 9386d7f5d3SJohn Marino 9486d7f5d3SJohn Marinoint 9586d7f5d3SJohn Marinovop_setattr(struct vnode *vp, struct vattr *vap, 9686d7f5d3SJohn Marino struct ucred *cred, struct proc *p) 9786d7f5d3SJohn Marino{ 9886d7f5d3SJohn Marino /* 9986d7f5d3SJohn Marino * Check for unsettable attributes. 10086d7f5d3SJohn Marino */ 10186d7f5d3SJohn Marino if ((vap->va_type != VNON) || (vap->va_nlink != VNOVAL) || 10286d7f5d3SJohn Marino (vap->va_fsid != VNOVAL) || (vap->va_fileid != VNOVAL) || 10386d7f5d3SJohn Marino (vap->va_blocksize != VNOVAL) || (vap->va_rdev != VNOVAL) || 10486d7f5d3SJohn Marino ((int)vap->va_bytes != VNOVAL) || (vap->va_gen != VNOVAL)) { 10586d7f5d3SJohn Marino return (EINVAL); 10686d7f5d3SJohn Marino } 10786d7f5d3SJohn Marino 10886d7f5d3SJohn Marino if (vap->va_flags != VNOVAL) { 10986d7f5d3SJohn Marino /* 11086d7f5d3SJohn Marino * Set the immutable and append flags of the file. 11186d7f5d3SJohn Marino */ 11286d7f5d3SJohn Marino } 11386d7f5d3SJohn Marino 11486d7f5d3SJohn Marino if (vap->va_uid != (uid_t)VNOVAL || vap->va_gid != (gid_t)VNOVAL) { 11586d7f5d3SJohn Marino /* 11686d7f5d3SJohn Marino * Change owner and/or group of the file. 11786d7f5d3SJohn Marino */ 11886d7f5d3SJohn Marino } 11986d7f5d3SJohn Marino 12086d7f5d3SJohn Marino if (vap->va_size != VNOVAL) { 12186d7f5d3SJohn Marino /* 12286d7f5d3SJohn Marino * Truncate the file to the specified size. 12386d7f5d3SJohn Marino */ 12486d7f5d3SJohn Marino } 12586d7f5d3SJohn Marino 12686d7f5d3SJohn Marino if (vap->va_atime.tv_sec != VNOVAL || vap->va_mtime.tv_sec != VNOVAL) { 12786d7f5d3SJohn Marino /* 12886d7f5d3SJohn Marino * Change access and/or modification time of file. 12986d7f5d3SJohn Marino */ 13086d7f5d3SJohn Marino } 13186d7f5d3SJohn Marino 13286d7f5d3SJohn Marino if (vap->va_mode != (mode_t)VNOVAL) { 13386d7f5d3SJohn Marino /* 13486d7f5d3SJohn Marino * Change permissions of file. 13586d7f5d3SJohn Marino */ 13686d7f5d3SJohn Marino } 13786d7f5d3SJohn Marino 13886d7f5d3SJohn Marino return 0; 13986d7f5d3SJohn Marino} 14086d7f5d3SJohn Marino.Ed 14186d7f5d3SJohn Marino.Sh ERRORS 14286d7f5d3SJohn Marino.Bl -tag -width Er 14386d7f5d3SJohn Marino.It Bq Er EPERM 14486d7f5d3SJohn MarinoThe file is immutable 14586d7f5d3SJohn Marino.It Bq Er EACCES 14686d7f5d3SJohn MarinoPermission denied 14786d7f5d3SJohn Marino.It Bq Er EROFS 14886d7f5d3SJohn MarinoThe filesystem is readonly 14986d7f5d3SJohn Marino.El 15086d7f5d3SJohn Marino.Sh SEE ALSO 15186d7f5d3SJohn Marino.Xr vnode 9 , 15286d7f5d3SJohn Marino.Xr VOP_ACCESS 9 15386d7f5d3SJohn Marino.Sh AUTHORS 15486d7f5d3SJohn MarinoThis man page was written by 15586d7f5d3SJohn Marino.An Doug Rabson . 156