FreeBSD/sys/fs/unionfs/union_vnops.c
/*
 * Check the access mode toward shadow file/dir.
 */
Check the access mode toward shadow file/dir.
Check the access mode toward shadow file / dir .
static int
unionfs_check_corrected_access(accmode_t accmode,
			     struct vattr *va,
			     struct ucred *cred)
{
	int		count;
	uid_t		uid;	
	gid_t		gid;	
	u_short		vmode;	
	u_short		mask;
	mask = 0;
	uid = va->va_uid;
	gid = va->va_gid;
	vmode = va->va_mode;
	if (cred->cr_uid == uid) {
		if (accmode & VEXEC)
			mask |= S_IXUSR;
		if (accmode & VREAD)
			mask |= S_IRUSR;
		if (accmode & VWRITE)
			mask |= S_IWUSR;
		return ((vmode & mask) == mask ? 0 : EACCES);
	}
	count = 0;
	if (groupmember(gid, cred)) {
		if (accmode & VEXEC)
			mask |= S_IXGRP;
		if (accmode & VREAD)
			mask |= S_IRGRP;
		if (accmode & VWRITE)
			mask |= S_IWGRP;
		return ((vmode & mask) == mask ? 0 : EACCES);
	}
	if (accmode & VEXEC)
		mask |= S_IXOTH;
	if (accmode & VREAD)
		mask |= S_IROTH;
	if (accmode & VWRITE)
		mask |= S_IWOTH;
	return ((vmode & mask) == mask ? 0 : EACCES);
}
static int unionfs_check_corrected_access ( accmode_t accmode , struct vattr * va , struct ucred * cred ) { int count ; uid_t uid ; gid_t gid ; u_short vmode ; u_short mask ; mask = 0 ; uid = va -> va_uid ; gid = va -> va_gid ; vmode = va -> va_mode ; if ( cred -> cr_uid == uid ) { if ( accmode & VEXEC ) mask |= S_IXUSR ; if ( accmode & VREAD ) mask |= S_IRUSR ; if ( accmode & VWRITE ) mask |= S_IWUSR ; return ( ( vmode & mask ) == mask ? 0 : EACCES ) ; } count = 0 ; if ( groupmember ( gid , cred ) ) { if ( accmode & VEXEC ) mask |= S_IXGRP ; if ( accmode & VREAD ) mask |= S_IRGRP ; if ( accmode & VWRITE ) mask |= S_IWGRP ; return ( ( vmode & mask ) == mask ? 0 : EACCES ) ; } if ( accmode & VEXEC ) mask |= S_IXOTH ; if ( accmode & VREAD ) mask |= S_IROTH ; if ( accmode & VWRITE ) mask |= S_IWOTH ; return ( ( vmode & mask ) == mask ? 0 : EACCES ) ; }
Check the access mode toward shadow file/dir.
Check the access mode toward shadow file / dir .
/* upper side vnode's uid */ /* upper side vnode's gid */ /* upper side vnode's mode */ /* check owner */ /* check group */ /* check other */