2022-03-28 20:23:47 +00:00
|
|
|
//go:build darwin || freebsd || linux
|
2020-05-12 09:30:41 +00:00
|
|
|
// +build darwin freebsd linux
|
2017-12-03 16:25:00 +00:00
|
|
|
|
|
|
|
package fuse
|
|
|
|
|
|
|
|
import (
|
2020-10-05 21:09:52 +00:00
|
|
|
"context"
|
|
|
|
|
2022-11-12 13:52:37 +00:00
|
|
|
"github.com/anacrolix/fuse"
|
2024-09-09 20:37:08 +00:00
|
|
|
"github.com/anacrolix/fuse/fs"
|
2017-12-03 16:25:00 +00:00
|
|
|
"github.com/restic/restic/internal/restic"
|
|
|
|
)
|
|
|
|
|
2024-09-09 20:37:08 +00:00
|
|
|
// Statically ensure that *other implements the given interface
|
2024-09-09 20:37:51 +00:00
|
|
|
var _ = fs.NodeForgetter(&other{})
|
2024-09-09 20:37:08 +00:00
|
|
|
var _ = fs.NodeReadlinker(&other{})
|
|
|
|
|
2017-12-03 16:25:00 +00:00
|
|
|
type other struct {
|
2024-09-09 20:37:51 +00:00
|
|
|
root *Root
|
|
|
|
forget forgetFn
|
|
|
|
node *restic.Node
|
|
|
|
inode uint64
|
2017-12-03 16:25:00 +00:00
|
|
|
}
|
|
|
|
|
2024-09-09 20:37:51 +00:00
|
|
|
func newOther(root *Root, forget forgetFn, inode uint64, node *restic.Node) (*other, error) {
|
|
|
|
return &other{root: root, forget: forget, inode: inode, node: node}, nil
|
2017-12-03 16:25:00 +00:00
|
|
|
}
|
|
|
|
|
2023-05-18 17:27:38 +00:00
|
|
|
func (l *other) Readlink(_ context.Context, _ *fuse.ReadlinkRequest) (string, error) {
|
2017-12-03 16:25:00 +00:00
|
|
|
return l.node.LinkTarget, nil
|
|
|
|
}
|
|
|
|
|
2023-05-18 17:18:09 +00:00
|
|
|
func (l *other) Attr(_ context.Context, a *fuse.Attr) error {
|
2017-12-03 16:25:00 +00:00
|
|
|
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
|
|
|
|
}
|
2024-09-09 20:37:51 +00:00
|
|
|
|
|
|
|
func (l *other) Forget() {
|
|
|
|
l.forget()
|
|
|
|
}
|