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/root_node.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/root_node.go')
-rw-r--r-- | internal/fusefrontend/root_node.go | 13 |
1 files changed, 7 insertions, 6 deletions
diff --git a/internal/fusefrontend/root_node.go b/internal/fusefrontend/root_node.go index c82078d..46bee4a 100644 --- a/internal/fusefrontend/root_node.go +++ b/internal/fusefrontend/root_node.go @@ -50,7 +50,13 @@ type RootNode struct { dirCache dirCache // inoMap translates inode numbers from different devices to unique inode // numbers. - inoMap inomap.TranslateStater + inoMap *inomap.InoMap + // gen is the node generation numbers. Normally, it is always set to 1, + // but -sharestorage uses an incrementing counter for new nodes. + // This makes each directory entry unique (even hard links), + // makes go-fuse hand out separate FUSE Node IDs for each, and prevents + // bizarre problems when inode numbers are reused behind our back. + gen uint64 } func NewRootNode(args Args, c *contentenc.ContentEnc, n *nametransform.NameTransform) *RootNode { @@ -71,11 +77,6 @@ func NewRootNode(args Args, c *contentenc.ContentEnc, n *nametransform.NameTrans inoMap: inomap.New(), dirCache: dirCache{ivLen: ivLen}, } - // In `-sharedstorage` mode we always set the inode number to zero. - // This makes go-fuse generate a new inode number for each lookup. - if args.SharedStorage { - rn.inoMap = &inomap.TranslateStatZero{} - } return rn } |