FreeBSD/sys/kern/vfs_vnops.c
/*
 * Simplified in-kernel wrapper calls for extended attribute access.
 * Both calls pass in a NULL credential, authorizing as "kernel" access.
 * Set IO_NODELOCKED in ioflg if the vnode is already locked.
 */
Simplified in-kernel wrapper calls for extended attribute access.
Both calls pass in a NULL credential, authorizing as "kernel" access.
Set IO_NODELOCKED in ioflg if the vnode is already locked.
Simplified in - kernel wrapper calls for extended attribute access . Both calls pass in a NULL credential authorizing as " kernel " access . Set IO_NODELOCKED in ioflg if the vnode is already locked .
int
vn_extattr_get(struct vnode *vp, int ioflg, int attrnamespace,
    const char *attrname, int *buflen, char *buf, struct thread *td)
{
	struct uio	auio;
	struct iovec	iov;
	int	error;
	iov.iov_len = *buflen;
	iov.iov_base = buf;
	auio.uio_iov = &iov;
	auio.uio_iovcnt = 1;
	auio.uio_rw = UIO_READ;
	auio.uio_segflg = UIO_SYSSPACE;
	auio.uio_td = td;
	auio.uio_offset = 0;
	auio.uio_resid = *buflen;
	if ((ioflg & IO_NODELOCKED) == 0)
		vn_lock(vp, LK_SHARED | LK_RETRY);
	ASSERT_VOP_LOCKED(vp, "IO_NODELOCKED with no vp lock held");
	error = VOP_GETEXTATTR(vp, attrnamespace, attrname, &auio, NULL, NULL,
	    td);
	if ((ioflg & IO_NODELOCKED) == 0)
		VOP_UNLOCK(vp, 0);
	if (error == 0) {
		*buflen = *buflen - auio.uio_resid;
	}
	return (error);
}
int vn_extattr_get ( struct vnode * vp , int ioflg , int attrnamespace , const char * attrname , int * buflen , char * buf , struct thread * td ) { struct uio auio ; struct iovec iov ; int error ; iov . iov_len = * buflen ; iov . iov_base = buf ; auio . uio_iov = & iov ; auio . uio_iovcnt = 1 ; auio . uio_rw = UIO_READ ; auio . uio_segflg = UIO_SYSSPACE ; auio . uio_td = td ; auio . uio_offset = 0 ; auio . uio_resid = * buflen ; if ( ( ioflg & IO_NODELOCKED ) == 0 ) vn_lock ( vp , LK_SHARED | LK_RETRY ) ; ASSERT_VOP_LOCKED ( vp , " " ) ; error = VOP_GETEXTATTR ( vp , attrnamespace , attrname , & auio , NULL , NULL , td ) ; if ( ( ioflg & IO_NODELOCKED ) == 0 ) VOP_UNLOCK ( vp , 0 ) ; if ( error == 0 ) { * buflen = * buflen - auio . uio_resid ; } return ( error ) ; }
Simplified in-kernel wrapper calls for extended attribute access.
Simplified in - kernel wrapper calls for extended attribute access .
/* authorize attribute retrieval as kernel */