From: Nicolas Thery Date: Wed, 19 Aug 2009 05:20:06 +0000 (+0200) Subject: isofs: refactor vop_access to use vop_helper_access X-Git-Tag: v2.4.0~138^2~11 X-Git-Url: https://gitweb.dragonflybsd.org/~nant/dragonfly.git/commitdiff_plain/e01206711a914df2ef343b796769503a3b2f46fa isofs: refactor vop_access to use vop_helper_access --- diff --git a/sys/vfs/isofs/cd9660/cd9660_vnops.c b/sys/vfs/isofs/cd9660/cd9660_vnops.c index 82392931f8..be863c87fd 100644 --- a/sys/vfs/isofs/cd9660/cd9660_vnops.c +++ b/sys/vfs/isofs/cd9660/cd9660_vnops.c @@ -131,66 +131,10 @@ cd9660_access(struct vop_access_args *ap) { struct vnode *vp = ap->a_vp; struct iso_node *ip = VTOI(vp); - struct ucred *cred = ap->a_cred; - mode_t mask, mode = ap->a_mode; - gid_t *gp; - int i; - /* - * Disallow write attempts unless the file is a socket, - * fifo, or a block or character device resident on the - * file system. - */ - if (mode & VWRITE) { - switch (vp->v_type) { - case VDIR: - case VLNK: - case VREG: - return (EROFS); - /* NOT REACHED */ - default: - break; - } - } - - /* User id 0 always gets access. */ - if (cred->cr_uid == 0) - return (0); - - mask = 0; - - /* Otherwise, check the owner. */ - if (cred->cr_uid == ip->inode.iso_uid) { - if (mode & VEXEC) - mask |= S_IXUSR; - if (mode & VREAD) - mask |= S_IRUSR; - if (mode & VWRITE) - mask |= S_IWUSR; - return ((ip->inode.iso_mode & mask) == mask ? 0 : EACCES); - } - - /* Otherwise, check the groups. */ - for (i = 0, gp = cred->cr_groups; i < cred->cr_ngroups; i++, gp++) - if (ip->inode.iso_gid == *gp) { - if (mode & VEXEC) - mask |= S_IXGRP; - if (mode & VREAD) - mask |= S_IRGRP; - if (mode & VWRITE) - mask |= S_IWGRP; - return ((ip->inode.iso_mode & mask) == mask ? - 0 : EACCES); - } - - /* Otherwise, check everyone else. */ - if (mode & VEXEC) - mask |= S_IXOTH; - if (mode & VREAD) - mask |= S_IROTH; - if (mode & VWRITE) - mask |= S_IWOTH; - return ((ip->inode.iso_mode & mask) == mask ? 0 : EACCES); + KKASSERT(vp->v_mount->mnt_flag & MNT_RDONLY); + return (vop_helper_access(ap, ip->inode.iso_uid, ip->inode.iso_gid, + ip->inode.iso_mode, 0)); } /*