From 461bddb0e8f467cd2d59e4b108947cdfc1ac12db Mon Sep 17 00:00:00 2001 From: Johannes Truschnigg Date: Sun, 19 Apr 2026 13:44:18 +0200 Subject: [PATCH] mount: Ensure a hard link count > 0 for all files When using `restic mount` to serve a repository via a POSIX host's file system, all files backed up from Windows systems will show up on the mounting host with a (hard)link count of 0. While this is not a problem in general and most programs do not even register this strange value, some others (such as Samba's smbd(8)) will go the extra mile and check a file's stat() results for various properties (such as a positive non-zero link count), and refuse to operate if any of the reported values appear off. Since other inode properties absent from non-POSIX backup sources are also "faked up" (e.g., the inode number) during mount and work fine in general, the chances of this change to be in any way harmful are probably rather slim. --- internal/fuse/file.go | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/internal/fuse/file.go b/internal/fuse/file.go index 42a83d652..986d8428f 100644 --- a/internal/fuse/file.go +++ b/internal/fuse/file.go @@ -55,7 +55,8 @@ func (f *file) Attr(_ context.Context, a *fuse.Attr) error { a.Size = f.node.Size a.Blocks = (f.node.Size + blockSize - 1) / blockSize a.BlockSize = blockSize - a.Nlink = uint32(f.node.Links) + // present a link count > 0 to keep over-eager stat() .st_nlink checks (e.g., from Samba's smbd) happy + a.Nlink = max(uint32(1), uint32(f.node.Links)) if !f.root.cfg.OwnerIsRoot { a.Uid = f.node.UID