FreeBSD/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/zfs_acl.c
/*
 * Read an external acl object.  If the intent is to modify, always
 * create a new acl and leave any cached acl in place.
 */
Read an external acl object.  If the intent is to modify, always
create a new acl and leave any cached acl in place.
Read an external acl object . If the intent is to modify always create a new acl and leave any cached acl in place .
static int
zfs_acl_node_read(znode_t *zp, zfs_acl_t **aclpp, boolean_t will_modify)
{
	zfs_acl_t	*aclp;
	int		aclsize;
	int		acl_count;
	zfs_acl_node_t	*aclnode;
	zfs_acl_phys_t	znode_acl;
	int		version;
	int		error;
	ASSERT(MUTEX_HELD(&zp->z_acl_lock));
	ASSERT_VOP_LOCKED(ZTOV(zp), __func__);
	if (zp->z_acl_cached && !will_modify) {
		*aclpp = zp->z_acl_cached;
		return (0);
	}
	version = zfs_znode_acl_version(zp);
	if ((error = zfs_acl_znode_info(zp, &aclsize,
	    &acl_count, &znode_acl)) != 0) {
		goto done;
	}
	aclp = zfs_acl_alloc(version);
	aclp->z_acl_count = acl_count;
	aclp->z_acl_bytes = aclsize;
	aclnode = zfs_acl_node_alloc(aclsize);
	aclnode->z_ace_count = aclp->z_acl_count;
	aclnode->z_size = aclsize;
	if (!zp->z_is_sa) {
		if (znode_acl.z_acl_extern_obj) {
			error = dmu_read(zp->z_zfsvfs->z_os,
			    znode_acl.z_acl_extern_obj, 0, aclnode->z_size,
			    aclnode->z_acldata, DMU_READ_PREFETCH);
		} else {
			bcopy(znode_acl.z_ace_data, aclnode->z_acldata,
			    aclnode->z_size);
		}
	} else {
		error = sa_lookup(zp->z_sa_hdl, SA_ZPL_DACL_ACES(zp->z_zfsvfs),
		    aclnode->z_acldata, aclnode->z_size);
	}
	if (error != 0) {
		zfs_acl_free(aclp);
		zfs_acl_node_free(aclnode);
		if (error == ECKSUM)
			error = SET_ERROR(EIO);
		goto done;
	}
	list_insert_head(&aclp->z_acl, aclnode);
	*aclpp = aclp;
	if (!will_modify)
		zp->z_acl_cached = aclp;
done:
	return (error);
}
static int zfs_acl_node_read ( znode_t * zp , zfs_acl_t * * aclpp , boolean_t will_modify ) { zfs_acl_t * aclp ; int aclsize ; int acl_count ; zfs_acl_node_t * aclnode ; zfs_acl_phys_t znode_acl ; int version ; int error ; ASSERT ( MUTEX_HELD ( & zp -> z_acl_lock ) ) ; ASSERT_VOP_LOCKED ( ZTOV ( zp ) , __func__ ) ; if ( zp -> z_acl_cached && ! will_modify ) { * aclpp = zp -> z_acl_cached ; return ( 0 ) ; } version = zfs_znode_acl_version ( zp ) ; if ( ( error = zfs_acl_znode_info ( zp , & aclsize , & acl_count , & znode_acl ) ) != 0 ) { goto done ; } aclp = zfs_acl_alloc ( version ) ; aclp -> z_acl_count = acl_count ; aclp -> z_acl_bytes = aclsize ; aclnode = zfs_acl_node_alloc ( aclsize ) ; aclnode -> z_ace_count = aclp -> z_acl_count ; aclnode -> z_size = aclsize ; if ( ! zp -> z_is_sa ) { if ( znode_acl . z_acl_extern_obj ) { error = dmu_read ( zp -> z_zfsvfs -> z_os , znode_acl . z_acl_extern_obj , 0 , aclnode -> z_size , aclnode -> z_acldata , DMU_READ_PREFETCH ) ; } else { bcopy ( znode_acl . z_ace_data , aclnode -> z_acldata , aclnode -> z_size ) ; } } else { error = sa_lookup ( zp -> z_sa_hdl , SA_ZPL_DACL_ACES ( zp -> z_zfsvfs ) , aclnode -> z_acldata , aclnode -> z_size ) ; } if ( error != 0 ) { zfs_acl_free ( aclp ) ; zfs_acl_node_free ( aclnode ) ; if ( error == ECKSUM ) error = SET_ERROR ( EIO ) ; goto done ; } list_insert_head ( & aclp -> z_acl , aclnode ) ; * aclpp = aclp ; if ( ! will_modify ) zp -> z_acl_cached = aclp ; done : return ( error ) ; }
Read an external acl object.
Read an external acl object .
/* convert checksum errors into IO errors */