RFC: new module Linux::xattr

Do you have a question? Post it now! No Registration Necessary.  Now with pictures!

Threaded View

This is a new module to work with extended file attributes on Linux
(that's a newish Linux kernel feature that allows you to associate
arbitrary name/value pairs with a file).

I'm proposing Linux::xattr as the namespace (that mirrors the python and
ruby packages). Any comments on the namespace?

Regarding the interface and Perl function names, the command-line tools
in the original attr package from http://acl.bestbits.at/ are named


and their C library functions are named


I was going to make the Perl functions look like the command-line tools
and call them


Any comments on that?

Lastly, the early-draft XS for getfattr() is below.  If an XS expert
could look at it and let me know if I'm doing anything dumb, dangerous
or un-idiomatic it would greatly advance civilization as we know it.  If
more context is desired, the current working code is at

 SV *
getfattr(path, attrname, flags)
        const char *path
         const char *attrname
         int flags
        char * attrvalue;
        char * errstr;
        int rc;
        STRLEN junklen;
        attrvalue = NULL;
        junklen = ATTR_MAX_VALUELEN;

            //I wonder if it would be faster to pre-allocate a buffer
            //and re-use it, but then it wouldn't be thread-safe?
        New(1, attrvalue, ATTR_MAX_VALUELEN, char);

        rc = attr_get(path,attrname,attrvalue,&junklen,flags);

        //uh-oh, attr_get failed
        if (rc == -1){

            //key not found, just return undef
            if(errno == ENOATTR){

            //print warning and return undef
                New(1, errstr, 1000, char);
                warn("attr_get failed: %s",strerror_r(errno,errstr,1000));
        RETVAL = newSVpv(attrvalue, junklen);

Thanks a lot.

Re: RFC: new module Linux::xattr

[A complimentary Cc of this posting was sent to
Kevin Goess
Quoted text here. Click to load it

Well, on OS/2 it is called OS2::ExtAttr.  Do not know how Win* ports
have it (NTFS has this feature too - actually, it is even easier
to accessible - just open "Filename:FieldName").

Quoted text here. Click to load it

OS2::ExtAttr is supposed to be used mostly via tie().  It comes with
Perl distribution; consult it for details.

Hope this helps,

Site Timeline