From 4d99b02279dce3ef7d37ca219d1305b81f716741 Mon Sep 17 00:00:00 2001 From: Jakob Unterwurzacher Date: Sun, 12 Jul 2020 15:03:42 +0200 Subject: v2api: Getattr: fix file size --- internal/fusefrontend/node.go | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) (limited to 'internal') diff --git a/internal/fusefrontend/node.go b/internal/fusefrontend/node.go index 2c9a4f7..69d9b22 100644 --- a/internal/fusefrontend/node.go +++ b/internal/fusefrontend/node.go @@ -97,8 +97,22 @@ func (n *Node) Getattr(ctx context.Context, f fs.FileHandle, out *fuse.AttrOut) if err != nil { return fs.ToErrno(err) } - n.rootNode().inoMap.TranslateStat(st) + + // Fix inode number + rn := n.rootNode() + rn.inoMap.TranslateStat(st) out.Attr.FromStat(st) + + // Fix size + if out.IsRegular() { + out.Size = rn.contentEnc.CipherSizeToPlainSize(out.Size) + } else if out.IsSymlink() { + target, _ := n.Readlink(ctx) + out.Size = uint64(len(target)) + } + if rn.args.ForceOwner != nil { + out.Owner = *rn.args.ForceOwner + } return 0 } -- cgit v1.2.3