1.\" -*- nroff -*- 2.\" -*- nroff -*- 3.\" 4.\" Copyright (c) 1996 Doug Rabson 5.\" 6.\" All rights reserved. 7.\" 8.\" This program is free software. 9.\" 10.\" Redistribution and use in source and binary forms, with or without 11.\" modification, are permitted provided that the following conditions 12.\" are met: 13.\" 1. Redistributions of source code must retain the above copyright 14.\" notice, this list of conditions and the following disclaimer. 15.\" 2. Redistributions in binary form must reproduce the above copyright 16.\" notice, this list of conditions and the following disclaimer in the 17.\" documentation and/or other materials provided with the distribution. 18.\" 19.\" THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY EXPRESS OR 20.\" IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES 21.\" OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. 22.\" IN NO EVENT SHALL THE DEVELOPERS BE LIABLE FOR ANY DIRECT, INDIRECT, 23.\" INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT 24.\" NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 25.\" DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 26.\" THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 27.\" (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF 28.\" THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 29.\" 30.\" $FreeBSD$ 31.\" 32.Dd July 24, 1996 33.Os 34.Dt VOP_ACCESS 9 35.Sh NAME 36.Nm VOP_ACCESS 37.Nd "check access permissions of a file or Unix domain socket" 38.Sh SYNOPSIS 39.In sys/param.h 40.In sys/vnode.h 41.Ft int 42.Fn VOP_ACCESS "struct vnode *vp" "accmode_t accmode" "struct ucred *cred" "struct thread *td" 43.Sh DESCRIPTION 44This entry point checks the access permissions of the file against the 45given credentials. 46.Pp 47Its arguments are: 48.Bl -tag -width accmode 49.It Fa vp 50The vnode of the file to check. 51.It Fa accmode 52The type of access required. 53.It Fa cred 54The user credentials to check. 55.It Fa td 56The thread which is checking. 57.El 58.Pp 59The 60.Fa accmode 61is a mask which can contain flags described in <sys/vnode.h>, e.g. 62.Dv VREAD , 63.Dv VWRITE 64or 65.Dv VEXEC . 66.Sh LOCKS 67The vnode will be locked on entry and should remain locked on return. 68.Sh RETURN VALUES 69If the file is accessible in the specified way, then zero is returned, 70otherwise an appropriate error code is returned. 71.Sh PSEUDOCODE 72.Bd -literal 73int 74vop_access(struct vnode *vp, accmode_t accmode, struct ucred *cred, struct thread *td) 75{ 76 int error; 77 78 /* 79 * Disallow write attempts on read-only file systems; 80 * unless the file is a socket, fifo, or a block or 81 * character device resident on the filesystem. 82 */ 83 if (accmode & VWRITE) { 84 switch (vp->v_type) { 85 case VDIR: 86 case VLNK: 87 case VREG: 88 if (vp->v_mount->mnt_flag & MNT_RDONLY) 89 return EROFS; 90 91 break; 92 } 93 } 94 95 /* If immutable bit set, nobody gets to write it. */ 96 if ((accmode & VWRITE) && vp has immutable bit set) 97 return (EPERM); 98 99 error = vaccess(vp->v_type, mode of vp, owner of vp, 100 group of vp, ap->a_accmode, ap->a_cred, NULL); 101 102 return (error); 103} 104.Ed 105.Sh ERRORS 106.Bl -tag -width Er 107.It Bq Er EPERM 108An attempt was made to change an immutable file. 109.It Bq Er EACCES 110The permission bits the file mode or the ACL do not permit the 111requested access. 112.El 113.Sh SEE ALSO 114.Xr vaccess 9 , 115.Xr vaccess_acl_posix1e 9 , 116.Xr vnode 9 117.Sh AUTHORS 118This manual page was written by 119.An Doug Rabson . 120