summaryrefslogtreecommitdiff
path: root/internal/inomap/inomap.go
diff options
context:
space:
mode:
authorJakob Unterwurzacher2020-05-03 15:22:10 +0200
committerJakob Unterwurzacher2020-05-03 15:22:10 +0200
commit518771e4e247762f60c5594de427a8c86f19bd57 (patch)
tree625aed59393508f8f3b61787963012a684b37d8e /internal/inomap/inomap.go
parentdb93a6c54cfd615561207f1bbcf7e665ebc296b6 (diff)
fusefrontend_reverse: use inomap for inode number translation
Gets rid of static inode number value limitations. Fixes https://github.com/rfjakob/gocryptfs/issues/457
Diffstat (limited to 'internal/inomap/inomap.go')
-rw-r--r--internal/inomap/inomap.go16
1 files changed, 12 insertions, 4 deletions
diff --git a/internal/inomap/inomap.go b/internal/inomap/inomap.go
index c277849..0ca43e4 100644
--- a/internal/inomap/inomap.go
+++ b/internal/inomap/inomap.go
@@ -15,6 +15,7 @@
package inomap
import (
+ "fmt"
"log"
"sync"
"syscall"
@@ -72,23 +73,30 @@ func (m *InoMap) spill(in QIno) (out uint64) {
func (m *InoMap) Translate(in QIno) (out uint64) {
m.Lock()
defer m.Unlock()
+ defer func() {
+ fmt.Printf("Translate: %v -> %d\n", in, out)
+ }()
if in.Ino > maxPassthruIno {
- return m.spill(in)
+ out = m.spill(in)
+ return out
}
ns, found := m.namespaceMap[in.namespaceData]
// Use existing namespace
if found {
- return uint64(ns)<<48 | in.Ino
+ out = uint64(ns)<<48 | in.Ino
+ return out
}
// No free namespace slots?
if m.namespaceNext >= maxNamespaceId {
- return m.spill(in)
+ out = m.spill(in)
+ return out
}
ns = m.namespaceNext
m.namespaceNext++
m.namespaceMap[in.namespaceData] = ns
- return uint64(ns)<<48 | in.Ino
+ out = uint64(ns)<<48 | in.Ino
+ return out
}
// TranslateStat translates the inode number contained in "st" if neccessary.