2
2
mirror of https://github.com/octoleo/restic.git synced 2024-11-18 02:55:18 +00:00
restic/internal/fuse/link.go
Jasper Lievisse Adriaanse 96311d1a2b Add support for illumos/Solaris
This does come without xattr/fuse support at this point.

NB: not hooking up the integration tests as restic won't compile without
    cgo with Go < 1.10.
2018-03-04 20:11:29 +00:00

47 lines
955 B
Go

// +build !openbsd
// +build !solaris
// +build !windows
package fuse
import (
"bazil.org/fuse"
"bazil.org/fuse/fs"
"github.com/restic/restic/internal/restic"
"golang.org/x/net/context"
)
// Statically ensure that *link implements the given interface
var _ = fs.NodeReadlinker(&link{})
type link struct {
root *Root
node *restic.Node
inode uint64
}
func newLink(ctx context.Context, root *Root, inode uint64, node *restic.Node) (*link, error) {
return &link{root: root, inode: inode, 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.inode
a.Mode = l.node.Mode
if !l.root.cfg.OwnerIsRoot {
a.Uid = l.node.UID
a.Gid = l.node.GID
}
a.Atime = l.node.AccessTime
a.Ctime = l.node.ChangeTime
a.Mtime = l.node.ModTime
a.Nlink = uint32(l.node.Links)
return nil
}