Skip site navigation (1)Skip section navigation (2)
Date:      Mon, 7 Mar 2016 11:14:54 -0500
From:      "Kenneth D. Merry" <ken@FreeBSD.ORG>
To:        Rick Macklem <rmacklem@uoguelph.ca>
Cc:        fs@freebsd.org, scsi@freebsd.org, Robert Watson <rwatson@freebsd.org>
Subject:   Re: FUSE extended attribute patches available
Message-ID:  <20160307161454.GA3501@mithlond.kdm.org>
In-Reply-To: <800018199.6694281.1457233600357.JavaMail.zimbra@uoguelph.ca>
References:  <CD5FCB90-1952-4014-BBE0-1BFF1EF85E17@freebsd.org> <800018199.6694281.1457233600357.JavaMail.zimbra@uoguelph.ca>

next in thread | previous in thread | raw e-mail | index | archive | help
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@FreeBSD.ORG



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?20160307161454.GA3501>