Sat 04 Aug 2012 02:47:54 PM UTC, original submission:
I've been trying to remove attributes by calling attr_multi, but according to strace the syscall getxattr is being called instead of removexattr.
Looking at the relevant files in package version 2.4.46 we have in include/attributes.h:
/*
- Valid values of am_opcode.
*/
#define ATTR_OP_GET 1 /* return the indicated attr's value */
#define ATTR_OP_SET 2 /* set/create the indicated attr/value pair */
#define ATTR_OP_REMOVE 3 /* remove the indicated attr */
and in libattr/libattr.c:
static int
attr_single(const char path, attr_multiop_t op, int flags)
{
int r = -1;
errno = -EINVAL;
flags |= op->am_flags;
if (op->am_opcode & ATTR_OP_GET)
r = attr_get(path, op->am_attrname, op->am_attrvalue,
&op->am_length, flags);
else if (op->am_opcode & ATTR_OP_SET)
r = attr_set(path, op->am_attrname, op->am_attrvalue,
op->am_length, flags);
else if (op->am_opcode & ATTR_OP_REMOVE)
r = attr_remove(path, op->am_attrname, flags);
return r;
}
since ATTR_OP_GET & ATTR_OP_REMOVE == 1, the dispatching code above will never call the attr_remove() function. The code needs to either
- change the order of comparisons
- switch to comparing with == instead of bitbanging
- redefining ATTR_OP_REMOVE to 4 instead of 3.
|