* Copyright (c) 1982, 1986 Regents of the University of California.
* All rights reserved. The Berkeley software License Agreement
* specifies the terms and conditions for redistribution.
* @(#)vfs_vnops.c 7.1 (Berkeley) %G%
#include "../machine/reg.h"
* Check mode permission on inode pointer.
* Mode is READ, WRITE or EXEC.
* In the case of WRITE, the
* read-only status of the file
* Also in WRITE, prototype text
* segments cannot be written.
* The mode is shifted to select
* the owner/group/other fields.
* The super user is granted all
register struct inode
*ip
;
* Disallow write attempts on read-only
* file systems; unless the file is a block
* or character device resident on the
if (ip
->i_fs
->fs_ronly
!= 0) {
if ((ip
->i_mode
& IFMT
) != IFCHR
&&
(ip
->i_mode
& IFMT
) != IFBLK
) {
* If there's shared text associated with
* the inode, try to free it up once. If
* we fail, we can't allow writing.
if (ip
->i_flag
& ITEXT
) {
* If you're the super-user,
* Access check is based on only
* one of owner, group, public.
* If not owner, then check group.
* If not a member of the group, then
if (u
.u_uid
!= ip
->i_uid
) {
if (u
.u_gid
== ip
->i_gid
)
for (; gp
< &u
.u_groups
[NGROUPS
] && *gp
!= NOGROUP
; gp
++)
* Look up a pathname and test if
* the resultant inode is owned by the
* If not, try for super-user.
* If permission is granted,
register struct inode
*ip
;
register struct nameidata
*ndp
= &u
.u_nd
;
ndp
->ni_nameiop
= LOOKUP
| follow
;
ndp
->ni_segflg
= UIO_USERSPACE
;
if (u
.u_uid
== ip
->i_uid
)
* Test if the current user is the