forked from TrueCloudLab/restic
fuse: Add '.' and '..' entries to all directories
This commit is contained in:
parent
f8176a74ec
commit
f4e85a53e7
1 changed files with 25 additions and 11 deletions
|
@ -22,12 +22,13 @@ type dir struct {
|
||||||
root *Root
|
root *Root
|
||||||
items map[string]*restic.Node
|
items map[string]*restic.Node
|
||||||
inode uint64
|
inode uint64
|
||||||
|
parentInode uint64
|
||||||
node *restic.Node
|
node *restic.Node
|
||||||
|
|
||||||
blobsize *BlobSizeCache
|
blobsize *BlobSizeCache
|
||||||
}
|
}
|
||||||
|
|
||||||
func newDir(ctx context.Context, root *Root, inode uint64, node *restic.Node) (*dir, error) {
|
func newDir(ctx context.Context, root *Root, inode, parentInode uint64, node *restic.Node) (*dir, error) {
|
||||||
debug.Log("new dir for %v (%v)", node.Name, node.Subtree.Str())
|
debug.Log("new dir for %v (%v)", node.Name, node.Subtree.Str())
|
||||||
tree, err := root.repo.LoadTree(ctx, *node.Subtree)
|
tree, err := root.repo.LoadTree(ctx, *node.Subtree)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
@ -44,6 +45,7 @@ func newDir(ctx context.Context, root *Root, inode uint64, node *restic.Node) (*
|
||||||
node: node,
|
node: node,
|
||||||
items: items,
|
items: items,
|
||||||
inode: inode,
|
inode: inode,
|
||||||
|
parentInode: parentInode,
|
||||||
}, nil
|
}, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -134,7 +136,19 @@ func (d *dir) calcNumberOfLinks() uint32 {
|
||||||
|
|
||||||
func (d *dir) ReadDirAll(ctx context.Context) ([]fuse.Dirent, error) {
|
func (d *dir) ReadDirAll(ctx context.Context) ([]fuse.Dirent, error) {
|
||||||
debug.Log("called")
|
debug.Log("called")
|
||||||
ret := make([]fuse.Dirent, 0, len(d.items))
|
ret := make([]fuse.Dirent, 0, len(d.items)+2)
|
||||||
|
|
||||||
|
ret = append(ret, fuse.Dirent{
|
||||||
|
Inode: d.inode,
|
||||||
|
Name: ".",
|
||||||
|
Type: fuse.DT_Dir,
|
||||||
|
})
|
||||||
|
|
||||||
|
ret = append(ret, fuse.Dirent{
|
||||||
|
Inode: d.parentInode,
|
||||||
|
Name: "..",
|
||||||
|
Type: fuse.DT_Dir,
|
||||||
|
})
|
||||||
|
|
||||||
for _, node := range d.items {
|
for _, node := range d.items {
|
||||||
var typ fuse.DirentType
|
var typ fuse.DirentType
|
||||||
|
@ -166,7 +180,7 @@ func (d *dir) Lookup(ctx context.Context, name string) (fs.Node, error) {
|
||||||
}
|
}
|
||||||
switch node.Type {
|
switch node.Type {
|
||||||
case "dir":
|
case "dir":
|
||||||
return newDir(ctx, d.root, fs.GenerateDynamicInode(d.inode, name), node)
|
return newDir(ctx, d.root, fs.GenerateDynamicInode(d.inode, name), d.inode, node)
|
||||||
case "file":
|
case "file":
|
||||||
return newFile(ctx, d.root, fs.GenerateDynamicInode(d.inode, name), node)
|
return newFile(ctx, d.root, fs.GenerateDynamicInode(d.inode, name), node)
|
||||||
case "symlink":
|
case "symlink":
|
||||||
|
|
Loading…
Reference in a new issue