libgocryptfs/main.go

59 lines
1.1 KiB
Go
Raw Normal View History

2015-09-03 19:27:07 +02:00
package main
import (
2015-09-05 11:49:05 +02:00
"bazil.org/fuse"
fusefs "bazil.org/fuse/fs"
"fmt"
"github.com/rfjakob/cluefs/lib/cluefs"
2015-09-03 19:27:07 +02:00
"github.com/rfjakob/gocryptfs/frontend"
"os"
2015-09-03 19:27:07 +02:00
)
2015-09-05 11:49:05 +02:00
const (
PROGRAM_NAME = "gocryptfs"
USE_OPENSSL = true
2015-09-05 11:49:05 +02:00
)
2015-09-03 19:27:07 +02:00
func main() {
// Parse command line arguments
conf, err := cluefs.ParseArguments()
2015-09-03 19:27:07 +02:00
if err != nil {
os.Exit(1)
2015-09-03 19:27:07 +02:00
}
// Create the file system object
2015-09-03 19:27:07 +02:00
var key [16]byte
cfs := frontend.NewFS(key, conf.GetShadowDir(), USE_OPENSSL)
2015-09-03 19:27:07 +02:00
2015-09-05 11:49:05 +02:00
// Mount the file system
mountOpts := []fuse.MountOption{
fuse.FSName(PROGRAM_NAME),
fuse.Subtype(PROGRAM_NAME),
fuse.VolumeName(PROGRAM_NAME),
fuse.LocalVolume(),
fuse.MaxReadahead(1024*1024),
2015-09-05 11:49:05 +02:00
}
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)
2015-09-03 19:27:07 +02:00
}
// We are done
os.Exit(0)
2015-09-03 19:27:07 +02:00
}