2015-08-16 20:27:07 +00:00
|
|
|
// +build !openbsd
|
2015-08-17 17:40:34 +00:00
|
|
|
// +build !windows
|
2015-08-16 20:27:07 +00:00
|
|
|
|
2015-07-21 19:25:05 +00:00
|
|
|
package fuse
|
|
|
|
|
|
|
|
import (
|
2017-07-23 12:21:03 +00:00
|
|
|
"github.com/restic/restic/internal"
|
2016-08-21 15:46:23 +00:00
|
|
|
|
2015-07-21 19:25:05 +00:00
|
|
|
"bazil.org/fuse"
|
|
|
|
"bazil.org/fuse/fs"
|
|
|
|
"golang.org/x/net/context"
|
|
|
|
)
|
|
|
|
|
|
|
|
// Statically ensure that *file implements the given interface
|
|
|
|
var _ = fs.NodeReadlinker(&link{})
|
|
|
|
|
|
|
|
type link struct {
|
2017-06-18 13:11:32 +00:00
|
|
|
root *Root
|
|
|
|
node *restic.Node
|
|
|
|
inode uint64
|
2015-07-21 19:25:05 +00:00
|
|
|
}
|
|
|
|
|
2017-06-18 13:11:32 +00:00
|
|
|
func newLink(ctx context.Context, root *Root, inode uint64, node *restic.Node) (*link, error) {
|
|
|
|
return &link{root: root, inode: inode, node: node}, 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 {
|
2017-06-18 13:11:32 +00:00
|
|
|
a.Inode = l.inode
|
2015-07-21 19:25:05 +00:00
|
|
|
a.Mode = l.node.Mode
|
2015-07-26 18:41:29 +00:00
|
|
|
|
2017-06-18 13:11:32 +00:00
|
|
|
if !l.root.cfg.OwnerIsRoot {
|
2015-07-26 18:41:29 +00:00
|
|
|
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
|
2017-02-11 20:50:03 +00:00
|
|
|
|
|
|
|
a.Nlink = uint32(l.node.Links)
|
|
|
|
|
2015-07-21 19:25:05 +00:00
|
|
|
return nil
|
|
|
|
}
|