Commit 53aac50a authored by Michael Stapelberg's avatar Michael Stapelberg

open /dev/fuse in blocking mode so the runtime does not use a poller

/dev/fuse is not pollable. Go ≥ 1.13 starts reporting this on Read().
parent b71377f2
......@@ -126,10 +126,14 @@ var mountflagopts = map[string]func(uintptr) uintptr{
var errFallback = errors.New("sentinel: fallback to fusermount(1)")
func directmount(dir string, cfg *MountConfig) (*os.File, error) {
dev, err := os.OpenFile("/dev/fuse", os.O_RDWR, 0644)
// We use syscall.Open + os.NewFile instead of os.OpenFile so that the file
// is opened in blocking mode. When opened in non-blocking mode, the Go
// runtime tries to use poll(2), which does not work with /dev/fuse.
fd, err := syscall.Open("/dev/fuse", syscall.O_RDWR, 0644)
if err != nil {
return nil, errFallback
}
dev := os.NewFile(uintptr(fd), "/dev/fuse")
// As per libfuse/fusermount.c:847: https://bit.ly/2SgtWYM#L847
data := fmt.Sprintf("fd=%d,rootmode=40000,user_id=%d,group_id=%d",
dev.Fd(), os.Getuid(), os.Getgid())
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment