From c9c7671c58b1888110d9afeee3117808ca98d2ff Mon Sep 17 00:00:00 2001 From: greatroar <61184462+greatroar@users.noreply.github.com> Date: Sun, 27 Nov 2022 13:53:42 +0100 Subject: [PATCH] fuse: Clean up inode generation --- internal/fuse/dir.go | 9 +++++---- internal/fuse/snapshots_dir.go | 7 ++++--- 2 files changed, 9 insertions(+), 7 deletions(-) diff --git a/internal/fuse/dir.go b/internal/fuse/dir.go index 74ff50070..7265e7ada 100644 --- a/internal/fuse/dir.go +++ b/internal/fuse/dir.go @@ -204,15 +204,16 @@ func (d *dir) Lookup(ctx context.Context, name string) (fs.Node, error) { debug.Log(" Lookup(%v) -> not found", name) return nil, fuse.ENOENT } + inode := inodeFromNode(d.inode, node) switch node.Type { case "dir": - return newDir(d.root, inodeFromNode(d.inode, node), d.inode, node) + return newDir(d.root, inode, d.inode, node) case "file": - return newFile(d.root, inodeFromNode(d.inode, node), node) + return newFile(d.root, inode, node) case "symlink": - return newLink(d.root, inodeFromNode(d.inode, node), node) + return newLink(d.root, inode, node) case "dev", "chardev", "fifo", "socket": - return newOther(d.root, inodeFromNode(d.inode, node), node) + return newOther(d.root, inode, node) default: debug.Log(" node %v has unknown type %v", name, node.Type) return nil, fuse.ENOENT diff --git a/internal/fuse/snapshots_dir.go b/internal/fuse/snapshots_dir.go index 21f29fe23..8fb9d387e 100644 --- a/internal/fuse/snapshots_dir.go +++ b/internal/fuse/snapshots_dir.go @@ -104,12 +104,13 @@ func (d *SnapshotsDir) Lookup(ctx context.Context, name string) (fs.Node, error) entry := meta.names[name] if entry != nil { + inode := inodeFromName(d.inode, name) if entry.linkTarget != "" { - return newSnapshotLink(d.root, inodeFromName(d.inode, name), entry.linkTarget, entry.snapshot) + return newSnapshotLink(d.root, inode, entry.linkTarget, entry.snapshot) } else if entry.snapshot != nil { - return newDirFromSnapshot(d.root, inodeFromName(d.inode, name), entry.snapshot) + return newDirFromSnapshot(d.root, inode, entry.snapshot) } else { - return NewSnapshotsDir(d.root, inodeFromName(d.inode, name), d.inode, d.dirStruct, d.prefix+"/"+name), nil + return NewSnapshotsDir(d.root, inode, d.inode, d.dirStruct, d.prefix+"/"+name), nil } }