mirror of https://github.com/restic/restic.git
fuse/mount: display symlinks properly
This commit is contained in:
parent
1ac72b8813
commit
3f4b5b8d48
|
@ -71,6 +71,8 @@ func (d *dir) ReadDirAll(ctx context.Context) ([]fuse.Dirent, error) {
|
||||||
typ = fuse.DT_Dir
|
typ = fuse.DT_Dir
|
||||||
case "file":
|
case "file":
|
||||||
typ = fuse.DT_File
|
typ = fuse.DT_File
|
||||||
|
case "symlink":
|
||||||
|
typ = fuse.DT_Link
|
||||||
}
|
}
|
||||||
|
|
||||||
ret = append(ret, fuse.Dirent{
|
ret = append(ret, fuse.Dirent{
|
||||||
|
@ -93,6 +95,8 @@ func (d *dir) Lookup(ctx context.Context, name string) (fs.Node, error) {
|
||||||
return newDir(d.repo, child)
|
return newDir(d.repo, child)
|
||||||
case "file":
|
case "file":
|
||||||
return newFile(d.repo, child)
|
return newFile(d.repo, child)
|
||||||
|
case "symlink":
|
||||||
|
return newLink(d.repo, child)
|
||||||
default:
|
default:
|
||||||
return nil, fuse.ENOENT
|
return nil, fuse.ENOENT
|
||||||
}
|
}
|
||||||
|
|
|
@ -0,0 +1,30 @@
|
||||||
|
package fuse
|
||||||
|
|
||||||
|
import (
|
||||||
|
"bazil.org/fuse"
|
||||||
|
"bazil.org/fuse/fs"
|
||||||
|
"github.com/restic/restic"
|
||||||
|
"github.com/restic/restic/repository"
|
||||||
|
"golang.org/x/net/context"
|
||||||
|
)
|
||||||
|
|
||||||
|
// Statically ensure that *file implements the given interface
|
||||||
|
var _ = fs.NodeReadlinker(&link{})
|
||||||
|
|
||||||
|
type link struct {
|
||||||
|
node *restic.Node
|
||||||
|
}
|
||||||
|
|
||||||
|
func newLink(repo *repository.Repository, node *restic.Node) (*link, error) {
|
||||||
|
return &link{node: node}, nil
|
||||||
|
}
|
||||||
|
|
||||||
|
func (l *link) Readlink(ctx context.Context, req *fuse.ReadlinkRequest) (string, error) {
|
||||||
|
return l.node.LinkTarget, nil
|
||||||
|
}
|
||||||
|
|
||||||
|
func (l *link) Attr(ctx context.Context, a *fuse.Attr) error {
|
||||||
|
a.Inode = l.node.Inode
|
||||||
|
a.Mode = l.node.Mode
|
||||||
|
return nil
|
||||||
|
}
|
Loading…
Reference in New Issue