FreeBSD/sys/ufs/ffs/ffs_vnops.c
/*
 * Vnode operation to retrieve extended attributes on a vnode.
 */
Vnode operation to retrieve extended attributes on a vnode.
Vnode operation to retrieve extended attributes on a vnode .
static int
ffs_listextattr(struct vop_listextattr_args *ap)
{
	struct inode *ip;
	u_char *eae, *p, *pe, *pn;
	unsigned easize;
	uint32_t ul;
	int error, ealen;
	ip = VTOI(ap->a_vp);
	if (ap->a_vp->v_type == VCHR || ap->a_vp->v_type == VBLK)
		return (EOPNOTSUPP);
	error = extattr_check_cred(ap->a_vp, ap->a_attrnamespace,
	    ap->a_cred, ap->a_td, VREAD);
	if (error)
		return (error);
	error = ffs_open_ea(ap->a_vp, ap->a_cred, ap->a_td);
	if (error)
		return (error);
	eae = ip->i_ea_area;
	easize = ip->i_ea_len;
	error = 0;
	if (ap->a_size != NULL)
		*ap->a_size = 0;
	pe = eae + easize;
	for(p = eae; error == 0 && p < pe; p = pn) {
		bcopy(p, &ul, sizeof(ul));
		pn = p + ul;
		if (pn > pe)
			break;
		p += sizeof(ul);
		if (*p++ != ap->a_attrnamespace)
			continue;
		p++;	
		ealen = *p;
		if (ap->a_size != NULL) {
			*ap->a_size += ealen + 1;
		} else if (ap->a_uio != NULL) {
			error = uiomove(p, ealen + 1, ap->a_uio);
		}
	}
	ffs_close_ea(ap->a_vp, 0, ap->a_cred, ap->a_td);
	return(error);
}
static int ffs_listextattr ( struct vop_listextattr_args * ap ) { struct inode * ip ; u_char * eae , * p , * pe , * pn ; unsigned easize ; uint32_t ul ; int error , ealen ; ip = VTOI ( ap -> a_vp ) ; if ( ap -> a_vp -> v_type == VCHR || ap -> a_vp -> v_type == VBLK ) return ( EOPNOTSUPP ) ; error = extattr_check_cred ( ap -> a_vp , ap -> a_attrnamespace , ap -> a_cred , ap -> a_td , VREAD ) ; if ( error ) return ( error ) ; error = ffs_open_ea ( ap -> a_vp , ap -> a_cred , ap -> a_td ) ; if ( error ) return ( error ) ; eae = ip -> i_ea_area ; easize = ip -> i_ea_len ; error = 0 ; if ( ap -> a_size != NULL ) * ap -> a_size = 0 ; pe = eae + easize ; for ( p = eae ; error == 0 && p < pe ; p = pn ) { bcopy ( p , & ul , sizeof ( ul ) ) ; pn = p + ul ; if ( pn > pe ) break ; p += sizeof ( ul ) ; if ( * p ++ != ap -> a_attrnamespace ) continue ; p ++ ; ealen = * p ; if ( ap -> a_size != NULL ) { * ap -> a_size += ealen + 1 ; } else if ( ap -> a_uio != NULL ) { error = uiomove ( p , ealen + 1 , ap -> a_uio ) ; } } ffs_close_ea ( ap -> a_vp , 0 , ap -> a_cred , ap -> a_td ) ; return ( error ) ; }
Vnode operation to retrieve extended attributes on a vnode.
Vnode operation to retrieve extended attributes on a vnode .
/*
vop_listextattr {
	IN struct vnode *a_vp;
	IN int a_attrnamespace;
	INOUT struct uio *a_uio;
	OUT size_t *a_size;
	IN struct ucred *a_cred;
	IN struct thread *a_td;
};
*/ /* pad2 */