-
Notifications
You must be signed in to change notification settings - Fork 1
/
main.go
46 lines (38 loc) · 935 Bytes
/
main.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
package main
import (
"fmt"
"log"
"os"
"os/signal"
"github.com/hanwen/go-fuse/fuse"
"github.com/hanwen/go-fuse/fuse/nodefs"
"github.com/chzchzchz/goboardfs/boardfs"
)
func main() {
if len(os.Args) < 2 {
fmt.Fprintf(os.Stderr, "Usage: %s <mountpoint>\n", os.Args[0])
os.Exit(1)
}
mountOptions := &fuse.MountOptions{
AllowOther: true,
Name: "boardfs",
Options: []string{"default_permissions"},
}
mountpoint := os.Args[1]
root := boardfs.NewRootNode()
conn := nodefs.NewFileSystemConnector(root, &nodefs.Options{})
server, err := fuse.NewServer(conn.RawFS(), mountpoint, mountOptions)
if err != nil {
log.Fatalf("Mount fail: %v\n", err)
}
// shutdown fuseserver on SIGINT
sigchan := make(chan os.Signal, 1)
signal.Notify(sigchan, os.Interrupt, os.Kill)
go func() {
sig := <-sigchan
fmt.Print("\nExiting on ", sig, "\n")
server.Unmount()
}()
server.Serve()
signal.Stop(sigchan)
}