From e04dc050126edcf7440ea5412bc74c6ad8b42e95 Mon Sep 17 00:00:00 2001 From: Jakob Unterwurzacher Date: Thu, 17 Nov 2016 20:32:19 +0100 Subject: fusefrontend: upgrade wlockMap to use device AND inode number If there are multiple filesystems backing the gocryptfs filesystems inode numbers are not guaranteed to be unique. --- internal/fusefrontend_reverse/ino_map.go | 5 ----- internal/fusefrontend_reverse/rfs.go | 6 +++--- 2 files changed, 3 insertions(+), 8 deletions(-) (limited to 'internal/fusefrontend_reverse') diff --git a/internal/fusefrontend_reverse/ino_map.go b/internal/fusefrontend_reverse/ino_map.go index 9412343..dae8222 100644 --- a/internal/fusefrontend_reverse/ino_map.go +++ b/internal/fusefrontend_reverse/ino_map.go @@ -17,8 +17,3 @@ type inoGenT struct { func (i *inoGenT) next() uint64 { return atomic.AddUint64(i.ino, 1) } - -type devIno struct { - dev uint64 - ino uint64 -} diff --git a/internal/fusefrontend_reverse/rfs.go b/internal/fusefrontend_reverse/rfs.go index 7f102cf..aca4b90 100644 --- a/internal/fusefrontend_reverse/rfs.go +++ b/internal/fusefrontend_reverse/rfs.go @@ -41,7 +41,7 @@ type ReverseFS struct { // Inode number generator inoGen *inoGenT // Maps backing files device+inode pairs to user-facing unique inode numbers - inoMap map[devIno]uint64 + inoMap map[fusefrontend.DevInoStruct]uint64 // Protects map access inoMapLock sync.Mutex } @@ -68,7 +68,7 @@ func NewFS(args fusefrontend.Args) *ReverseFS { nameTransform: nameTransform, contentEnc: contentEnc, inoGen: newInoGen(), - inoMap: map[devIno]uint64{}, + inoMap: map[fusefrontend.DevInoStruct]uint64{}, } } @@ -167,7 +167,7 @@ func (rfs *ReverseFS) inoAwareStat(relPlainPath string) (*fuse.Attr, fuse.Status // The file has hard links. We have to give it a stable inode number so // tar or rsync can find them. if fi.Mode().IsRegular() && st.Nlink > 1 { - di := devIno{uint64(st.Dev), st.Ino} + di := fusefrontend.DevInoFromStat(st) rfs.inoMapLock.Lock() stableIno := rfs.inoMap[di] if stableIno == 0 { -- cgit v1.2.3