/
types.go
69 lines (55 loc) · 1.21 KB
/
types.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
package stofuse
import (
"context"
stdfs "io/fs"
"bazil.org/fuse"
"bazil.org/fuse/fs"
)
type sigFabric struct {
unmountAll chan interface{}
}
func newSigs() *sigFabric {
return &sigFabric{
unmountAll: make(chan interface{}),
}
}
// couples together a directory entry ("node name") and a node
type stoEntry struct {
dirent fuse.Dirent // name found from here
node fs.Node
}
func newStoEntry(dirent fuse.Dirent, node fs.Node) stoEntry {
return stoEntry{dirent, node}
}
type stoSymlink struct {
target string
inode uint64
}
func (s *stoSymlink) MakeDirent(name string) fuse.Dirent {
return fuse.Dirent{
Inode: s.inode,
Name: name,
Type: fuse.DT_Link,
}
}
func (s *stoSymlink) MakeStoEntry(name string) stoEntry {
return stoEntry{s.MakeDirent(name), s}
}
func newStoSymlink(target string) *stoSymlink {
return &stoSymlink{
target: target,
inode: nextInode(),
}
}
func (s *stoSymlink) Readlink(_ context.Context, req *fuse.ReadlinkRequest) (string, error) {
return s.target, nil
}
func (s *stoSymlink) Attr(_ context.Context, attr *fuse.Attr) error {
attr.Inode = s.inode
attr.Mode = stdfs.ModeSymlink | 0555
return nil
}
var _ interface {
fs.NodeReadlinker
fs.Node
} = (*stoSymlink)(nil)