From 86891054ef2a5d1b0b59c7c140aae284e7c5bd87 Mon Sep 17 00:00:00 2001 From: Jakob Unterwurzacher Date: Mon, 11 Nov 2024 22:27:42 +0100 Subject: 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 --- internal/fusefrontend/root_node.go | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) (limited to 'internal/fusefrontend/root_node.go') 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 +} -- cgit v1.2.3