From b3b292a8a3c1478b769e213e0e590f38cb1b923c Mon Sep 17 00:00:00 2001 From: Jakob Unterwurzacher Date: Wed, 22 Jul 2026 21:49:43 +0200 Subject: fusefrontend: make translateSize Stat_t/Statx_t agnostic --- internal/fusefrontend/node_helpers.go | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) (limited to 'internal/fusefrontend/node_helpers.go') diff --git a/internal/fusefrontend/node_helpers.go b/internal/fusefrontend/node_helpers.go index e8fca80..96c0961 100644 --- a/internal/fusefrontend/node_helpers.go +++ b/internal/fusefrontend/node_helpers.go @@ -56,15 +56,15 @@ func (n *Node) readlink(dirfd int, cName string) (out []byte, errno syscall.Errn // translateSize translates the ciphertext size in `out` into plaintext size. // Handles regular files & symlinks (and finds out what is what by looking at // `out.Mode`). -func (n *Node) translateSize(dirfd int, cName string, out *fuse.Attr) { - if out.IsRegular() { - rn := n.rootNode() - out.Size = rn.contentEnc.CipherSizeToPlainSize(out.Size) - } else if out.IsSymlink() { - // read and decrypt target +func (n *Node) translateSize(dirfd int, cName string, mode uint32, cSize uint64) (pSize uint64) { + switch mode & syscall.S_IFMT { + case syscall.S_IFREG: + return n.rootNode().contentEnc.CipherSizeToPlainSize(cSize) + case syscall.S_IFLNK: target, _ := n.readlink(dirfd, cName) - out.Size = uint64(len(target)) + return uint64(len(target)) } + return cSize } // Path returns the relative plaintext path of this node -- cgit v1.2.3