| 1 |
|
| 2 |
|
| 3 |
package sysfs |
| 4 |
|
| 5 |
import ( |
| 6 |
"net" |
| 7 |
"syscall" |
| 8 |
|
| 9 |
experimentalsys "github.com/tetratelabs/wazero/experimental/sys" |
| 10 |
socketapi "github.com/tetratelabs/wazero/internal/sock" |
| 11 |
) |
| 12 |
|
| 13 |
|
| 14 |
const MSG_PEEK = 0x2 |
| 15 |
|
| 16 |
func newTCPListenerFile(tl *net.TCPListener) socketapi.TCPSock { |
| 17 |
return &unsupportedSockFile{} |
| 18 |
} |
| 19 |
|
| 20 |
type unsupportedSockFile struct { |
| 21 |
baseSockFile |
| 22 |
} |
| 23 |
|
| 24 |
|
| 25 |
func (f *unsupportedSockFile) Accept() (socketapi.TCPConn, experimentalsys.Errno) { |
| 26 |
return nil, experimentalsys.ENOSYS |
| 27 |
} |
| 28 |
|
| 29 |
func _pollSock(conn syscall.Conn, flag experimentalsys.Pflag, timeoutMillis int32) (bool, experimentalsys.Errno) { |
| 30 |
return false, experimentalsys.ENOTSUP |
| 31 |
} |
| 32 |
|
| 33 |
func setNonblockSocket(fd uintptr, enabled bool) experimentalsys.Errno { |
| 34 |
return experimentalsys.ENOTSUP |
| 35 |
} |
| 36 |
|
| 37 |
func readSocket(fd uintptr, buf []byte) (int, experimentalsys.Errno) { |
| 38 |
return -1, experimentalsys.ENOTSUP |
| 39 |
} |
| 40 |
|
| 41 |
func writeSocket(fd uintptr, buf []byte) (int, experimentalsys.Errno) { |
| 42 |
return -1, experimentalsys.ENOTSUP |
| 43 |
} |
| 44 |
|
| 45 |
func recvfrom(fd uintptr, buf []byte, flags int32) (n int, errno experimentalsys.Errno) { |
| 46 |
return -1, experimentalsys.ENOTSUP |
| 47 |
} |
| 48 |
|
| 49 |
|
| 50 |
|
| 51 |
|
| 52 |
|
| 53 |
|
| 54 |
|
| 55 |
func syscallConnControl(conn syscall.Conn, fn func(fd uintptr) (int, experimentalsys.Errno)) (n int, errno experimentalsys.Errno) { |
| 56 |
return -1, experimentalsys.ENOTSUP |
| 57 |
} |
| 58 |
|
| 59 |
|
| 60 |
func (f *tcpListenerFile) Accept() (socketapi.TCPConn, experimentalsys.Errno) { |
| 61 |
return nil, experimentalsys.ENOSYS |
| 62 |
} |
| 63 |
|
| 64 |
|
| 65 |
func (f *tcpConnFile) Shutdown(how int) experimentalsys.Errno { |
| 66 |
|
| 67 |
var err error |
| 68 |
switch how { |
| 69 |
case socketapi.SHUT_RD: |
| 70 |
err = f.tc.Close() |
| 71 |
case socketapi.SHUT_WR: |
| 72 |
err = f.tc.Close() |
| 73 |
case socketapi.SHUT_RDWR: |
| 74 |
return f.close() |
| 75 |
default: |
| 76 |
return experimentalsys.EINVAL |
| 77 |
} |
| 78 |
return experimentalsys.UnwrapOSError(err) |
| 79 |
} |