github.com/hanwen/go-fuse@v1.0.0/fuse/poll_darwin.go (about) 1 package fuse 2 3 import ( 4 "path/filepath" 5 "syscall" 6 "unsafe" 7 ) 8 9 type pollFd struct { 10 Fd int32 11 Events int16 12 Revents int16 13 } 14 15 func sysPoll(fds []pollFd, timeout int) (n int, err error) { 16 r0, _, e1 := syscall.Syscall(syscall.SYS_POLL, uintptr(unsafe.Pointer(&fds[0])), 17 uintptr(len(fds)), uintptr(timeout)) 18 n = int(r0) 19 if e1 != 0 { 20 err = syscall.Errno(e1) 21 } 22 return n, err 23 } 24 25 func pollHack(mountPoint string) error { 26 const ( 27 POLLIN = 0x1 28 POLLPRI = 0x2 29 POLLOUT = 0x4 30 POLLRDHUP = 0x2000 31 POLLERR = 0x8 32 POLLHUP = 0x10 33 ) 34 35 fd, err := syscall.Open(filepath.Join(mountPoint, pollHackName), syscall.O_CREAT|syscall.O_TRUNC|syscall.O_RDWR, 0644) 36 if err != nil { 37 return err 38 } 39 pollData := []pollFd{{ 40 Fd: int32(fd), 41 Events: POLLIN | POLLPRI | POLLOUT, 42 }} 43 44 // Trigger _OP_POLL, so we can say ENOSYS. We don't care about 45 // the return value. 46 sysPoll(pollData, 0) 47 syscall.Close(fd) 48 return nil 49 }