summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--internal/fusefrontend/xattr.go6
-rw-r--r--tests/defaults/main_test.go39
2 files changed, 43 insertions, 2 deletions
diff --git a/internal/fusefrontend/xattr.go b/internal/fusefrontend/xattr.go
index ac4b15f..813f286 100644
--- a/internal/fusefrontend/xattr.go
+++ b/internal/fusefrontend/xattr.go
@@ -48,13 +48,15 @@ func (fs *FS) GetXAttr(path string, attr string, context *fuse.Context) ([]byte,
return data, fuse.OK
}
+const _EOPNOTSUPP = fuse.Status(syscall.EOPNOTSUPP)
+
// SetXAttr implements pathfs.Filesystem.
func (fs *FS) SetXAttr(path string, attr string, data []byte, flags int, context *fuse.Context) fuse.Status {
if fs.isFiltered(path) {
return fuse.EPERM
}
if disallowedXAttrName(attr) {
- return fuse.EPERM
+ return _EOPNOTSUPP
}
flags = filterXattrSetFlags(flags)
@@ -74,7 +76,7 @@ func (fs *FS) RemoveXAttr(path string, attr string, context *fuse.Context) fuse.
return fuse.EPERM
}
if disallowedXAttrName(attr) {
- return fuse.EPERM
+ return _EOPNOTSUPP
}
cPath, err := fs.getBackingPath(path)
if err != nil {
diff --git a/tests/defaults/main_test.go b/tests/defaults/main_test.go
index 49c6dcf..89d3bfc 100644
--- a/tests/defaults/main_test.go
+++ b/tests/defaults/main_test.go
@@ -193,3 +193,42 @@ func TestWrite0200File(t *testing.T) {
t.Fatal("wrong restored permissions")
}
}
+
+// When xattr support was introduced, mv threw warnings like these:
+// mv: preserving permissions for ‘b/x’: Operation not permitted
+// because we returned EPERM when it tried to set system.posix_acl_access.
+// Now we return EOPNOTSUPP and mv is happy.
+func TestMvWarnings(t *testing.T) {
+ fn := test_helpers.TmpDir + "/TestMvWarnings"
+ err := ioutil.WriteFile(fn, nil, 0600)
+ if err != nil {
+ t.Fatalf("creating file failed: %v", err)
+ }
+ cmd := exec.Command("mv", fn, test_helpers.DefaultPlainDir)
+ out, err := cmd.CombinedOutput()
+ if err != nil {
+ t.Log(string(out))
+ t.Fatal(err)
+ }
+ if len(out) != 0 {
+ t.Fatalf("Got warnings from mv:\n%s", string(out))
+ }
+}
+
+// See TestCpWarnings.
+func TestCpWarnings(t *testing.T) {
+ fn := test_helpers.TmpDir + "/TestCpWarnings"
+ err := ioutil.WriteFile(fn, []byte("foo"), 0600)
+ if err != nil {
+ t.Fatalf("creating file failed: %v", err)
+ }
+ cmd := exec.Command("cp", "-a", fn, test_helpers.DefaultPlainDir)
+ out, err := cmd.CombinedOutput()
+ if err != nil {
+ t.Log(string(out))
+ t.Fatal(err)
+ }
+ if len(out) != 0 {
+ t.Fatalf("Got warnings from cp -a:\n%s", string(out))
+ }
+}