summaryrefslogtreecommitdiff
path: root/internal/fusefrontend/node_helpers.go
diff options
context:
space:
mode:
authorJakob Unterwurzacher2021-07-31 13:24:25 +0200
committerJakob Unterwurzacher2021-07-31 13:24:25 +0200
commit1bc1db620b061aabf59469a5eb4fb60e3e1701a3 (patch)
treed569e213c3a046cdb1fa01fe089fbab048a6fdfe /internal/fusefrontend/node_helpers.go
parenteecbcbb0905320fc8a030fb716bee259bf6dd00f (diff)
fusefrontend: -sharedstorage: present stable inode numbers
Use the Gen field (inode generation) to distinguish hard links while passing the real inode numbers to userspace. Fixes https://github.com/rfjakob/gocryptfs/issues/584
Diffstat (limited to 'internal/fusefrontend/node_helpers.go')
-rw-r--r--internal/fusefrontend/node_helpers.go12
1 files changed, 10 insertions, 2 deletions
diff --git a/internal/fusefrontend/node_helpers.go b/internal/fusefrontend/node_helpers.go
index ce2e8a9..31954f3 100644
--- a/internal/fusefrontend/node_helpers.go
+++ b/internal/fusefrontend/node_helpers.go
@@ -2,6 +2,7 @@ package fusefrontend
import (
"context"
+ "sync/atomic"
"syscall"
"github.com/hanwen/go-fuse/v2/fs"
@@ -82,13 +83,20 @@ func (n *Node) rootNode() *RootNode {
func (n *Node) newChild(ctx context.Context, st *syscall.Stat_t, out *fuse.EntryOut) *fs.Inode {
rn := n.rootNode()
// Get stable inode number based on underlying (device,ino) pair
- // (or set to zero in case of `-sharestorage`)
rn.inoMap.TranslateStat(st)
out.Attr.FromStat(st)
+
+ var gen uint64 = 1
+ if rn.args.SharedStorage {
+ // Make each directory entry a unique node by using a unique generation
+ // value - see the comment at RootNode.gen for details.
+ gen = atomic.AddUint64(&rn.gen, 1)
+ }
+
// Create child node
id := fs.StableAttr{
Mode: uint32(st.Mode),
- Gen: 1,
+ Gen: gen,
Ino: st.Ino,
}
node := &Node{}