aboutsummaryrefslogtreecommitdiff
path: root/internal
diff options
context:
space:
mode:
Diffstat (limited to 'internal')
-rw-r--r--internal/fusefrontend/args.go3
-rw-r--r--internal/fusefrontend/node_helpers.go3
-rw-r--r--internal/fusefrontend/root_node.go10
-rw-r--r--internal/inomap/inomap.go11
4 files changed, 24 insertions, 3 deletions
diff --git a/internal/fusefrontend/args.go b/internal/fusefrontend/args.go
index 5eb6bff..ae1c30c 100644
--- a/internal/fusefrontend/args.go
+++ b/internal/fusefrontend/args.go
@@ -46,4 +46,7 @@ type Args struct {
Suid bool
// Enable the FUSE kernel_cache option
KernelCache bool
+ // SharedStorage disables caching & hard link tracking,
+ // enabled via cli flag "-sharedstorage"
+ SharedStorage bool
}
diff --git a/internal/fusefrontend/node_helpers.go b/internal/fusefrontend/node_helpers.go
index ad92043..f99e6df 100644
--- a/internal/fusefrontend/node_helpers.go
+++ b/internal/fusefrontend/node_helpers.go
@@ -102,8 +102,9 @@ func (n *Node) prepareAtSyscall(child string) (dirfd int, cName string, errno sy
// newChild attaches a new child inode to n.
// The passed-in `st` will be modified to get a unique inode number.
func (n *Node) newChild(ctx context.Context, st *syscall.Stat_t, out *fuse.EntryOut) *fs.Inode {
- // Get unique inode number
rn := n.rootNode()
+ // Get stable inode number based on underlying (device,ino) pair
+ // (or set to zero in case of `-sharestorage`)
rn.inoMap.TranslateStat(st)
out.Attr.FromStat(st)
// Create child node
diff --git a/internal/fusefrontend/root_node.go b/internal/fusefrontend/root_node.go
index e03e250..bdefafa 100644
--- a/internal/fusefrontend/root_node.go
+++ b/internal/fusefrontend/root_node.go
@@ -50,7 +50,7 @@ type RootNode struct {
IsIdle uint32
// inoMap translates inode numbers from different devices to unique inode
// numbers.
- inoMap *inomap.InoMap
+ inoMap inomap.TranslateStater
}
func NewRootNode(args Args, c *contentenc.ContentEnc, n nametransform.NameTransformer) *RootNode {
@@ -60,12 +60,18 @@ func NewRootNode(args Args, c *contentenc.ContentEnc, n nametransform.NameTransf
if len(args.Exclude) > 0 {
tlog.Warn.Printf("Forward mode does not support -exclude")
}
- return &RootNode{
+ rn := &RootNode{
args: args,
nameTransform: n,
contentEnc: c,
inoMap: inomap.New(),
}
+ // In `-sharedstorage` mode we always set the inode number to zero.
+ // This makes go-fuse generate a new inode number for each lookup.
+ if args.SharedStorage {
+ rn.inoMap = &inomap.TranslateStatZero{}
+ }
+ return rn
}
// mangleOpenFlags is used by Create() and Open() to convert the open flags the user
diff --git a/internal/inomap/inomap.go b/internal/inomap/inomap.go
index 82d50b0..0977a46 100644
--- a/internal/inomap/inomap.go
+++ b/internal/inomap/inomap.go
@@ -104,3 +104,14 @@ func (m *InoMap) TranslateStat(st *syscall.Stat_t) {
in := QInoFromStat(st)
st.Ino = m.Translate(in)
}
+
+type TranslateStater interface {
+ TranslateStat(st *syscall.Stat_t)
+}
+
+// TranslateStatZero always sets st.Ino to zero. Used for `-sharedstorage`.
+type TranslateStatZero struct{}
+
+func (z TranslateStatZero) TranslateStat(st *syscall.Stat_t) {
+ st.Ino = 0
+}