aboutsummaryrefslogtreecommitdiff
path: root/internal/fusefrontend_reverse/node.go
diff options
context:
space:
mode:
authorJakob Unterwurzacher2020-08-15 17:31:25 +0200
committerJakob Unterwurzacher2020-08-15 17:31:45 +0200
commit94e8fc12ea5756a130e7ac9ed67ddd519b5f3a22 (patch)
tree44186807f71db8c555af23f8969f8f1456c955f9 /internal/fusefrontend_reverse/node.go
parent15b0b4a5fd268b421ddc347e4417b2538a540922 (diff)
v2api/reverse: finish -exclude
Tests pass now.
Diffstat (limited to 'internal/fusefrontend_reverse/node.go')
-rw-r--r--internal/fusefrontend_reverse/node.go33
1 files changed, 16 insertions, 17 deletions
diff --git a/internal/fusefrontend_reverse/node.go b/internal/fusefrontend_reverse/node.go
index deaf953..de1ee49 100644
--- a/internal/fusefrontend_reverse/node.go
+++ b/internal/fusefrontend_reverse/node.go
@@ -26,8 +26,7 @@ type Node struct {
// Lookup - FUSE call for discovering a file.
func (n *Node) Lookup(ctx context.Context, cName string, out *fuse.EntryOut) (ch *fs.Inode, errno syscall.Errno) {
- dirfd := int(-1)
- pName := ""
+ var d *dirfdPlus
t := n.lookupFileType(cName)
if t == typeDiriv {
// gocryptfs.diriv
@@ -40,14 +39,15 @@ func (n *Node) Lookup(ctx context.Context, cName string, out *fuse.EntryOut) (ch
return n.lookupConf(ctx, out)
} else if t == typeReal {
// real file
- dirfd, pName, errno = n.prepareAtSyscall(cName)
+ d, errno = n.prepareAtSyscall(cName)
+ //fmt.Printf("Lookup: prepareAtSyscall -> d=%#v, errno=%d\n", d, errno)
if errno != 0 {
return
}
- defer syscall.Close(dirfd)
+ defer syscall.Close(d.dirfd)
}
// Get device number and inode number into `st`
- st, err := syscallcompat.Fstatat2(dirfd, pName, unix.AT_SYMLINK_NOFOLLOW)
+ st, err := syscallcompat.Fstatat2(d.dirfd, d.pName, unix.AT_SYMLINK_NOFOLLOW)
if err != nil {
return nil, fs.ToErrno(err)
}
@@ -55,7 +55,7 @@ func (n *Node) Lookup(ctx context.Context, cName string, out *fuse.EntryOut) (ch
ch = n.newChild(ctx, st, out)
// Translate ciphertext size in `out.Attr.Size` to plaintext size
if t == typeReal {
- n.translateSize(dirfd, cName, pName, &out.Attr)
+ n.translateSize(d.dirfd, cName, d.pName, &out.Attr)
}
return ch, 0
}
@@ -69,13 +69,13 @@ func (n *Node) Getattr(ctx context.Context, f fs.FileHandle, out *fuse.AttrOut)
return f.(fs.FileGetattrer).Getattr(ctx, out)
}
- dirfd, pName, errno := n.prepareAtSyscall("")
+ d, errno := n.prepareAtSyscall("")
if errno != 0 {
return
}
- defer syscall.Close(dirfd)
+ defer syscall.Close(d.dirfd)
- st, err := syscallcompat.Fstatat2(dirfd, pName, unix.AT_SYMLINK_NOFOLLOW)
+ st, err := syscallcompat.Fstatat2(d.dirfd, d.pName, unix.AT_SYMLINK_NOFOLLOW)
if err != nil {
return fs.ToErrno(err)
}
@@ -87,7 +87,7 @@ func (n *Node) Getattr(ctx context.Context, f fs.FileHandle, out *fuse.AttrOut)
// Translate ciphertext size in `out.Attr.Size` to plaintext size
cName := filepath.Base(n.Path())
- n.translateSize(dirfd, cName, pName, &out.Attr)
+ n.translateSize(d.dirfd, cName, d.pName, &out.Attr)
if rn.args.ForceOwner != nil {
out.Owner = *rn.args.ForceOwner
@@ -99,27 +99,26 @@ func (n *Node) Getattr(ctx context.Context, f fs.FileHandle, out *fuse.AttrOut)
//
// Symlink-safe through openBackingDir() + Readlinkat().
func (n *Node) Readlink(ctx context.Context) (out []byte, errno syscall.Errno) {
- dirfd, pName, errno := n.prepareAtSyscall("")
+ d, errno := n.prepareAtSyscall("")
if errno != 0 {
return
}
- defer syscall.Close(dirfd)
+ defer syscall.Close(d.dirfd)
- cName := filepath.Base(n.Path())
- return n.readlink(dirfd, cName, pName)
+ return n.readlink(d.dirfd, d.cName, d.pName)
}
// Open - FUSE call. Open already-existing file.
//
// Symlink-safe through Openat().
func (n *Node) Open(ctx context.Context, flags uint32) (fh fs.FileHandle, fuseFlags uint32, errno syscall.Errno) {
- dirfd, pName, errno := n.prepareAtSyscall("")
+ d, errno := n.prepareAtSyscall("")
if errno != 0 {
return
}
- defer syscall.Close(dirfd)
+ defer syscall.Close(d.dirfd)
- fd, err := syscallcompat.Openat(dirfd, pName, syscall.O_RDONLY|syscall.O_NOFOLLOW, 0)
+ fd, err := syscallcompat.Openat(d.dirfd, d.pName, syscall.O_RDONLY|syscall.O_NOFOLLOW, 0)
if err != nil {
errno = fs.ToErrno(err)
return