restic/internal/fuse/link.go

46 lines
913 B
Go
Raw Normal View History

// +build darwin freebsd linux
2015-08-16 16:27:07 -04:00
2015-07-21 15:25:05 -04:00
package fuse
import (
"context"
2015-07-21 15:25:05 -04:00
"bazil.org/fuse"
"bazil.org/fuse/fs"
2017-07-24 11:42:25 -04:00
"github.com/restic/restic/internal/restic"
2015-07-21 15:25:05 -04:00
)
2017-09-17 11:34:19 -04:00
// Statically ensure that *link implements the given interface
2015-07-21 15:25:05 -04:00
var _ = fs.NodeReadlinker(&link{})
type link struct {
2017-06-18 09:11:32 -04:00
root *Root
node *restic.Node
inode uint64
2015-07-21 15:25:05 -04:00
}
2017-06-18 09:11:32 -04: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 15:25:05 -04: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 09:11:32 -04:00
a.Inode = l.inode
2015-07-21 15:25:05 -04:00
a.Mode = l.node.Mode
2017-06-18 09:11:32 -04:00
if !l.root.cfg.OwnerIsRoot {
a.Uid = l.node.UID
a.Gid = l.node.GID
}
2015-07-21 16:11:30 -04:00
a.Atime = l.node.AccessTime
a.Ctime = l.node.ChangeTime
a.Mtime = l.node.ModTime
2017-02-11 15:50:03 -05:00
a.Nlink = uint32(l.node.Links)
2015-07-21 15:25:05 -04:00
return nil
}