FUSE extended attribute patches available

Kenneth D. Merry ken at FreeBSD.ORG
Mon Mar 7 16:15:04 UTC 2016


On Sat, Mar 05, 2016 at 22:06:40 -0500, Rick Macklem wrote:
> Ken Merry wrote:
> > I have patches for FreeBSD???s FUSE filesystem kernel module to support
> > extended attributes:
> > 
> > https://people.freebsd.org/~ken/fuse_extattr.20160229.1.txt
> > 
> The only bit of code I have that might be useful for this patch is:
>   	case FUSE_GETXATTR:
>   	case FUSE_LISTXATTR:
> ! 		/*
> ! 		 * These can have varying response lengths, and 0 length
> ! 		 * isn't necessarily invalid.
> ! 		 */
> ! 		err = 0;
> *** I came up with this:
> 		fgin = (struct fuse_getxattr_in *)
> 		    ((char *)ftick->tk_ms_fiov.base +
> 		     sizeof(struct fuse_in_header));
> 		if (fgin->size == 0)
> 			err = (blen == sizeof(struct fuse_getxattr_out)) ? 0 :
> 			    EINVAL;
> 		else
> 			err = (blen <= fgin->size) ? 0 : EINVAL;
>   		break;
> I think I got the size check right?

I think that is correct, yes.

> The big question is...
> What to do with the NAMESPACE?
> - My code fails for SYSTEM and does USER without prepending "user.".
>   (That seemed to be what rwatson@ felt was reasonable. I thought our
>    discussion was on a mailing list, but I can't find it.)
>   I've cc'd him. Maybe he can comment again.

IBM's LTFS at least seems to require the "user." prefix on Linux.  For
context, this code supports Windows, Linux and MacOS X.  So the "#else"
case is Linux.  Here's the code in question:

/**
 * Strip a Linux namespace prefix from the given xattr name and return the position of the suffix.
 * If the name is "user.X", return the "X" portion. Otherwise, return an error.
 * This function does nothing on Mac OS X.
 * @param name Name to strip.
 * @return A pointer to the name suffix, or NULL to indicate an invalid name. On Mac OS X,
 *         always returns @name.
 */
const char *_xattr_strip_name(const char *name)
{
#if (defined (__APPLE__) || defined (mingw_PLATFORM))
        return name;
#else   
        if (strstr(name, "user.") == name)
                return name + 5;
        else
                return NULL;
#endif
}

I can certainly change it to do whatever is the correct answer on FreeBSD.
It looks like for FUSE with MacOS and Windows, they expect just the
attribute name without a namespace prefix.

> - If you stick with prepending "user." or "system." there needs to be
>   some way to bypass this so that attributes that don't start in "user."
>   or "system." can be accessed. I've seen "trusted." and "glusterfs."
>   on GlusterFS.
>   --> Maybe a new namespace called something like "nil" that just bypasses
>       any USER or SYSTEM checks?
> 

I'll respond to rwatson's email on this part...

Ken
-- 
Kenneth Merry
ken at FreeBSD.ORG


More information about the freebsd-fs mailing list