From 6d4f1a6888cafd218cb97bd11de6a7553d9bc8f1 Mon Sep 17 00:00:00 2001 From: Jakob Unterwurzacher Date: Sun, 9 Aug 2020 22:11:46 +0200 Subject: v2api/reverse: implement Read --- internal/fusefrontend_reverse/node_helpers.go | 33 +++++++++++++++++++++++---- 1 file changed, 29 insertions(+), 4 deletions(-) (limited to 'internal/fusefrontend_reverse/node_helpers.go') 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) -- cgit v1.2.3