aboutsummaryrefslogtreecommitdiff
path: root/internal/inomap/inomap.go
diff options
context:
space:
mode:
authorJakob Unterwurzacher2021-09-10 17:17:16 +0200
committerJakob Unterwurzacher2021-09-10 17:17:16 +0200
commitc9b825c58a9f996379108926754513bca03bb306 (patch)
tree51e2831bae6904945babd682fab16382c14b989d /internal/inomap/inomap.go
parentee561035707527dee48cecfc9466ab4921666b43 (diff)
inomap: deterministically set root device
We used to have "first Translate() wins". This is not deterministic, as the LOOKUP for the root directory does not seem to reach us, so the first user LOOKUP would win, which may be on a mountpoint.
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