FreeBSD/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/zfs_vnops.c
/*
 * Vnode operating to retrieve a named extended attribute.
 */
Vnode operating to retrieve a named extended attribute.
Vnode operating to retrieve a named extended attribute .
static int
zfs_getextattr(struct vop_getextattr_args *ap)
{
	zfsvfs_t *zfsvfs = VTOZ(ap->a_vp)->z_zfsvfs;
	struct thread *td = ap->a_td;
	struct nameidata nd;
	char attrname[255];
	struct vattr va;
	vnode_t *xvp = NULL, *vp;
	int error, flags;
	error = extattr_check_cred(ap->a_vp, ap->a_attrnamespace,
	    ap->a_cred, ap->a_td, VREAD);
	if (error != 0)
		return (error);
	error = zfs_create_attrname(ap->a_attrnamespace, ap->a_name, attrname,
	    sizeof(attrname));
	if (error != 0)
		return (error);
	ZFS_ENTER(zfsvfs);
	error = zfs_lookup(ap->a_vp, NULL, &xvp, NULL, 0, ap->a_cred, td,
	    LOOKUP_XATTR);
	if (error != 0) {
		ZFS_EXIT(zfsvfs);
		return (error);
	}
	flags = FREAD;
	NDINIT_ATVP(&nd, LOOKUP, NOFOLLOW, UIO_SYSSPACE, attrname,
	    xvp, td);
	error = vn_open_cred(&nd, &flags, 0, 0, ap->a_cred, NULL);
	vp = nd.ni_vp;
	NDFREE(&nd, NDF_ONLY_PNBUF);
	if (error != 0) {
		ZFS_EXIT(zfsvfs);
		if (error == ENOENT)
			error = ENOATTR;
		return (error);
	}
	if (ap->a_size != NULL) {
		error = VOP_GETATTR(vp, &va, ap->a_cred);
		if (error == 0)
			*ap->a_size = (size_t)va.va_size;
	} else if (ap->a_uio != NULL)
		error = VOP_READ(vp, ap->a_uio, IO_UNIT, ap->a_cred);
	VOP_UNLOCK(vp, 0);
	vn_close(vp, flags, ap->a_cred, td);
	ZFS_EXIT(zfsvfs);
	return (error);
}
static int zfs_getextattr ( struct vop_getextattr_args * ap ) { zfsvfs_t * zfsvfs = VTOZ ( ap -> a_vp ) -> z_zfsvfs ; struct thread * td = ap -> a_td ; struct nameidata nd ; char attrname [ 255 ] ; struct vattr va ; vnode_t * xvp = NULL , * vp ; int error , flags ; error = extattr_check_cred ( ap -> a_vp , ap -> a_attrnamespace , ap -> a_cred , ap -> a_td , VREAD ) ; if ( error != 0 ) return ( error ) ; error = zfs_create_attrname ( ap -> a_attrnamespace , ap -> a_name , attrname , sizeof ( attrname ) ) ; if ( error != 0 ) return ( error ) ; ZFS_ENTER ( zfsvfs ) ; error = zfs_lookup ( ap -> a_vp , NULL , & xvp , NULL , 0 , ap -> a_cred , td , LOOKUP_XATTR ) ; if ( error != 0 ) { ZFS_EXIT ( zfsvfs ) ; return ( error ) ; } flags = FREAD ; NDINIT_ATVP ( & nd , LOOKUP , NOFOLLOW , UIO_SYSSPACE , attrname , xvp , td ) ; error = vn_open_cred ( & nd , & flags , 0 , 0 , ap -> a_cred , NULL ) ; vp = nd . ni_vp ; NDFREE ( & nd , NDF_ONLY_PNBUF ) ; if ( error != 0 ) { ZFS_EXIT ( zfsvfs ) ; if ( error == ENOENT ) error = ENOATTR ; return ( error ) ; } if ( ap -> a_size != NULL ) { error = VOP_GETATTR ( vp , & va , ap -> a_cred ) ; if ( error == 0 ) * ap -> a_size = ( size_t ) va . va_size ; } else if ( ap -> a_uio != NULL ) error = VOP_READ ( vp , ap -> a_uio , IO_UNIT , ap -> a_cred ) ; VOP_UNLOCK ( vp , 0 ) ; vn_close ( vp , flags , ap -> a_cred , td ) ; ZFS_EXIT ( zfsvfs ) ; return ( error ) ; }
Vnode operating to retrieve a named extended attribute.
Vnode operating to retrieve a named extended attribute .
/*
vop_getextattr {
	IN struct vnode *a_vp;
	IN int a_attrnamespace;
	IN const char *a_name;
	INOUT struct uio *a_uio;
	OUT size_t *a_size;
	IN struct ucred *a_cred;
	IN struct thread *a_td;
};
*/