aboutsummaryrefslogtreecommitdiff
path: root/internal/fusefrontend
diff options
context:
space:
mode:
authorJakob Unterwurzacher2019-01-02 21:52:52 +0100
committerJakob Unterwurzacher2019-01-02 21:52:52 +0100
commit352f3147c5f1260cf729692d945c87e210cb1ad8 (patch)
tree7678cd13a18f1d4bf2c4f24c2e15df0c7fc85f6f /internal/fusefrontend
parent2b12bba274ba75f76ac8c2af3790e4190b32396f (diff)
fusefrontend: move openBackingDir into its own file
This function is in all fastpaths, will get a cache, and needs its own file. renamed: internal/fusefrontend/names.go -> internal/fusefrontend/openbackingdir.go renamed: internal/fusefrontend/names_test.go -> internal/fusefrontend/openbackingdir_test.go
Diffstat (limited to 'internal/fusefrontend')
-rw-r--r--internal/fusefrontend/fs.go19
-rw-r--r--internal/fusefrontend/openbackingdir.go (renamed from internal/fusefrontend/names.go)22
-rw-r--r--internal/fusefrontend/openbackingdir_test.go (renamed from internal/fusefrontend/names_test.go)0
3 files changed, 19 insertions, 22 deletions
diff --git a/internal/fusefrontend/fs.go b/internal/fusefrontend/fs.go
index 5c52a19..5adade6 100644
--- a/internal/fusefrontend/fs.go
+++ b/internal/fusefrontend/fs.go
@@ -16,6 +16,7 @@ import (
"github.com/hanwen/go-fuse/fuse/nodefs"
"github.com/hanwen/go-fuse/fuse/pathfs"
+ "github.com/rfjakob/gocryptfs/internal/configfile"
"github.com/rfjakob/gocryptfs/internal/contentenc"
"github.com/rfjakob/gocryptfs/internal/nametransform"
"github.com/rfjakob/gocryptfs/internal/serialize_reads"
@@ -661,3 +662,21 @@ func (fs *FS) reportMitigatedCorruption(item string) {
return
}
}
+
+// isFiltered - check if plaintext "path" should be forbidden
+//
+// Prevents name clashes with internal files when file names are not encrypted
+func (fs *FS) isFiltered(path string) bool {
+ if !fs.args.PlaintextNames {
+ return false
+ }
+ // gocryptfs.conf in the root directory is forbidden
+ if path == configfile.ConfDefaultName {
+ tlog.Info.Printf("The name /%s is reserved when -plaintextnames is used\n",
+ configfile.ConfDefaultName)
+ return true
+ }
+ // Note: gocryptfs.diriv is NOT forbidden because diriv and plaintextnames
+ // are exclusive
+ return false
+}
diff --git a/internal/fusefrontend/names.go b/internal/fusefrontend/openbackingdir.go
index 63f2e84..849a486 100644
--- a/internal/fusefrontend/names.go
+++ b/internal/fusefrontend/openbackingdir.go
@@ -1,36 +1,14 @@
package fusefrontend
-// This file forwards file encryption operations to cryptfs
-
import (
"path/filepath"
"strings"
"syscall"
- "github.com/rfjakob/gocryptfs/internal/configfile"
"github.com/rfjakob/gocryptfs/internal/nametransform"
"github.com/rfjakob/gocryptfs/internal/syscallcompat"
- "github.com/rfjakob/gocryptfs/internal/tlog"
)
-// isFiltered - check if plaintext "path" should be forbidden
-//
-// Prevents name clashes with internal files when file names are not encrypted
-func (fs *FS) isFiltered(path string) bool {
- if !fs.args.PlaintextNames {
- return false
- }
- // gocryptfs.conf in the root directory is forbidden
- if path == configfile.ConfDefaultName {
- tlog.Info.Printf("The name /%s is reserved when -plaintextnames is used\n",
- configfile.ConfDefaultName)
- return true
- }
- // Note: gocryptfs.diriv is NOT forbidden because diriv and plaintextnames
- // are exclusive
- return false
-}
-
// openBackingDir opens the parent ciphertext directory of plaintext path
// "relPath" and returns the dirfd and the encrypted basename.
//
diff --git a/internal/fusefrontend/names_test.go b/internal/fusefrontend/openbackingdir_test.go
index 8453e52..8453e52 100644
--- a/internal/fusefrontend/names_test.go
+++ b/internal/fusefrontend/openbackingdir_test.go