New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
x/sys/unix: Listxattr on FreeBSD loses namespace info #54357
Comments
cc @golang/freebsd |
Modifying returned data in this way would probably break some existing code somewhere. Also, when called with zero sized buffer, Perhaps we could add a set of new functions (something like |
Yeah... The only way I see existing code working at the moment is if it assumes that only user namespace attributes are returned, and then prefixes them by itself. But yeah, modifying the returned data certainly has pitfalls. |
There's a |
Another data point. The FUSE implementation does prepend each attribute name with "namespace." |
I did some further digging.. there's more to it than just the namespace prefixes. The actual buffer formats differ. extattr_list_file (FreeBSD) llistxattr (Linux) Both call I don't think we should be doing this kind of translation on the Go side. I had some really nasty corner cases doing something similar with the direntries for the FreeBSD 11 <-> 12 64bit inode translation shim. I think we should just provide the full FreeBSD interface and that's it. |
Change https://go.dev/cl/430215 mentions this issue: |
@calmh Would the approach in the above CL be helpful for your use case? |
Yes, being able to specify the namespace solves my use case. 👍 However, I still think the existing functions should be either changed or perhaps deprecated, as the data they return can't be usefully interpreted, as we don't know from which namespace the returned attribute names come. |
Current extended attributes API mixes together attributes from different namespaces without a way to separate them. Add versions of *listxattr functions that return attributes only from the specified namespace. For golang/go#54357 Change-Id: I605d677dd2f2a17541bc02f3146a7509c69269c9 Reviewed-on: https://go-review.googlesource.com/c/sys/+/430215 Reviewed-by: Yuval Pavel Zholkover <paulzhol@gmail.com> Reviewed-by: Ian Lance Taylor <iant@google.com> Run-TryBot: Dmitri Goutnik <dgoutnik@gmail.com> Reviewed-by: Tobias Klauser <tobias.klauser@gmail.com> TryBot-Result: Gopher Robot <gobot@golang.org> Auto-Submit: Jenny Rakoczy <jenny@golang.org> Reviewed-by: Jenny Rakoczy <jenny@golang.org>
I believe this issue was resolved by the above commit, closing. |
File extended attributes on FreeBSD (and NetBSD) have a namespace which is either
user
orsystem
. This is represented by an enum in the syscall API. In the Go package, it's represented by prefixing the name withuser.
orsystem.
, like how it works in Linux. When listing extended attributes (at the syscall level) you need to specify the namespace. The Go package lists both the system and user namespaces and merges the results, but doesn't add any prefix so the returned list of attribute names isn't usable -- we don't know the namespace each came from.A test case:
which returns the following list of attributes (when run as a superuser who can set
system
namespace attributes):(that's
length, name, length, name
so"foo", "bar"
)Actually trying to
unix.Lgetxattr
"foo"
or"bar"
returnsENOATTR
, as these do not exist without a namespace.Probably
Llistxattr
(andListxattr
) should synthesize the namespace prefix in the listing.The text was updated successfully, but these errors were encountered: