github.com/tetratelabs/wazero@v1.2.1/internal/sysfs/file_unix.go (about) 1 //go:build unix || darwin || linux 2 3 package sysfs 4 5 import ( 6 "syscall" 7 8 "github.com/tetratelabs/wazero/internal/platform" 9 ) 10 11 const NonBlockingFileIoSupported = true 12 13 // readFd exposes syscall.Read. 14 func readFd(fd uintptr, buf []byte) (int, syscall.Errno) { 15 if len(buf) == 0 { 16 return 0, 0 // Short-circuit 0-len reads. 17 } 18 n, err := syscall.Read(int(fd), buf) 19 errno := platform.UnwrapOSError(err) 20 return n, errno 21 }