aboutsummaryrefslogtreecommitdiff
path: root/internal/fusefrontend_reverse/node_dir_ops.go
diff options
context:
space:
mode:
authorJakob Unterwurzacher2021-08-16 18:40:48 +0200
committerJakob Unterwurzacher2021-08-16 19:23:58 +0200
commitb2724070d95234a8cd281f275211e0f827a8bbe1 (patch)
tree0c4efc4714d0826ac99ec40c905a111c9f9c7015 /internal/fusefrontend_reverse/node_dir_ops.go
parentad4b99170b9ad438909f5cba8c32109a18697a7a (diff)
reverse mode: implement -one-file-system
Fixes https://github.com/rfjakob/gocryptfs/issues/475
Diffstat (limited to 'internal/fusefrontend_reverse/node_dir_ops.go')
-rw-r--r--internal/fusefrontend_reverse/node_dir_ops.go23
1 files changed, 16 insertions, 7 deletions
diff --git a/internal/fusefrontend_reverse/node_dir_ops.go b/internal/fusefrontend_reverse/node_dir_ops.go
index c287284..21b9775 100644
--- a/internal/fusefrontend_reverse/node_dir_ops.go
+++ b/internal/fusefrontend_reverse/node_dir_ops.go
@@ -23,6 +23,22 @@ import (
// This function is symlink-safe through use of openBackingDir() and
// ReadDirIVAt().
func (n *Node) Readdir(ctx context.Context) (stream fs.DirStream, errno syscall.Errno) {
+ // Virtual files: at least one gocryptfs.diriv file
+ virtualFiles := []fuse.DirEntry{
+ {Mode: virtualFileMode, Name: nametransform.DirIVFilename},
+ }
+ rn := n.rootNode()
+
+ // This directory is a mountpoint. Present it as empty.
+ if rn.args.OneFileSystem && n.isOtherFilesystem {
+ if rn.args.PlaintextNames {
+ return fs.NewListDirStream(nil), 0
+ } else {
+ // An "empty" directory still has a gocryptfs.diriv file!
+ return fs.NewListDirStream(virtualFiles), 0
+ }
+ }
+
d, errno := n.prepareAtSyscall("")
if errno != 0 {
return
@@ -41,8 +57,6 @@ func (n *Node) Readdir(ctx context.Context) (stream fs.DirStream, errno syscall.
return nil, fs.ToErrno(err)
}
- rn := n.rootNode()
-
// Filter out excluded entries
entries = rn.excludeDirEntries(d, entries)
@@ -50,11 +64,6 @@ func (n *Node) Readdir(ctx context.Context) (stream fs.DirStream, errno syscall.
return n.readdirPlaintextnames(entries)
}
- // Virtual files: at least one gocryptfs.diriv file
- virtualFiles := []fuse.DirEntry{
- {Mode: virtualFileMode, Name: nametransform.DirIVFilename},
- }
-
dirIV := pathiv.Derive(d.cPath, pathiv.PurposeDirIV)
// Encrypt names
for i := range entries {