Skip site navigation (1)Skip section navigation (2)
Date:      Sun, 2 Mar 2025 15:48:42 -0800
From:      Rick Macklem <rick.macklem@gmail.com>
To:        Lionel Cons <lionelcons1972@gmail.com>
Cc:        freebsd-hackers@freebsd.org
Subject:   Re: FreeBSD NFSv4.1 nfsd, named attribute support (OPENATTR)?
Message-ID:  <CAM5tNy4tHt9WFjwj0Zc_pQ4c4DLgr=0UDzcj2vzUjMfTsOH_LA@mail.gmail.com>
In-Reply-To: <CAPJSo4WLs5e0PJY1iO3wHe8L61AgAu5fQbNjmBYhx_-7topOcg@mail.gmail.com>
References:  <CALXu0Ufwu_tsZW7mgLLGySbB_XMVOChwEyK1Z%2Br3rpYiXiyXGg@mail.gmail.com> <CAM5tNy5HLEGZc=EMuD%2BQFhFRZg5SwmN6P5KvwMFPO5%2B3Cckh3g@mail.gmail.com> <CAPJSo4Uzhapmpk5zovhycMKXS-egZ3xsC_eFUQWdEUdtKYaMNQ@mail.gmail.com> <CAPJSo4WLs5e0PJY1iO3wHe8L61AgAu5fQbNjmBYhx_-7topOcg@mail.gmail.com>

index | next in thread | previous in thread | raw e-mail

[-- Attachment #1 --]
On Tue, Feb 18, 2025 at 4:14 PM Lionel Cons <lionelcons1972@gmail.com> wrote:
>
> On Mon, 20 Jan 2025 at 13:15, Lionel Cons <lionelcons1972@gmail.com> wrote:
> >
> > On Sun, 12 Jan 2025 at 16:50, Rick Macklem <rick.macklem@gmail.com> wrote:
> > >
> > > On Sun, Jan 12, 2025 at 2:09 AM Cedric Blancher
> > > <cedric.blancher@gmail.com> wrote:
> > > >
> > > > Good morning!
> > > >
> > > > Does FreeBSD NFSv4.1 nfsd support named attributes (e.g. OPENATTR),
> > > > per https://datatracker.ietf.org/doc/html/rfc5661#section-5.3
> > > >
> > > > ZFS and Solaris UFS support named attributes (via O_XATTR), does
> > > > FreeBSD do it too?
> > > No. fork files/resource forks (or whatever you choose to call them)
> > > have been discussed multiple times.
> > >
> > > If I recall correctly, one showstopper was fixing the archive tools.
> > > There was also the generic argument that Linux doesn't support them.
> > > Then there was the issue of what VFS/VOP changes were required.
> > > (The FreeBSD VFS carries vnode locks across VOP calls and is at
> > > what I would call a lower level than Solaris.)
> > > --> Which all comes down to who will do the work?
> > >
> > > If I recall correctly, there was a time when a group associated with
> > > CERN needed them to transition away from Solaris.
> >
> > That was my team, and there is still the need to do it. What keeps us
> > FRUSTRATED is the lack of progress. Well, and "no", we cannot do it
> > ourselves, this is well beyond the expertise my team has.
>
> Does anyone have any suggestions on how to proceed?
The patch found here does the very basics for ZFS (no NFSv4 code yet).
https://people.freebsd.org/~rmacklem/xattr.patch

It will only work for a ZFS file system and I think you need to set the
xattr property to dir.
Once you apply the patch to a kernel and rebuild/run that kernel,
you need to copy /usr/src/sys/sys/fcntl.h to /usr/include/sys.
The attached trivial test priogram should work.
(It uses O_NAMEDATTR in a manner similar to Solaris, although
I do not have a Solaris system to play with, so the semantics might
not be exactly the same?)

If people pick this up and test it, I will be inspired to continue to
work on it.

I will come up with NFSv4 code relatively soon and put this up
on github someday. I have no idea if this will ever make it into
FreeBSD's main?

rick
ps: See the attached trivial test program for how to use it.

>
> Lionel
>

[-- Attachment #2 --]
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <fcntl.h>
#include <errno.h>
#include <dirent.h>
#include <sys/param.h>
#include <sys/types.h>
#include <sys/stat.h>
#include <err.h>
#include <unistd.h>

int
main(int argc, char *argv[])
{
	int fd, fd2;
	char buf[512], *cp;
	ssize_t siz;
	off_t offs;
	struct dirent *dp;

	if (argc != 2)
		errx(1, "Usage: xattrtest <file>");
	fd = open(argv[1], O_NAMEDATTR, 0);
	if (fd < 0)
		err(1, "can't open %s", argv[1]);
	printf("Open xattr successful\n");
	siz = getdents(fd, buf, 512);
	if (siz < 0)
		err(1, "Cannot getdents");
	cp = buf;
	while (cp < &buf[siz]) {
		dp = (struct dirent *)cp;
		printf("name=%s\n", dp->d_name);
		cp += dp->d_reclen;
	}
	fd2 = openat(fd, "def", O_CREAT | O_RDWR | O_NAMEDATTR);
	if (fd2 < 0)
		err(1, "can't openat def");
	siz = write(fd2, "xxxyyy", 6);
	if (siz != 6)
		err(1, "can't write xxxyyy");
	offs = lseek(fd2, 0, SEEK_SET);
	if (offs != 0)
		err(1, "Can't lseek %ld", offs);
	siz = read(fd2, buf, 512);
	if (siz != 6)
		err(1, "Can't read xxxyyy");
	buf[6] = '\0';
	printf("got=%s\n", buf);
	close(fd);
}
help

Want to link to this message? Use this
URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?CAM5tNy4tHt9WFjwj0Zc_pQ4c4DLgr=0UDzcj2vzUjMfTsOH_LA>