FreeBSD/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/zfs_acl.c
/*
 * Check accesses of interest (AoI) against attributes of the dataset
 * such as read-only.  Returns zero if no AoI conflict with dataset
 * attributes, otherwise an appropriate errno is returned.
 */
Check accesses of interest (AoI) against attributes of the dataset
such as read-only.  Returns zero if no AoI conflict with dataset
attributes, otherwise an appropriate errno is returned.
Check accesses of interest ( AoI ) against attributes of the dataset such as read - only . Returns zero if no AoI conflict with dataset attributes otherwise an appropriate errno is returned .
static int
zfs_zaccess_dataset_check(znode_t *zp, uint32_t v4_mode)
{
	if ((v4_mode & WRITE_MASK) &&
	    (zp->z_zfsvfs->z_vfs->vfs_flag & VFS_RDONLY) &&
	    (!IS_DEVVP(ZTOV(zp)) ||
	    (IS_DEVVP(ZTOV(zp)) && (v4_mode & WRITE_MASK_ATTRS)))) {
		return (SET_ERROR(EROFS));
	}
	if ((v4_mode & WRITE_MASK_DATA) &&
	    (((ZTOV(zp)->v_type != VDIR) &&
	    (zp->z_pflags & (ZFS_READONLY | ZFS_IMMUTABLE))) ||
	    (ZTOV(zp)->v_type == VDIR &&
	    (zp->z_pflags & ZFS_IMMUTABLE)))) {
		return (SET_ERROR(EPERM));
	}
#ifdef illumos
	if ((v4_mode & (ACE_DELETE | ACE_DELETE_CHILD)) &&
	    (zp->z_pflags & ZFS_NOUNLINK)) {
		return (SET_ERROR(EPERM));
	}
#else
	if ((v4_mode & ACE_DELETE) &&
	    (zp->z_pflags & ZFS_NOUNLINK)) {
		return (EPERM);
	}
#endif
	if (((v4_mode & (ACE_READ_DATA|ACE_EXECUTE)) &&
	    (zp->z_pflags & ZFS_AV_QUARANTINED))) {
		return (SET_ERROR(EACCES));
	}
	return (0);
}
static int zfs_zaccess_dataset_check ( znode_t * zp , uint32_t v4_mode ) { if ( ( v4_mode & WRITE_MASK ) && ( zp -> z_zfsvfs -> z_vfs -> vfs_flag & VFS_RDONLY ) && ( ! IS_DEVVP ( ZTOV ( zp ) ) || ( IS_DEVVP ( ZTOV ( zp ) ) && ( v4_mode & WRITE_MASK_ATTRS ) ) ) ) { return ( SET_ERROR ( EROFS ) ) ; } if ( ( v4_mode & WRITE_MASK_DATA ) && ( ( ( ZTOV ( zp ) -> v_type != VDIR ) && ( zp -> z_pflags & ( ZFS_READONLY | ZFS_IMMUTABLE ) ) ) || ( ZTOV ( zp ) -> v_type == VDIR && ( zp -> z_pflags & ZFS_IMMUTABLE ) ) ) ) { return ( SET_ERROR ( EPERM ) ) ; } #ifdef illumos if ( ( v4_mode & ( ACE_DELETE | ACE_DELETE_CHILD ) ) && ( zp -> z_pflags & ZFS_NOUNLINK ) ) { return ( SET_ERROR ( EPERM ) ) ; } #else if ( ( v4_mode & ACE_DELETE ) && ( zp -> z_pflags & ZFS_NOUNLINK ) ) { return ( EPERM ) ; } #endif if ( ( ( v4_mode & ( ACE_READ_DATA | ACE_EXECUTE ) ) && ( zp -> z_pflags & ZFS_AV_QUARANTINED ) ) ) { return ( SET_ERROR ( EACCES ) ) ; } return ( 0 ) ; }
Check accesses of interest (AoI) against attributes of the dataset
 such as read-only.
Check accesses of interest ( AoI ) against attributes of the dataset such as read - only .
/*
	 * Only check for READONLY on non-directories.
	 */ /*
	 * In FreeBSD we allow to modify directory's content is ZFS_NOUNLINK
	 * (sunlnk) is set. We just don't allow directory removal, which is
	 * handled in zfs_zaccess_delete().
	 */