aboutsummaryrefslogtreecommitdiff
path: root/internal/fusefrontend_reverse/node_xattr_linux.go
diff options
context:
space:
mode:
authorAleksey Vasenev2024-11-17 23:14:36 +0300
committerJakob Unterwurzacher2025-11-22 21:24:20 +0100
commited1c5e4a9f5ce1921f3ec03b32e591ce828ec5b9 (patch)
treea2e1f64e772e2af169df3ce4ac955fbf3ec8c83b /internal/fusefrontend_reverse/node_xattr_linux.go
parentbe34b9822bea4ce3b717c1b9bf5076f1118427ec (diff)
Xattrs support in reverse mode
Fixes https://github.com/rfjakob/gocryptfs/issues/827
Diffstat (limited to 'internal/fusefrontend_reverse/node_xattr_linux.go')
-rw-r--r--internal/fusefrontend_reverse/node_xattr_linux.go40
1 files changed, 40 insertions, 0 deletions
diff --git a/internal/fusefrontend_reverse/node_xattr_linux.go b/internal/fusefrontend_reverse/node_xattr_linux.go
new file mode 100644
index 0000000..f6d04a5
--- /dev/null
+++ b/internal/fusefrontend_reverse/node_xattr_linux.go
@@ -0,0 +1,40 @@
+package fusefrontend_reverse
+
+import (
+ "fmt"
+ "syscall"
+
+ "github.com/hanwen/go-fuse/v2/fs"
+
+ "github.com/rfjakob/gocryptfs/v2/internal/syscallcompat"
+)
+
+func (n *Node) getXAttr(cAttr string) (out []byte, errno syscall.Errno) {
+ d, errno := n.prepareAtSyscall("")
+ if errno != 0 {
+ return
+ }
+ defer syscall.Close(d.dirfd)
+
+ procPath := fmt.Sprintf("/proc/self/fd/%d/%s", d.dirfd, d.pName)
+ pData, err := syscallcompat.Lgetxattr(procPath, cAttr)
+ if err != nil {
+ return nil, fs.ToErrno(err)
+ }
+ return pData, 0
+}
+
+func (n *Node) listXAttr() (out []string, errno syscall.Errno) {
+ d, errno := n.prepareAtSyscall("")
+ if errno != 0 {
+ return
+ }
+ defer syscall.Close(d.dirfd)
+
+ procPath := fmt.Sprintf("/proc/self/fd/%d/%s", d.dirfd, d.pName)
+ pNames, err := syscallcompat.Llistxattr(procPath)
+ if err != nil {
+ return nil, fs.ToErrno(err)
+ }
+ return pNames, 0
+}