aboutsummaryrefslogtreecommitdiff
path: root/internal/fusefrontend_reverse/node.go
diff options
context:
space:
mode:
authorJakob Unterwurzacher2020-08-02 19:33:12 +0200
committerJakob Unterwurzacher2020-08-02 19:33:12 +0200
commit84ed139cd2cede9b773fe7892a0bc2515fc1f00f (patch)
tree9886e8fdce9450fd6232e532d5e8e939871dd2fc /internal/fusefrontend_reverse/node.go
parent4674bac8381838718f0defba0f2e0d9eba2a41a3 (diff)
v2api/reverse: implement Lookup for longname
Diffstat (limited to 'internal/fusefrontend_reverse/node.go')
-rw-r--r--internal/fusefrontend_reverse/node.go46
1 files changed, 10 insertions, 36 deletions
diff --git a/internal/fusefrontend_reverse/node.go b/internal/fusefrontend_reverse/node.go
index 0b2df12..713beee 100644
--- a/internal/fusefrontend_reverse/node.go
+++ b/internal/fusefrontend_reverse/node.go
@@ -10,7 +10,6 @@ import (
"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"
)
@@ -25,9 +24,16 @@ func (n *Node) Lookup(ctx context.Context, name string, out *fuse.EntryOut) (ch
dirfd := int(-1)
pName := ""
t := n.lookupFileType(name)
- // gocryptfs.conf
- if t == typeConfig {
+ if t == typeDiriv {
+ // gocryptfs.diriv
+ return n.lookupDiriv(ctx, out)
+ } else if t == typeName {
+ // gocryptfs.longname.*.name
+ return n.lookupLongnameName(ctx, name, out)
+ } else if t == typeConfig {
+ // gocryptfs.conf
var err error
+ pName = configfile.ConfReverseName
rn := n.rootNode()
dirfd, err = syscallcompat.OpenDirNofollow(rn.args.Cipherdir, "")
if err != nil {
@@ -35,34 +41,6 @@ func (n *Node) Lookup(ctx context.Context, name string, out *fuse.EntryOut) (ch
return
}
defer syscall.Close(dirfd)
- pName = configfile.ConfReverseName
- } else if t == typeDiriv {
- // gocryptfs.diriv
- dirfd, pName, errno = n.prepareAtSyscall("")
- if errno != 0 {
- return
- }
- defer syscall.Close(dirfd)
- st, err := syscallcompat.Fstatat2(dirfd, pName, unix.AT_SYMLINK_NOFOLLOW)
- if err != nil {
- errno = fs.ToErrno(err)
- return
- }
- content := pathiv.Derive(n.Path(), pathiv.PurposeDirIV)
- var vf *virtualFile
- vf, errno = n.newVirtualFile(content, st, inoTagDirIV)
- if errno != 0 {
- return nil, errno
- }
- out.Attr = vf.attr
- // Create child node
- id := fs.StableAttr{Mode: uint32(vf.attr.Mode), Gen: 1, Ino: vf.attr.Ino}
- ch = n.NewInode(ctx, vf, id)
- return
- } else if t == typeName {
- // gocryptfs.longname.*.name
-
- // TODO
} else if t == typeReal {
// real file
dirfd, pName, errno = n.prepareAtSyscall(name)
@@ -71,21 +49,17 @@ func (n *Node) Lookup(ctx context.Context, name string, out *fuse.EntryOut) (ch
}
defer syscall.Close(dirfd)
}
-
// Get device number and inode number into `st`
st, err := syscallcompat.Fstatat2(dirfd, pName, unix.AT_SYMLINK_NOFOLLOW)
if err != nil {
return nil, fs.ToErrno(err)
}
-
// Create new inode and fill `out`
ch = n.newChild(ctx, st, out)
-
+ // Translate ciphertext size in `out.Attr.Size` to plaintext size
if t == typeReal {
- // Translate ciphertext size in `out.Attr.Size` to plaintext size
n.translateSize(dirfd, pName, &out.Attr)
}
-
return ch, 0
}