From c9b825c58a9f996379108926754513bca03bb306 Mon Sep 17 00:00:00 2001 From: Jakob Unterwurzacher Date: Fri, 10 Sep 2021 17:17:16 +0200 Subject: 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. --- internal/fusefrontend_reverse/root_node.go | 17 +++++++++++------ 1 file changed, 11 insertions(+), 6 deletions(-) (limited to 'internal/fusefrontend_reverse/root_node.go') diff --git a/internal/fusefrontend_reverse/root_node.go b/internal/fusefrontend_reverse/root_node.go index d4c1e37..e15ddb0 100644 --- a/internal/fusefrontend_reverse/root_node.go +++ b/internal/fusefrontend_reverse/root_node.go @@ -2,10 +2,13 @@ package fusefrontend_reverse import ( "log" + "os" "path/filepath" "strings" "syscall" + "github.com/rfjakob/gocryptfs/v2/internal/exitcodes" + "github.com/rfjakob/gocryptfs/v2/internal/tlog" "golang.org/x/sys/unix" @@ -46,12 +49,14 @@ type RootNode struct { // ReverseFS provides an encrypted view. func NewRootNode(args fusefrontend.Args, c *contentenc.ContentEnc, n *nametransform.NameTransform) *RootNode { var rootDev uint64 - if args.OneFileSystem { - var st syscall.Stat_t - err := syscall.Stat(args.Cipherdir, &st) - if err != nil { - log.Panicf("Could not stat backing directory %q: %v", args.Cipherdir, err) + var st syscall.Stat_t + if err := syscall.Stat(args.Cipherdir, &st); err != nil { + tlog.Warn.Printf("Could not stat backing directory %q: %v", args.Cipherdir, err) + if args.OneFileSystem { + tlog.Fatal.Printf("This is a fatal error in combination with -one-file-system") + os.Exit(exitcodes.CipherDir) } + } else { rootDev = uint64(st.Dev) } @@ -59,7 +64,7 @@ func NewRootNode(args fusefrontend.Args, c *contentenc.ContentEnc, n *nametransf args: args, nameTransform: n, contentEnc: c, - inoMap: inomap.New(), + inoMap: inomap.New(rootDev), rootDev: rootDev, } if len(args.Exclude) > 0 || len(args.ExcludeWildcard) > 0 || len(args.ExcludeFrom) > 0 { -- cgit v1.2.3