forked from fudanchii/kakigoori
/
kakigoori.go
53 lines (39 loc) · 963 Bytes
/
kakigoori.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
package main
import (
"log"
"os"
"time"
"github.com/hanwen/go-fuse/fuse"
"github.com/hanwen/go-fuse/fuse/nodefs"
"github.com/hanwen/go-fuse/fuse/pathfs"
"github.com/fudanchii/kakigoori/event"
"github.com/fudanchii/kakigoori/fs"
)
func main() {
var finalFs pathfs.FileSystem
config, err := parseConfig("config.json")
if err != nil {
log.Fatal(err)
}
event.StartListening()
kakigoorifs := fs.NewKakigooriFileSystem(config.Root)
finalFs = kakigoorifs
opts := &nodefs.Options{
NegativeTimeout: time.Second,
AttrTimeout: time.Second,
EntryTimeout: time.Second,
}
pathFs := pathfs.NewPathNodeFs(finalFs, nil)
conn := nodefs.NewFileSystemConnector(pathFs, opts)
mOpts := &fuse.MountOptions{
AllowOther: false,
}
state, err := fuse.NewServer(conn.RawFS(), config.MountPoint, mOpts)
if err != nil {
log.Printf("Mount fail: %v\n", err)
os.Exit(1)
}
state.SetDebug(false)
log.Println("Mounted!")
state.Serve()
}