From d48ccb3ddab71773a991b8f1b062901ff5b435b0 Mon Sep 17 00:00:00 2001 From: M. Vefa Bicakci Date: Tue, 7 Mar 2017 12:09:09 +0300 Subject: Report correct symbolic link dentry sizes Prior to this commit, gocryptfs's reverse mode did not report correct directory entry sizes for symbolic links, where the dentry size needs to be the same as the length of a string containing the target path. This commit corrects this issue and adds a test case to verify the correctness of the implementation. This issue was discovered during the use of a strict file copying program on a reverse-mounted gocryptfs file system. --- internal/fusefrontend_reverse/rfs.go | 10 ++++++++++ 1 file changed, 10 insertions(+) (limited to 'internal') diff --git a/internal/fusefrontend_reverse/rfs.go b/internal/fusefrontend_reverse/rfs.go index f9a2979..a3a3d3b 100644 --- a/internal/fusefrontend_reverse/rfs.go +++ b/internal/fusefrontend_reverse/rfs.go @@ -221,6 +221,16 @@ func (rfs *ReverseFS) GetAttr(relPath string, context *fuse.Context) (*fuse.Attr // Calculate encrypted file size if a.IsRegular() { a.Size = rfs.contentEnc.PlainSizeToCipherSize(a.Size) + } else if a.IsSymlink() { + var linkTarget string + var readlinkStatus fuse.Status + + linkTarget, readlinkStatus = rfs.Readlink(relPath, context) + if !readlinkStatus.Ok() { + return nil, readlinkStatus + } + + a.Size = uint64(len(linkTarget)) } return a, fuse.OK } -- cgit v1.2.3