aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJakob Unterwurzacher2020-07-05 19:33:50 +0200
committerJakob Unterwurzacher2020-07-05 19:34:30 +0200
commitc22e78ee41f4c5a91429bb83c6be3e60b4c2a20f (patch)
treed4877bd95f2974d45d708245e80946a39bea6fd0
parent1f4e554168a25151e0c21375921376fd2b6c53de (diff)
v2api: implement Opendir
-rw-r--r--internal/fusefrontend/node_api_check.go1
-rw-r--r--internal/fusefrontend/node_dir_ops.go17
2 files changed, 18 insertions, 0 deletions
diff --git a/internal/fusefrontend/node_api_check.go b/internal/fusefrontend/node_api_check.go
index 9b5746a..d9facb7 100644
--- a/internal/fusefrontend/node_api_check.go
+++ b/internal/fusefrontend/node_api_check.go
@@ -14,3 +14,4 @@ var _ = (fs.NodeRmdirer)((*Node)(nil))
var _ = (fs.NodeUnlinker)((*Node)(nil))
var _ = (fs.NodeReadlinker)((*Node)(nil))
var _ = (fs.NodeOpener)((*Node)(nil))
+var _ = (fs.NodeOpendirer)((*Node)(nil))
diff --git a/internal/fusefrontend/node_dir_ops.go b/internal/fusefrontend/node_dir_ops.go
index 8aa79ba..32e5e86 100644
--- a/internal/fusefrontend/node_dir_ops.go
+++ b/internal/fusefrontend/node_dir_ops.go
@@ -348,3 +348,20 @@ retry:
}
return 0
}
+
+// Opendir is a FUSE call to check if the directory can be opened.
+func (n *Node) Opendir(ctx context.Context) (errno syscall.Errno) {
+ dirfd, cName, errno := n.prepareAtSyscall("")
+ if errno != 0 {
+ return
+ }
+ defer syscall.Close(dirfd)
+
+ // Open backing directory
+ fd, err := syscallcompat.Openat(dirfd, cName, syscall.O_RDONLY|syscall.O_DIRECTORY, 0)
+ if err != nil {
+ return fs.ToErrno(err)
+ }
+ syscall.Close(fd)
+ return 0
+}