Implement list of EA return functionality.
Correctly delete EA's when the content length is set to zero. Sponsored by: DARPA & NAI Labs.
This commit is contained in:
parent
8453c174a1
commit
7428de69d2
Notes:
svn2git
2020-12-20 02:59:44 +00:00
svn path=/head/; revision=102175
@ -1396,9 +1396,10 @@ vop_getextattr {
|
||||
{
|
||||
struct inode *ip;
|
||||
struct fs *fs;
|
||||
u_char *eae, *p;
|
||||
u_char *eae, *p, *pe, *pn;
|
||||
struct ufs2_dinode *dp;
|
||||
unsigned easize;
|
||||
uint32_t ul;
|
||||
int error, ealen;
|
||||
|
||||
ip = VTOI(ap->a_vp);
|
||||
@ -1412,6 +1413,7 @@ vop_getextattr {
|
||||
if (error)
|
||||
return (error);
|
||||
easize = dp->di_extsize;
|
||||
if (strlen(ap->a_name) > 0) {
|
||||
error = ENOATTR;
|
||||
ealen = ffs_findextattr(eae, easize,
|
||||
ap->a_attrnamespace, ap->a_name, NULL, &p);
|
||||
@ -1422,6 +1424,28 @@ vop_getextattr {
|
||||
else if (ap->a_uio != NULL)
|
||||
error = uiomove(p, ealen, ap->a_uio);
|
||||
}
|
||||
} else {
|
||||
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++; /* pad2 */
|
||||
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);
|
||||
}
|
||||
}
|
||||
}
|
||||
free(eae, M_TEMP);
|
||||
return(error);
|
||||
}
|
||||
@ -1465,7 +1489,7 @@ vop_setextattr {
|
||||
dp = ip->i_din2;
|
||||
|
||||
/* Calculate the length of the EA entry */
|
||||
if (ap->a_uio == NULL) {
|
||||
if (ap->a_uio == NULL || ap->a_uio->uio_resid == 0) {
|
||||
/* delete */
|
||||
ealength = eapad1 = ealen = eapad2 = eacont = 0;
|
||||
} else {
|
||||
|
Loading…
Reference in New Issue
Block a user