diff options
author | Jakob Unterwurzacher | 2021-07-31 13:24:25 +0200 |
---|---|---|
committer | Jakob Unterwurzacher | 2021-07-31 13:24:25 +0200 |
commit | 1bc1db620b061aabf59469a5eb4fb60e3e1701a3 (patch) | |
tree | d569e213c3a046cdb1fa01fe089fbab048a6fdfe /internal/fusefrontend/node_helpers.go | |
parent | eecbcbb0905320fc8a030fb716bee259bf6dd00f (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.go | 12 |
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{} |