Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Report symlink sizes from FUSE mount #3668

Merged
merged 2 commits into from
Mar 21, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 8 additions & 0 deletions changelog/unreleased/issue-3667
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
Bugfix: restic mount now reports symlinks sizes

Symlinks used to have size zero in restic mountpoints, confusing some
third-party tools. They now have a size equal to the byte length of their
target path, as required by POSIX.

https://github.com/restic/restic/issues/3667
https://github.com/restic/restic/pull/3668
3 changes: 3 additions & 0 deletions internal/fuse/link.go
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
//go:build darwin || freebsd || linux
// +build darwin freebsd linux

package fuse
Expand Down Expand Up @@ -40,6 +41,8 @@ func (l *link) Attr(ctx context.Context, a *fuse.Attr) error {
a.Mtime = l.node.ModTime

a.Nlink = uint32(l.node.Links)
a.Size = uint64(len(l.node.LinkTarget))
a.Blocks = 1 + a.Size/blockSize

return nil
}
2 changes: 2 additions & 0 deletions internal/fuse/snapshots_dir.go
Original file line number Diff line number Diff line change
Expand Up @@ -440,6 +440,8 @@ func (l *snapshotLink) Readlink(ctx context.Context, req *fuse.ReadlinkRequest)
func (l *snapshotLink) Attr(ctx context.Context, a *fuse.Attr) error {
a.Inode = l.inode
a.Mode = os.ModeSymlink | 0777
a.Size = uint64(len(l.target))
a.Blocks = 1 + a.Size/blockSize
a.Uid = l.root.uid
a.Gid = l.root.gid
a.Atime = l.snapshot.Time
Expand Down