summaryrefslogtreecommitdiff
path: root/main.go
diff options
context:
space:
mode:
authorJakob Unterwurzacher2015-09-05 11:49:05 +0200
committerJakob Unterwurzacher2015-09-05 11:49:05 +0200
commit05a5c0a0fffb4cb27c6e2dccda42d18ee067631c (patch)
tree11e83610503ea4e0f4cf7296979b6d358eff4e5d /main.go
parent6f90ec716a0e486628297a8d74e9f4d8d895e744 (diff)
Wrap cluefs part I
Diffstat (limited to 'main.go')
-rw-r--r--main.go36
1 files changed, 32 insertions, 4 deletions
diff --git a/main.go b/main.go
index af7bd21..6857b61 100644
--- a/main.go
+++ b/main.go
@@ -1,11 +1,18 @@
package main
import (
+ "bazil.org/fuse"
+ fusefs "bazil.org/fuse/fs"
+ "fmt"
"github.com/rfjakob/cluefs/lib/cluefs"
"github.com/rfjakob/gocryptfs/frontend"
"os"
)
+const (
+ PROGRAM_NAME = "gocryptfs"
+)
+
func main() {
// Parse command line arguments
conf, err := cluefs.ParseArguments()
@@ -17,10 +24,31 @@ func main() {
var key [16]byte
cfs := frontend.NewFS(key, conf.GetShadowDir())
- // Mount and serve file system requests
- if err = cfs.MountAndServe(conf.GetMountPoint(), conf.GetReadOnly()); err != nil {
- cluefs.ErrlogMain.Printf("could not mount file system [%s]", err)
- os.Exit(3)
+ // Mount the file system
+ mountOpts := []fuse.MountOption{
+ fuse.FSName(PROGRAM_NAME),
+ fuse.Subtype(PROGRAM_NAME),
+ fuse.VolumeName(PROGRAM_NAME),
+ fuse.LocalVolume(),
+ }
+ conn, err := fuse.Mount(conf.GetMountPoint(), mountOpts...)
+ if err != nil {
+ fmt.Println(err)
+ os.Exit(1)
+ }
+ defer conn.Close()
+
+ // Start serving requests
+ if err = fusefs.Serve(conn, cfs); err != nil {
+ fmt.Println(err)
+ os.Exit(1)
+ }
+
+ // Check for errors when mounting the file system
+ <-conn.Ready
+ if err = conn.MountError; err != nil {
+ fmt.Println(err)
+ os.Exit(1)
}
// We are done