bugattr - Bugs: bug #37027, attr_multi will never perform a...


bug #37027: attr_multi will never perform a remove operation with ATTR_OP_REMOVE

Submitted by:  None
Submitted on:  Sat 04 Aug 2012 02:47:54 PM UTC  
Category:  None Severity:  3 - Normal
Item Group:  None Status:  Fixed
Privacy:  Public Assigned to:  None
Open/Closed:  Closed

Add a New Comment(Rich Markup)

You are not logged in

Please log in, so followups can be emailed to you.


Fri 15 Sep 2017 01:54:22 PM UTC, comment #1:

Fixed in the following commit:

commit feaf46e9a95cec83c6300649fabd3be9ad508e20
Author: Andreas Gruenbacher <agruen@linbit.com>
Date: Mon Aug 6 13:31:20 2012 +0200

Fix ATTR_OP_REMOVE operation in attr_multi()

The ATTR_OP_GET, ATTR_OP_SET, and ATTR_OP_REMOVE constants are not single bit
values, so use comparisons instead of bit tests to check which of those
operations to perform. (Up to now, ATTR_OP_REMOVE was wrongly detected as

Andreas Gruenbacher <agruen>
Project Administrator
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.



(Note: upload size limit is set to 16384 kB, after insertion of the required escape characters.)

Attach Files:

No files currently attached


Depends on the following items: None found

Items that depend on this one: None found


Carbon-Copy List
  • -email is unavailable- added by agruen (Posted a comment)

    Do you think this task is very important?
    If so, you can add your encouragement to it.
    This task has 0 encouragements so far.

    Only logged-in users can vote.


    Please enter the title of George Orwell's famous dystopian book (it's a date):



    Follow 2 latest changes.

    Date Changed by Updated Field Previous Value => Replaced by
    Fri 15 Sep 2017 01:54:22 PM UTC agruen StatusNone => Fixed
        Open/ClosedOpen => Closed

    Back to the top

    Powered by Savane 3.3