aboutsummaryrefslogtreecommitdiff
path: root/internal/fusefrontend_reverse
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/fusefrontend_reverse
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/fusefrontend_reverse')
-rw-r--r--internal/fusefrontend_reverse/root_node.go17
1 files changed, 11 insertions, 6 deletions
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 {