freebsd5/sys/ufs/ffs/ffs_vnops.c
/*
 * Vnode operating to retrieve a named extended attribute.
 *
 * Locate a particular EA (nspace:name) in the area (ptr:length), and return
 * the length of the EA, and possibly the pointer to the entry and to the data.
 */
Vnode operating to retrieve a named extended attribute.
Locate a particular EA (nspace:name) in the area (ptr:length), and return
the length of the EA, and possibly the pointer to the entry and to the data.
Vnode operating to retrieve a named extended attribute . Locate a particular EA ( nspace : name ) in the area ( ptr : length ) and return the length of the EA and possibly the pointer to the entry and to the data .
static int
ffs_findextattr(u_char *ptr, u_int length, int nspace, const char *name, u_char **eap, u_char **eac)
{
	u_char *p, *pe, *pn, *p0;
	int eapad1, eapad2, ealength, ealen, nlen;
	uint32_t ul;
	pe = ptr + length;
	nlen = strlen(name);
	for (p = ptr; p < pe; p = pn) {
		p0 = p;
		bcopy(p, &ul, sizeof(ul));
		pn = p + ul;
		if (pn > pe)
			break;
		p += sizeof(uint32_t);
		if (*p != nspace)
			continue;
		p++;
		eapad2 = *p++;
		if (*p != nlen)
			continue;
		p++;
		if (bcmp(p, name, nlen))
			continue;
		ealength = sizeof(uint32_t) + 3 + nlen;
		eapad1 = 8 - (ealength % 8);
		if (eapad1 == 8)
			eapad1 = 0;
		ealength += eapad1;
		ealen = ul - ealength - eapad2;
		p += nlen + eapad1;
		if (eap != NULL)
			*eap = p0;
		if (eac != NULL)
			*eac = p;
		return (ealen);
	}
	return(-1);
}
static int ffs_findextattr ( u_char * ptr , u_int length , int nspace , const char * name , u_char * * eap , u_char * * eac ) { u_char * p , * pe , * pn , * p0 ; int eapad1 , eapad2 , ealength , ealen , nlen ; uint32_t ul ; pe = ptr + length ; nlen = strlen ( name ) ; for ( p = ptr ; p < pe ; p = pn ) { p0 = p ; bcopy ( p , & ul , sizeof ( ul ) ) ; pn = p + ul ; if ( pn > pe ) break ; p += sizeof ( uint32_t ) ; if ( * p != nspace ) continue ; p ++ ; eapad2 = * p ++ ; if ( * p != nlen ) continue ; p ++ ; if ( bcmp ( p , name , nlen ) ) continue ; ealength = sizeof ( uint32_t ) + 3 + nlen ; eapad1 = 8 - ( ealength % 8 ) ; if ( eapad1 == 8 ) eapad1 = 0 ; ealength += eapad1 ; ealen = ul - ealength - eapad2 ; p += nlen + eapad1 ; if ( eap != NULL ) * eap = p0 ; if ( eac != NULL ) * eac = p ; return ( ealen ) ; } return ( -1 ) ; }
Vnode operating to retrieve a named extended attribute.
Vnode operating to retrieve a named extended attribute .
/* make sure this entry is complete */