summaryrefslogtreecommitdiff
path: root/frontend/fe_fs.go
blob: 4d49194f91f5dd862fbfa6905302e3b0d2ce493c (plain)
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 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 {
	var nt nullTracer
	clfs, err := cluefs.NewClueFS(backing, nt)
	if err != nil {
		panic(err)
	}
	return &FS {
		CryptFS: cryptfs.NewCryptFS(key, useOpenssl),
		ClueFS: clfs,
		backing: backing,
	}
}

func (fs *FS) Root() (fusefs.Node, error) {
	cryptfs.Debug.Printf("Root\n")
	return NewDir("", fs.backing, fs), nil
}