summaryrefslogtreecommitdiff
path: root/cluefs_frontend/fe_fs.go
diff options
context:
space:
mode:
authorJakob Unterwurzacher2015-09-07 21:10:42 +0200
committerJakob Unterwurzacher2015-09-07 21:10:42 +0200
commitaf0ae03db23f845dbcf8a6738057222ce7986bd8 (patch)
tree90aa7fc12b9b12b28c486b9bdc3e62ab40eb0fe6 /cluefs_frontend/fe_fs.go
parentcd9512801525a63530c1f74ac184fb1d73bff67b (diff)
Rename frontend to "cluefs_frontend"
Enables adding another frontend later
Diffstat (limited to 'cluefs_frontend/fe_fs.go')
-rw-r--r--cluefs_frontend/fe_fs.go46
1 files changed, 46 insertions, 0 deletions
diff --git a/cluefs_frontend/fe_fs.go b/cluefs_frontend/fe_fs.go
new file mode 100644
index 0000000..2b12da6
--- /dev/null
+++ b/cluefs_frontend/fe_fs.go
@@ -0,0 +1,46 @@
+package cluefs_frontend
+
+// frontend sits between FUSE and ClueFS
+// and uses cryptfs for all crypto operations
+//
+// cryptfs
+// ^
+// |
+// v
+// FUSE <-> frontend <-> ClueFS
+//
+// This file handles just the root directory
+
+import (
+ "github.com/rfjakob/gocryptfs/cryptfs"
+ "github.com/rfjakob/cluefs/lib/cluefs"
+ fusefs "bazil.org/fuse/fs"
+)
+
+type FS struct {
+ *cryptfs.CryptFS
+ *cluefs.ClueFS
+ backing string
+}
+
+type nullTracer struct {}
+
+func (nullTracer) Trace(op cluefs.FsOperTracer) {}
+
+func NewFS(key [16]byte, backing string, useOpenssl bool) (*FS, error) {
+ var tracer nullTracer
+ clfs, err := cluefs.NewClueFS(backing, tracer)
+ if err != nil {
+ return nil, err
+ }
+ return &FS {
+ CryptFS: cryptfs.NewCryptFS(key, useOpenssl),
+ ClueFS: clfs,
+ backing: backing,
+ }, nil
+}
+
+func (fs *FS) Root() (fusefs.Node, error) {
+ cryptfs.Debug.Printf("Root\n")
+ return NewDir("", fs.backing, fs), nil
+}