diff options
| author | Jakob Unterwurzacher | 2026-02-02 22:18:25 +0100 |
|---|---|---|
| committer | Jakob Unterwurzacher | 2026-02-03 20:28:10 +0100 |
| commit | 14045511d3d91f36845a138359718c0fe7dff21c (patch) | |
| tree | 66bcc155f68e7c284a2179a0ff582e06e001209c /internal/fusefrontend_reverse/node_xattr_darwin.go | |
| parent | 6ac778beb0c962e0c2413c1bd91595a9bbccd25b (diff) | |
Use user-provided Listxattr buffer sizexattr_user_buffer
This huge buffer showed up big time in ./profiling/ls.bash
and caused a 2x LS benchmark slowdown.
Instead of the fixed-size buffer, use the buffer size
hint the user has provided us.
We return inaccurate (larger than actual, which should be safe)
numbers when the user has provided no buffer (size probe).
Diffstat (limited to 'internal/fusefrontend_reverse/node_xattr_darwin.go')
| -rw-r--r-- | internal/fusefrontend_reverse/node_xattr_darwin.go | 12 |
1 files changed, 5 insertions, 7 deletions
diff --git a/internal/fusefrontend_reverse/node_xattr_darwin.go b/internal/fusefrontend_reverse/node_xattr_darwin.go index 6816a18..1832f7f 100644 --- a/internal/fusefrontend_reverse/node_xattr_darwin.go +++ b/internal/fusefrontend_reverse/node_xattr_darwin.go @@ -4,6 +4,7 @@ import ( "syscall" "github.com/hanwen/go-fuse/v2/fs" + "golang.org/x/sys/unix" "github.com/rfjakob/gocryptfs/v2/internal/syscallcompat" ) @@ -33,7 +34,7 @@ func (n *Node) getXAttr(cAttr string) (out []byte, errno syscall.Errno) { return cData, 0 } -func (n *Node) listXAttr() (out []string, errno syscall.Errno) { +func (n *Node) listXAttr(buf []byte) (sz int, errno syscall.Errno) { d, errno := n.prepareAtSyscall("") if errno != 0 { return @@ -43,13 +44,10 @@ func (n *Node) listXAttr() (out []string, errno syscall.Errno) { // O_NONBLOCK to not block on FIFOs. fd, err := syscallcompat.Openat(d.dirfd, d.pName, syscall.O_RDONLY|syscall.O_NONBLOCK|syscall.O_NOFOLLOW, 0) if err != nil { - return nil, fs.ToErrno(err) + return 0, fs.ToErrno(err) } defer syscall.Close(fd) - pNames, err := syscallcompat.Flistxattr(fd) - if err != nil { - return nil, fs.ToErrno(err) - } - return pNames, 0 + sz, err = unix.Flistxattr(fd, buf) + return sz, fs.ToErrno(err) } |
