2015-09-07 21:10:42 +02:00
|
|
|
package cluefs_frontend
|
2015-09-03 19:09:23 +02:00
|
|
|
|
2015-09-05 20:30:20 +02:00
|
|
|
// 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
|
|
|
|
|
2015-09-03 19:09:23 +02:00
|
|
|
import (
|
|
|
|
"github.com/rfjakob/gocryptfs/cryptfs"
|
2015-09-04 20:31:06 +02:00
|
|
|
"github.com/rfjakob/cluefs/lib/cluefs"
|
2015-09-05 11:49:05 +02:00
|
|
|
fusefs "bazil.org/fuse/fs"
|
2015-09-03 19:09:23 +02:00
|
|
|
)
|
|
|
|
|
|
|
|
type FS struct {
|
2015-09-04 20:31:06 +02:00
|
|
|
*cryptfs.CryptFS
|
|
|
|
*cluefs.ClueFS
|
2015-09-05 11:49:05 +02:00
|
|
|
backing string
|
2015-09-03 19:27:07 +02:00
|
|
|
}
|
|
|
|
|
2015-09-04 20:31:06 +02:00
|
|
|
type nullTracer struct {}
|
2015-09-03 19:27:07 +02:00
|
|
|
|
2015-09-04 20:31:06 +02:00
|
|
|
func (nullTracer) Trace(op cluefs.FsOperTracer) {}
|
|
|
|
|
2015-09-06 11:42:01 +02:00
|
|
|
func NewFS(key [16]byte, backing string, useOpenssl bool) (*FS, error) {
|
|
|
|
var tracer nullTracer
|
|
|
|
clfs, err := cluefs.NewClueFS(backing, tracer)
|
2015-09-04 20:31:06 +02:00
|
|
|
if err != nil {
|
2015-09-06 11:42:01 +02:00
|
|
|
return nil, err
|
2015-09-04 20:31:06 +02:00
|
|
|
}
|
|
|
|
return &FS {
|
2015-09-06 10:38:43 +02:00
|
|
|
CryptFS: cryptfs.NewCryptFS(key, useOpenssl),
|
2015-09-04 20:31:06 +02:00
|
|
|
ClueFS: clfs,
|
2015-09-05 11:49:05 +02:00
|
|
|
backing: backing,
|
2015-09-06 11:42:01 +02:00
|
|
|
}, nil
|
2015-09-03 19:09:23 +02:00
|
|
|
}
|
2015-09-05 11:49:05 +02:00
|
|
|
|
|
|
|
func (fs *FS) Root() (fusefs.Node, error) {
|
2015-09-05 20:36:26 +02:00
|
|
|
cryptfs.Debug.Printf("Root\n")
|
2015-09-05 11:49:05 +02:00
|
|
|
return NewDir("", fs.backing, fs), nil
|
|
|
|
}
|