FreeBSD/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/zfs_vnops.c
/*
 * Vnode operation to set a named attribute.
 */
Vnode operation to set a named attribute.
Vnode operation to set a named attribute .
static int
zfs_setextattr(struct vop_setextattr_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, VWRITE);
	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 | CREATE_XATTR_DIR);
	if (error != 0) {
		ZFS_EXIT(zfsvfs);
		return (error);
	}
	flags = FFLAGS(O_WRONLY | O_CREAT);
	NDINIT_ATVP(&nd, LOOKUP, NOFOLLOW, UIO_SYSSPACE, attrname,
	    xvp, td);
	error = vn_open_cred(&nd, &flags, 0600, 0, ap->a_cred, NULL);
	vp = nd.ni_vp;
	NDFREE(&nd, NDF_ONLY_PNBUF);
	if (error != 0) {
		ZFS_EXIT(zfsvfs);
		return (error);
	}
	VATTR_NULL(&va);
	va.va_size = 0;
	error = VOP_SETATTR(vp, &va, ap->a_cred);
	if (error == 0)
		VOP_WRITE(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_setextattr ( struct vop_setextattr_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 , VWRITE ) ; 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 | CREATE_XATTR_DIR ) ; if ( error != 0 ) { ZFS_EXIT ( zfsvfs ) ; return ( error ) ; } flags = FFLAGS ( O_WRONLY | O_CREAT ) ; NDINIT_ATVP ( & nd , LOOKUP , NOFOLLOW , UIO_SYSSPACE , attrname , xvp , td ) ; error = vn_open_cred ( & nd , & flags , 0600 , 0 , ap -> a_cred , NULL ) ; vp = nd . ni_vp ; NDFREE ( & nd , NDF_ONLY_PNBUF ) ; if ( error != 0 ) { ZFS_EXIT ( zfsvfs ) ; return ( error ) ; } VATTR_NULL ( & va ) ; va . va_size = 0 ; error = VOP_SETATTR ( vp , & va , ap -> a_cred ) ; if ( error == 0 ) VOP_WRITE ( 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 operation to set a named attribute.
Vnode operation to set a named attribute .
/*
vop_setextattr {
	IN struct vnode *a_vp;
	IN int a_attrnamespace;
	IN const char *a_name;
	INOUT struct uio *a_uio;
	IN struct ucred *a_cred;
	IN struct thread *a_td;
};
*/