2015-08-16 20:27:07 +00:00
|
|
|
// +build !openbsd
|
|
|
|
|
2015-07-21 19:25:05 +00:00
|
|
|
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 {
|
2015-07-26 18:41:29 +00:00
|
|
|
node *restic.Node
|
|
|
|
ownerIsRoot bool
|
2015-07-21 19:25:05 +00:00
|
|
|
}
|
|
|
|
|
2015-07-26 18:41:29 +00:00
|
|
|
func newLink(repo *repository.Repository, node *restic.Node, ownerIsRoot bool) (*link, error) {
|
|
|
|
return &link{node: node, ownerIsRoot: ownerIsRoot}, nil
|
2015-07-21 19:25:05 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
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
|
2015-07-26 18:41:29 +00:00
|
|
|
|
|
|
|
if !l.ownerIsRoot {
|
|
|
|
a.Uid = l.node.UID
|
|
|
|
a.Gid = l.node.GID
|
|
|
|
}
|
2015-07-21 20:11:30 +00:00
|
|
|
a.Atime = l.node.AccessTime
|
|
|
|
a.Ctime = l.node.ChangeTime
|
|
|
|
a.Mtime = l.node.ModTime
|
2015-07-21 19:25:05 +00:00
|
|
|
return nil
|
|
|
|
}
|