From 518771e4e247762f60c5594de427a8c86f19bd57 Mon Sep 17 00:00:00 2001 From: Jakob Unterwurzacher Date: Sun, 3 May 2020 15:22:10 +0200 Subject: fusefrontend_reverse: use inomap for inode number translation Gets rid of static inode number value limitations. Fixes https://github.com/rfjakob/gocryptfs/issues/457 --- internal/inomap/qino.go | 26 +++++++++++++++++--------- 1 file changed, 17 insertions(+), 9 deletions(-) (limited to 'internal/inomap/qino.go') diff --git a/internal/inomap/qino.go b/internal/inomap/qino.go index a74a96d..ed514e8 100644 --- a/internal/inomap/qino.go +++ b/internal/inomap/qino.go @@ -7,9 +7,11 @@ import ( 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. + // Tag acts like an extension of the Dev field. // It is used by reverse mode for virtual files. - Flags uint8 + // Normal (forward) mode does not use it and it + // stays always zero there. + Tag uint8 } // QIno = Qualified Inode number. @@ -21,15 +23,21 @@ type QIno struct { Ino uint64 } -// QInoFromStat fills a new QIno struct with the passed Stat_t info. -func QInoFromStat(st *syscall.Stat_t) QIno { +// NewQIno returns a filled QIno struct +func NewQIno(dev uint64, tag uint8, ino uint64) QIno { return QIno{ 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), + Dev: dev, + Tag: tag, }, - Ino: uint64(st.Ino), + Ino: ino, } } + +// QInoFromStat fills a new QIno struct with the passed Stat_t info. +func QInoFromStat(st *syscall.Stat_t) QIno { + // 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. + return NewQIno(uint64(st.Dev), 0, uint64(st.Ino)) +} -- cgit v1.2.3