aboutsummaryrefslogtreecommitdiff
path: root/internal
diff options
context:
space:
mode:
authorJakob Unterwurzacher2024-11-11 22:27:42 +0100
committerJakob Unterwurzacher2024-11-11 22:33:07 +0100
commit86891054ef2a5d1b0b59c7c140aae284e7c5bd87 (patch)
tree7e863db4486656fd18ed5a1144e0669fb085bf58 /internal
parent12c0f3a0bdd11444b8bf880af7c63ea7850391f2 (diff)
Report inode number for the root node
Now that https://github.com/hanwen/go-fuse/issues/399 has landed we can report an inode number for the root node. Fixes https://github.com/rfjakob/gocryptfs/issues/580
Diffstat (limited to 'internal')
-rw-r--r--internal/fusefrontend/root_node.go15
-rw-r--r--internal/fusefrontend_reverse/root_node.go15
2 files changed, 26 insertions, 4 deletions
diff --git a/internal/fusefrontend/root_node.go b/internal/fusefrontend/root_node.go
index 39cdef7..ac814ad 100644
--- a/internal/fusefrontend/root_node.go
+++ b/internal/fusefrontend/root_node.go
@@ -59,13 +59,16 @@ type RootNode struct {
// quirks is a bitmap that enables workaround for quirks in the filesystem
// backing the cipherdir
quirks uint64
+ // rootIno is the inode number that we report for the root node on mount
+ rootIno uint64
}
func NewRootNode(args Args, c *contentenc.ContentEnc, n *nametransform.NameTransform) *RootNode {
var rootDev uint64
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)
+ var statErr error
+ if statErr = syscall.Stat(args.Cipherdir, &st); statErr != nil {
+ tlog.Warn.Printf("Could not stat backing directory %q: %v", args.Cipherdir, statErr)
} else {
rootDev = uint64(st.Dev)
}
@@ -87,6 +90,10 @@ func NewRootNode(args Args, c *contentenc.ContentEnc, n *nametransform.NameTrans
dirCache: dirCache{ivLen: ivLen},
quirks: syscallcompat.DetectQuirks(args.Cipherdir),
}
+ if statErr == nil {
+ rn.inoMap.TranslateStat(&st)
+ rn.rootIno = st.Ino
+ }
return rn
}
@@ -288,3 +295,7 @@ func (rn *RootNode) decryptXattrName(cAttr string) (attr string, err error) {
}
return attr, nil
}
+
+func (rn *RootNode) RootIno() uint64 {
+ return rn.rootIno
+}
diff --git a/internal/fusefrontend_reverse/root_node.go b/internal/fusefrontend_reverse/root_node.go
index 9de81b5..cb04151 100644
--- a/internal/fusefrontend_reverse/root_node.go
+++ b/internal/fusefrontend_reverse/root_node.go
@@ -51,6 +51,8 @@ type RootNode struct {
// bizarre problems when inode numbers are reused behind our back,
// like this one: https://github.com/rfjakob/gocryptfs/issues/802
gen uint64
+ // rootIno is the inode number that we report for the root node on mount
+ rootIno uint64
}
// NewRootNode returns an encrypted FUSE overlay filesystem.
@@ -59,9 +61,10 @@ type RootNode struct {
func NewRootNode(args fusefrontend.Args, c *contentenc.ContentEnc, n *nametransform.NameTransform) *RootNode {
var rootDev uint64
var st syscall.Stat_t
+ var statErr error
var shortNameMax int
- if err := syscall.Stat(args.Cipherdir, &st); err != nil {
- tlog.Warn.Printf("Could not stat backing directory %q: %v", args.Cipherdir, err)
+ if statErr = syscall.Stat(args.Cipherdir, &st); statErr != nil {
+ tlog.Warn.Printf("Could not stat backing directory %q: %v", args.Cipherdir, statErr)
if args.OneFileSystem {
tlog.Fatal.Printf("This is a fatal error in combination with -one-file-system")
os.Exit(exitcodes.CipherDir)
@@ -81,6 +84,10 @@ func NewRootNode(args fusefrontend.Args, c *contentenc.ContentEnc, n *nametransf
rootDev: rootDev,
shortNameMax: shortNameMax,
}
+ if statErr == nil {
+ rn.inoMap.TranslateStat(&st)
+ rn.rootIno = st.Ino
+ }
if len(args.Exclude) > 0 || len(args.ExcludeWildcard) > 0 || len(args.ExcludeFrom) > 0 {
rn.excluder = prepareExcluder(args)
}
@@ -171,3 +178,7 @@ func (rn *RootNode) uniqueStableAttr(mode uint32, ino uint64) fs.StableAttr {
Gen: atomic.AddUint64(&rn.gen, 1),
}
}
+
+func (rn *RootNode) RootIno() uint64 {
+ return rn.rootIno
+}