summaryrefslogtreecommitdiff
path: root/internal/fusefrontend/xattr_darwin.go
diff options
context:
space:
mode:
authorJakob Unterwurzacher2018-11-11 17:43:48 +0100
committerJakob Unterwurzacher2019-01-01 16:24:25 +0100
commit2286372603f506cf719654a9901de0749c544b12 (patch)
tree3281d54570b9a06e5be756a57d049900848db182 /internal/fusefrontend/xattr_darwin.go
parentb97d7d1d33d1274c6872d899692a56bd4070a6d9 (diff)
fusefrontend: make GetXAttr() symlink-safe on Linux
Uses the /proc/self/fd trick, which does not work on Darwin.
Diffstat (limited to 'internal/fusefrontend/xattr_darwin.go')
-rw-r--r--internal/fusefrontend/xattr_darwin.go19
1 files changed, 18 insertions, 1 deletions
diff --git a/internal/fusefrontend/xattr_darwin.go b/internal/fusefrontend/xattr_darwin.go
index b626006..cf48d13 100644
--- a/internal/fusefrontend/xattr_darwin.go
+++ b/internal/fusefrontend/xattr_darwin.go
@@ -3,7 +3,11 @@
// Package fusefrontend interfaces directly with the go-fuse library.
package fusefrontend
-import "github.com/pkg/xattr"
+import (
+ "github.com/pkg/xattr"
+
+ "github.com/hanwen/go-fuse/fuse"
+)
func disallowedXAttrName(attr string) bool {
return false
@@ -13,3 +17,16 @@ func disallowedXAttrName(attr string) bool {
func filterXattrSetFlags(flags int) int {
return flags &^ xattr.XATTR_NOSECURITY
}
+
+// This function is NOT symlink-safe because Darwin lacks fgetxattr().
+func (fs *FS) getXattr(relPath string, cAttr string, context *fuse.Context) ([]byte, fuse.Status) {
+ cPath, err := fs.getBackingPath(relPath)
+ if err != nil {
+ return nil, fuse.ToStatus(err)
+ }
+ cData, err := xattr.LGet(cPath, cAttr)
+ if err != nil {
+ return nil, unpackXattrErr(err)
+ }
+ return cData, fuse.OK
+}