Skip to content

Commit

Permalink
FreeBSD xattr support (#3650)
Browse files Browse the repository at this point in the history
* Support FreeBSD xattr naming

There is a slight compatibilty issue due to FreeBSD disallowing
usage of the `user.` prefix when it comes to xattr names.
Just for FreeBSD this patch removes that `user.` prefix (leaving
`ocis.`) which allows it to run on FreeBSD.

* Cleanup the FreeBSD xattr naming

* Comment for default xattr namespace as per Codacy static analysis

* chore: changelog update for freebsd-xattr-support

---------

Co-authored-by: Jur van den Berg <[email protected]>
  • Loading branch information
joramkruijer and BlackNovaTech authored Feb 14, 2023
1 parent 4a49209 commit ec27f5f
Show file tree
Hide file tree
Showing 4 changed files with 27 additions and 2 deletions.
5 changes: 5 additions & 0 deletions changelog/unreleased/freebsd-xattr-support.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
Bugfix: FreeBSD xattr support

We now properly handle FreeBSD xattr namespaces by leaving out the `user.` prefix. FreeBSD adds that automatically.

https://github.com/cs3org/reva/pull/3650
3 changes: 1 addition & 2 deletions pkg/storage/utils/decomposedfs/xattrs/xattrs.go
Original file line number Diff line number Diff line change
Expand Up @@ -36,9 +36,8 @@ import (
// A non root user can only manipulate the user. namespace, which is what
// we will use to store ownCloud specific metadata. To prevent name
// collisions with other apps We are going to introduce a sub namespace
// "user.ocis."
// "user.ocis." in the xattrs_prefix*.go files.
const (
OcisPrefix string = "user.ocis."
ParentidAttr string = OcisPrefix + "parentid"
OwnerIDAttr string = OcisPrefix + "owner.id"
OwnerIDPAttr string = OcisPrefix + "owner.idp"
Expand Down
11 changes: 11 additions & 0 deletions pkg/storage/utils/decomposedfs/xattrs/xattrs_prefix.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
//go:build !freebsd

package xattrs

// The default namespace for ocis. As non root users can only manipulate
// the user. namespace, which is what is used to store ownCloud specific
// metadata. To prevent name collisions with other apps, we are going to
// introduce a sub namespace "user.ocis."
const (
OcisPrefix string = "user.ocis."
)
10 changes: 10 additions & 0 deletions pkg/storage/utils/decomposedfs/xattrs/xattrs_prefix_freebsd.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
//go:build freebsd

package xattrs

// On FreeBSD the `user` namespace is implied through a separate syscall argument
// and will fail with invalid argument when you try to start an xattr name with user. or system.
// For that reason we drop the superfluous user. prefix for FreeBSD specifically.
const (
OcisPrefix string = "ocis."
)

0 comments on commit ec27f5f

Please sign in to comment.