aboutsummaryrefslogtreecommitdiff
path: root/internal/fusefrontend_reverse/node_helpers.go
diff options
context:
space:
mode:
authorJakob Unterwurzacher2020-08-09 22:11:46 +0200
committerJakob Unterwurzacher2020-08-09 22:11:46 +0200
commit6d4f1a6888cafd218cb97bd11de6a7553d9bc8f1 (patch)
tree7b48b6e97c4c73a4e0e9dce3456768526c46da65 /internal/fusefrontend_reverse/node_helpers.go
parent527609266386890fe1657c225c643ca448bcd71d (diff)
v2api/reverse: implement Read
Diffstat (limited to 'internal/fusefrontend_reverse/node_helpers.go')
-rw-r--r--internal/fusefrontend_reverse/node_helpers.go33
1 files changed, 29 insertions, 4 deletions
diff --git a/internal/fusefrontend_reverse/node_helpers.go b/internal/fusefrontend_reverse/node_helpers.go
index 7669a17..fd0abfc 100644
--- a/internal/fusefrontend_reverse/node_helpers.go
+++ b/internal/fusefrontend_reverse/node_helpers.go
@@ -10,6 +10,7 @@ import (
"github.com/hanwen/go-fuse/v2/fs"
"github.com/hanwen/go-fuse/v2/fuse"
+ "github.com/rfjakob/gocryptfs/internal/configfile"
"github.com/rfjakob/gocryptfs/internal/pathiv"
"github.com/rfjakob/gocryptfs/internal/syscallcompat"
)
@@ -115,8 +116,8 @@ func (n *Node) lookupLongnameName(ctx context.Context, nameFile string, out *fus
errno = fs.ToErrno(err)
return
}
- var vf *virtualFile
- vf, errno = n.newVirtualFile([]byte(cFullname), st, inoTagNameFile)
+ var vf *VirtualMemNode
+ vf, errno = n.newVirtualMemNode([]byte(cFullname), st, inoTagNameFile)
if errno != 0 {
return nil, errno
}
@@ -141,8 +142,8 @@ func (n *Node) lookupDiriv(ctx context.Context, out *fuse.EntryOut) (ch *fs.Inod
return
}
content := pathiv.Derive(n.Path(), pathiv.PurposeDirIV)
- var vf *virtualFile
- vf, errno = n.newVirtualFile(content, st, inoTagDirIV)
+ var vf *VirtualMemNode
+ vf, errno = n.newVirtualMemNode(content, st, inoTagDirIV)
if errno != 0 {
return nil, errno
}
@@ -153,6 +154,30 @@ func (n *Node) lookupDiriv(ctx context.Context, out *fuse.EntryOut) (ch *fs.Inod
return
}
+// lookupConf returns a new Inode for the gocryptfs.conf file
+func (n *Node) lookupConf(ctx context.Context, out *fuse.EntryOut) (ch *fs.Inode, errno syscall.Errno) {
+ rn := n.rootNode()
+ p := filepath.Join(rn.args.Cipherdir, configfile.ConfReverseName)
+ var st syscall.Stat_t
+ err := syscall.Stat(p, &st)
+ if err != nil {
+ errno = fs.ToErrno(err)
+ return
+ }
+ // Get unique inode number
+ rn.inoMap.TranslateStat(&st)
+ out.Attr.FromStat(&st)
+ // Create child node
+ id := fs.StableAttr{
+ Mode: uint32(st.Mode),
+ Gen: 1,
+ Ino: st.Ino,
+ }
+ node := &VirtualConfNode{path: p}
+ ch = n.NewInode(ctx, node, id)
+ return
+}
+
// readlink reads and encrypts a symlink. Used by Readlink, Getattr, Lookup.
func (n *Node) readlink(dirfd int, cName string, pName string) (out []byte, errno syscall.Errno) {
plainTarget, err := syscallcompat.Readlinkat(dirfd, pName)