aboutsummaryrefslogtreecommitdiff
path: root/internal/inomap/qino.go
diff options
context:
space:
mode:
authorJakob Unterwurzacher2020-04-19 21:57:53 +0200
committerJakob Unterwurzacher2020-04-19 22:00:56 +0200
commit9f9d59ded94f648202505e278f67667879e60be8 (patch)
tree17e9190c4aa752feab71545a56f0686b2ea64237 /internal/inomap/qino.go
parentfcdeb52390b15b0d59015dbd238835b9a6f6b3ff (diff)
inomap: rework logic to efficiently support flags
Adding flags allows to use inomap in reverse mode, replacing the clunky inoBaseDirIV/inoBaseNameFile logic that causes problems with high underlying inode numbers ( https://github.com/rfjakob/gocryptfs/issues/457 ) Microbenchmarks (values below) show that the "SingleDev" case is now much slower due to an extra map lookup, but this has no visible effects in ./test.bash results, so there was no time spent optimizing the case further. $ go test -bench=. goos: linux goarch: amd64 pkg: github.com/rfjakob/gocryptfs/internal/inomap BenchmarkTranslateSingleDev-4 18757510 61.5 ns/op BenchmarkTranslateManyDevs-4 18061515 64.5 ns/op PASS ok github.com/rfjakob/gocryptfs/internal/inomap 2.467s
Diffstat (limited to 'internal/inomap/qino.go')
-rw-r--r--internal/inomap/qino.go22
1 files changed, 16 insertions, 6 deletions
diff --git a/internal/inomap/qino.go b/internal/inomap/qino.go
index 8f99004..a74a96d 100644
--- a/internal/inomap/qino.go
+++ b/internal/inomap/qino.go
@@ -4,22 +4,32 @@ import (
"syscall"
)
+type namespaceData struct {
+ // Stat_t.Dev is uint64 on 32- and 64-bit Linux
+ Dev uint64
+ // Flags acts like an extension of the Dev field.
+ // It is used by reverse mode for virtual files.
+ Flags uint8
+}
+
// QIno = Qualified Inode number.
// Uniquely identifies a backing file through the device number,
// inode number pair.
type QIno struct {
- // Stat_t.{Dev,Ino} is uint64 on 32- and 64-bit Linux
- Dev uint64
+ namespaceData
+ // Stat_t.Ino is uint64 on 32- and 64-bit Linu
Ino uint64
}
// QInoFromStat fills a new QIno struct with the passed Stat_t info.
func QInoFromStat(st *syscall.Stat_t) QIno {
return QIno{
- // There are some architectures that use 32-bit values here
- // (darwin, freebsd-32, maybe others). Add and explicit cast to make
- // this function work everywhere.
- Dev: uint64(st.Dev),
+ namespaceData: namespaceData{
+ // There are some architectures that use 32-bit values here
+ // (darwin, freebsd-32, maybe others). Add an explicit cast to make
+ // this function work everywhere.
+ Dev: uint64(st.Dev),
+ },
Ino: uint64(st.Ino),
}
}