aboutsummaryrefslogtreecommitdiff
path: root/internal/inomap/inomap.go
diff options
context:
space:
mode:
Diffstat (limited to 'internal/inomap/inomap.go')
-rw-r--r--internal/inomap/inomap.go13
1 files changed, 11 insertions, 2 deletions
diff --git a/internal/inomap/inomap.go b/internal/inomap/inomap.go
index 97f9b61..997ea9b 100644
--- a/internal/inomap/inomap.go
+++ b/internal/inomap/inomap.go
@@ -49,13 +49,22 @@ type InoMap struct {
}
// New returns a new InoMap.
-func New() *InoMap {
- return &InoMap{
+// Inode numbers on device `rootDev` will be passed through as-is.
+// If `rootDev` is zero, the first Translate() call decides the effective
+// rootDev.
+func New(rootDev uint64) *InoMap {
+ m := &InoMap{
namespaceMap: make(map[namespaceData]uint16),
namespaceNext: 0,
spillMap: make(map[QIno]uint64),
spillNext: 0,
}
+ if rootDev > 0 {
+ // Reserve namespace 0 for rootDev
+ m.namespaceMap[namespaceData{rootDev, 0}] = 0
+ m.namespaceNext = 1
+ }
+ return m
}
var spillWarn sync.Once