summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--cluefs_frontend/fe_checks.go (renamed from frontend/fe_checks.go)2
-rw-r--r--cluefs_frontend/fe_dir.go (renamed from frontend/fe_dir.go)53
-rw-r--r--cluefs_frontend/fe_file.go (renamed from frontend/fe_file.go)2
-rw-r--r--cluefs_frontend/fe_fs.go (renamed from frontend/fe_fs.go)2
-rw-r--r--main.go2
5 files changed, 55 insertions, 6 deletions
diff --git a/frontend/fe_checks.go b/cluefs_frontend/fe_checks.go
index 30720f6..c555436 100644
--- a/frontend/fe_checks.go
+++ b/cluefs_frontend/fe_checks.go
@@ -1,4 +1,4 @@
-package frontend
+package cluefs_frontend
import (
"bazil.org/fuse/fs"
diff --git a/frontend/fe_dir.go b/cluefs_frontend/fe_dir.go
index 9849968..65d92f1 100644
--- a/frontend/fe_dir.go
+++ b/cluefs_frontend/fe_dir.go
@@ -1,4 +1,4 @@
-package frontend
+package cluefs_frontend
// frontend sits between FUSE and ClueFS
// and uses cryptfs for all crypto operations
@@ -22,7 +22,6 @@ import (
type Dir struct {
*cluefs.Dir
-
crfs *cryptfs.CryptFS
}
@@ -129,3 +128,53 @@ func (d *Dir) Create(ctx context.Context, req *fuse.CreateRequest, resp *fuse.Cr
}
return cryptFile, cryptFile, nil
}
+func (d *Dir) Symlink(ctx context.Context, req *fuse.SymlinkRequest) (fusefs.Node, error) {
+ req.Target = d.crfs.EncryptPath(req.Target)
+ req.NewName = d.crfs.EncryptPath(req.NewName)
+ node, err := d.Dir.Symlink(ctx, req)
+ if err != nil {
+ return nil, err
+ }
+
+ clueDir, ok := node.(*cluefs.Dir)
+ if ok {
+ return &Dir {
+ Dir: clueDir,
+ crfs: d.crfs,
+ }, nil
+ } else {
+ clueFile := node.(*cluefs.File)
+ return &File {
+ File: clueFile,
+ crfs: d.crfs,
+ }, nil
+ }
+}
+// We need to overwrite Readlink for both Dir and File. Do both right here to keep them in sync.
+func (d *Dir) Readlink(ctx context.Context, req *fuse.ReadlinkRequest) (string, error) {
+ dest, err := d.Dir.Readlink(ctx, req)
+ if err != nil {
+ return "", err
+ }
+ return d.crfs.DecryptPath(dest)
+}
+func (d *File) Readlink(ctx context.Context, req *fuse.ReadlinkRequest) (string, error) {
+ dest, err := d.File.Readlink(ctx, req)
+ if err != nil {
+ return "", err
+ }
+ return d.crfs.DecryptPath(dest)
+}
+// We need to overwrite Rename for both Dir and File. Do both right here to keep them in sync.
+func (d *Dir) Rename(ctx context.Context, req *fuse.RenameRequest, newDir fusefs.Node) error {
+ req.OldName = d.crfs.EncryptPath(req.OldName)
+ req.NewName = d.crfs.EncryptPath(req.NewName)
+ destDir := newDir.(*Dir)
+ return d.Dir.Rename(ctx, req, destDir.Dir)
+}
+func (d *File) Rename(ctx context.Context, req *fuse.RenameRequest, newDir fusefs.Node) error {
+ req.OldName = d.crfs.EncryptPath(req.OldName)
+ req.NewName = d.crfs.EncryptPath(req.NewName)
+ destDir := newDir.(*Dir)
+ return d.File.Rename(ctx, req, destDir.Dir)
+}
diff --git a/frontend/fe_file.go b/cluefs_frontend/fe_file.go
index 4679589..4c4e38a 100644
--- a/frontend/fe_file.go
+++ b/cluefs_frontend/fe_file.go
@@ -1,4 +1,4 @@
-package frontend
+package cluefs_frontend
// frontend sits between FUSE and ClueFS
// and uses cryptfs for all crypto operations
diff --git a/frontend/fe_fs.go b/cluefs_frontend/fe_fs.go
index d1fa5b1..2b12da6 100644
--- a/frontend/fe_fs.go
+++ b/cluefs_frontend/fe_fs.go
@@ -1,4 +1,4 @@
-package frontend
+package cluefs_frontend
// frontend sits between FUSE and ClueFS
// and uses cryptfs for all crypto operations
diff --git a/main.go b/main.go
index 071415a..c279612 100644
--- a/main.go
+++ b/main.go
@@ -5,7 +5,7 @@ import (
fusefs "bazil.org/fuse/fs"
"flag"
"fmt"
- "github.com/rfjakob/gocryptfs/frontend"
+ frontend "github.com/rfjakob/gocryptfs/cluefs_frontend"
"os"
"path/filepath"
)