From 0b7291b8b2398768d9cbb589cef0157492b934e2 Mon Sep 17 00:00:00 2001 From: Michael Eischer Date: Sun, 7 Aug 2022 13:02:40 +0200 Subject: [PATCH] mount: Fix parent inode used by snapshots dir --- internal/fuse/root.go | 2 +- internal/fuse/snapshots_dir.go | 24 +++++++++++++----------- 2 files changed, 14 insertions(+), 12 deletions(-) diff --git a/internal/fuse/root.go b/internal/fuse/root.go index a68ed96f1..63ab96d6d 100644 --- a/internal/fuse/root.go +++ b/internal/fuse/root.go @@ -68,7 +68,7 @@ func NewRoot(repo restic.Repository, cfg Config) *Root { } } - root.SnapshotsDir = NewSnapshotsDir(root, rootInode, NewSnapshotsDirStructure(root, cfg.PathTemplates, cfg.TimeTemplate), "") + root.SnapshotsDir = NewSnapshotsDir(root, rootInode, rootInode, NewSnapshotsDirStructure(root, cfg.PathTemplates, cfg.TimeTemplate), "") return root } diff --git a/internal/fuse/snapshots_dir.go b/internal/fuse/snapshots_dir.go index e5b18b20f..34bcccc4d 100644 --- a/internal/fuse/snapshots_dir.go +++ b/internal/fuse/snapshots_dir.go @@ -17,10 +17,11 @@ import ( // SnapshotsDir is a actual fuse directory generated from SnapshotsDirStructure // It uses the saved prefix to select the corresponding MetaDirData. type SnapshotsDir struct { - root *Root - inode uint64 - dirStruct *SnapshotsDirStructure - prefix string + root *Root + inode uint64 + parentInode uint64 + dirStruct *SnapshotsDirStructure + prefix string } // ensure that *SnapshotsDir implements these interfaces @@ -28,13 +29,14 @@ var _ = fs.HandleReadDirAller(&SnapshotsDir{}) var _ = fs.NodeStringLookuper(&SnapshotsDir{}) // NewSnapshotsDir returns a new directory structure containing snapshots and "latest" links -func NewSnapshotsDir(root *Root, inode uint64, dirStruct *SnapshotsDirStructure, prefix string) *SnapshotsDir { +func NewSnapshotsDir(root *Root, inode, parentInode uint64, dirStruct *SnapshotsDirStructure, prefix string) *SnapshotsDir { debug.Log("create snapshots dir, inode %d", inode) return &SnapshotsDir{ - root: root, - inode: inode, - dirStruct: dirStruct, - prefix: prefix, + root: root, + inode: inode, + parentInode: parentInode, + dirStruct: dirStruct, + prefix: prefix, } } @@ -68,7 +70,7 @@ func (d *SnapshotsDir) ReadDirAll(ctx context.Context) ([]fuse.Dirent, error) { Type: fuse.DT_Dir, }, { - Inode: d.root.inode, + Inode: d.parentInode, Name: "..", Type: fuse.DT_Dir, }, @@ -107,7 +109,7 @@ func (d *SnapshotsDir) Lookup(ctx context.Context, name string) (fs.Node, error) } else if entry.snapshot != nil { return newDirFromSnapshot(ctx, d.root, fs.GenerateDynamicInode(d.inode, name), entry.snapshot) } else { - return NewSnapshotsDir(d.root, fs.GenerateDynamicInode(d.inode, name), d.dirStruct, d.prefix+"/"+name), nil + return NewSnapshotsDir(d.root, fs.GenerateDynamicInode(d.inode, name), d.inode, d.dirStruct, d.prefix+"/"+name), nil } }