v2api: implement Opendir

This commit is contained in:
Jakob Unterwurzacher 2020-07-05 19:33:50 +02:00
parent 1f4e554168
commit c22e78ee41
2 changed files with 18 additions and 0 deletions

View File

@ -14,3 +14,4 @@ var _ = (fs.NodeRmdirer)((*Node)(nil))
var _ = (fs.NodeUnlinker)((*Node)(nil)) var _ = (fs.NodeUnlinker)((*Node)(nil))
var _ = (fs.NodeReadlinker)((*Node)(nil)) var _ = (fs.NodeReadlinker)((*Node)(nil))
var _ = (fs.NodeOpener)((*Node)(nil)) var _ = (fs.NodeOpener)((*Node)(nil))
var _ = (fs.NodeOpendirer)((*Node)(nil))

View File

@ -348,3 +348,20 @@ retry:
} }
return 0 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
}