Documentation
¶
Index ¶
- Constants
- func BytePtrFromString(s string) (*byte, error)
- func Chdir(path string) (err error)
- func Chmod(path string, mode uint32) (err error)
- func Chown(path string, uid, gid int) (err error)
- func Clearenv() (err error)
- func Close(fd int) (err error)
- func Dup(fd int) (fd2 int, err error)
- func Environ() []string
- func Execve(pathname string, argv []string, envv []string) (err error)
- func Exit(code int)
- func Faccessat(dirfd int, path string, mode uint32, flags int) (err error)
- func Fdclosedir(dir uintptr) (err error)
- func Fdopendir(fd int) (dir uintptr, err error)
- func Fork() (err error)
- func Fstat(fd int, p *Stat_t) (err error)
- func Fsync(fd int) (err error)
- func Getegid() int
- func Getenv(key string) (value string, found bool)
- func Geteuid() int
- func Getgid() int
- func Getpagesize() int
- func Getpid() int
- func Getppid() int
- func Getuid() int
- func Getwd() (string, error)
- func Kill(pid int, sig Signal) (err error)
- func Link(oldname, newname string) (err error)
- func Lstat(path string, p *Stat_t) (err error)
- func Mkdir(path string, mode uint32) (err error)
- func Mmap(fd int, offset int64, length int, prot int, flags int) (data []byte, err error)
- func Mprotect(b []byte, prot int) (err error)
- func Munmap(b []byte) (err error)
- func Open(path string, flag int, mode uint32) (fd int, err error)
- func Pipe2(p []int, flags int) (err error)
- func Pread(fd int, p []byte, offset int64) (n int, err error)
- func Pwrite(fd int, p []byte, offset int64) (n int, err error)
- func Read(fd int, p []byte) (n int, err error)
- func Readlink(path string, p []byte) (n int, err error)
- func Rename(from, to string) (err error)
- func Rmdir(path string) (err error)
- func Seek(fd int, offset int64, whence int) (newoffset int64, err error)
- func Setenv(key, val string) (err error)
- func Setrlimit(resource int, rlim *Rlimit) error
- func Stat(path string, p *Stat_t) (err error)
- func Symlink(from, to string) (err error)
- func Truncate(path string, length int64) (err error)
- func Uname(buf *Utsname) (err error)
- func Unlink(path string) (err error)
- func Unsetenv(key string) (err error)
- func Wait4(pid int, wstatus *WaitStatus, options int, rusage uintptr) (wpid int, err error)
- func Write(fd int, p []byte) (n int, err error)
- type Conn
- type Dirent
- type Errno
- type RawConn
- type RawSockaddrInet4
- type RawSockaddrInet6
- type Rlimit
- type Signal
- type Stat_t
- type SysProcAttr
- type Timespec
- type Utsname
- type WaitStatus
- func (w WaitStatus) Continued() bool
- func (w WaitStatus) CoreDump() bool
- func (w WaitStatus) ExitStatus() int
- func (w WaitStatus) Exited() bool
- func (w WaitStatus) Signal() Signal
- func (w WaitStatus) Signaled() bool
- func (w WaitStatus) StopSignal() Signal
- func (w WaitStatus) Stopped() bool
- func (w WaitStatus) TrapCause() int
Constants ¶
const ( MSG_DONTWAIT = 0x40 AF_INET = 0x2 AF_INET6 = 0xa )
const ( Stdin = 0 Stdout = 1 Stderr = 2 )
const ( // ../../lib/wasi-libc/libc-bottom-half/headers/public/__header_fcntl.h O_NOFOLLOW = 0x01000000 O_RDONLY = 0x04000000 O_WRONLY = 0x10000000 O_RDWR = O_RDONLY | O_WRONLY O_CREAT = __WASI_OFLAGS_CREAT << 12 O_TRUNC = __WASI_OFLAGS_TRUNC << 12 O_EXCL = __WASI_OFLAGS_EXCL << 12 O_DIRECTORY = __WASI_OFLAGS_DIRECTORY << 12 O_APPEND = __WASI_FDFLAGS_APPEND O_DSYNC = __WASI_FDFLAGS_DSYNC O_NONBLOCK = __WASI_FDFLAGS_NONBLOCK O_RSYNC = __WASI_FDFLAGS_RSYNC O_SYNC = __WASI_FDFLAGS_SYNC O_CLOEXEC = 0 // ../../lib/wasi-libc/sysroot/include/sys/mman.h MAP_FILE = 0 MAP_SHARED = 0x01 MAP_PRIVATE = 0x02 MAP_ANON = 0x20 MAP_ANONYMOUS = MAP_ANON // ../../lib/wasi-libc/sysroot/include/sys/mman.h PROT_NONE = 0 PROT_READ = 1 PROT_WRITE = 2 PROT_EXEC = 4 // ../../lib/wasi-libc/expected/wasm32-wasi/predefined-macros.txt F_GETFL = 3 F_SETFL = 4 // ../../lib/wasi-libc/libc-top-half/musl/arch/generic/bits/ioctl.h TIOCSPGRP = 0x5410 )
const ( SYS_FCNTL SYS_FCNTL64 SYS_FSTATAT64 SYS_IOCTL SYS_OPENAT SYS_UNLINKAT PATH_MAX = 4096 )
These values are needed as a stub until Go supports WASI as a full target. The constant values don't have a meaning and don't correspond to anything real.
const ( S_IFBLK = 0x6000 S_IFCHR = 0x2000 S_IFDIR = 0x4000 S_IFIFO = 0x1000 S_IFLNK = 0xa000 S_IFMT = 0xf000 S_IFREG = 0x8000 S_IFSOCK = 0xc000 S_IREAD = 0x100 S_IRGRP = 0x20 S_IROTH = 0x4 S_IRUSR = 0x100 S_IRWXG = 0x38 S_IRWXO = 0x7 S_IRWXU = 0x1c0 S_ISGID = 0x400 S_ISUID = 0x800 S_ISVTX = 0x200 S_IWGRP = 0x10 S_IWOTH = 0x2 S_IWRITE = 0x80 S_IWUSR = 0x80 S_IXGRP = 0x8 S_IXOTH = 0x1 S_IXUSR = 0x40 )
https://github.com/WebAssembly/wasi-libc/blob/main/libc-top-half/musl/include/sys/stat.h
const ( DT_BLK = __WASI_FILETYPE_BLOCK_DEVICE DT_CHR = __WASI_FILETYPE_CHARACTER_DEVICE DT_DIR = __WASI_FILETYPE_DIRECTORY DT_FIFO = __WASI_FILETYPE_SOCKET_STREAM DT_LNK = __WASI_FILETYPE_SYMBOLIC_LINK DT_REG = __WASI_FILETYPE_REGULAR_FILE DT_UNKNOWN = __WASI_FILETYPE_UNKNOWN )
https://github.com/WebAssembly/wasi-libc/blob/main/libc-bottom-half/headers/public/__header_dirent.h
Variables ¶
This section is empty.
Functions ¶
func BytePtrFromString ¶ added in v0.35.0
BytePtrFromString returns a pointer to a NUL-terminated array of bytes containing the text of s. If s contains a NUL byte at any location, it returns (nil, EINVAL).
func Fdclosedir ¶ added in v0.35.0
func Getpagesize ¶ added in v0.24.0
func Getpagesize() int
TODO: should this return runtime.wasmPageSize?
Types ¶
type Conn ¶ added in v0.14.0
type Conn interface { // SyscallConn returns a raw network connection. SyscallConn() (RawConn, error) }
Conn is implemented by some types in the net and os packages to provide access to the underlying file descriptor or handle.
type Dirent ¶ added in v0.35.0
Dirent is returned by pointer from Readdir to iterate over directory entries.
The pointer is managed by wasi-libc and is only valid until the next call to Readdir or Fdclosedir.
https://github.com/WebAssembly/wasi-libc/blob/main/libc-bottom-half/headers/public/__struct_dirent.h
type Errno ¶
type Errno uintptr
An Errno is an unsigned number describing an error condition. It implements the error interface. The zero Errno is by convention a non-error, so code to convert from Errno to error should use:
err = nil if errno != 0 { err = errno }
const ( E2BIG Errno = 1 /* Argument list too long */ EACCES Errno = 2 /* Permission denied */ EADDRINUSE Errno = 3 /* Address already in use */ EADDRNOTAVAIL Errno = 4 /* Address not available */ EAFNOSUPPORT Errno = 5 /* Address family not supported by protocol family */ EAGAIN Errno = 6 /* Try again */ EWOULDBLOCK Errno = EAGAIN /* Operation would block */ EALREADY Errno = 7 /* Socket already connected */ EBADF Errno = 8 /* Bad file number */ EBADMSG Errno = 9 /* Trying to read unreadable message */ EBUSY Errno = 10 /* Device or resource busy */ ECANCELED Errno = 11 /* Operation canceled. */ ECHILD Errno = 12 /* No child processes */ ECONNABORTED Errno = 13 /* Connection aborted */ ECONNREFUSED Errno = 14 /* Connection refused */ ECONNRESET Errno = 15 /* Connection reset by peer */ EDEADLK Errno = 16 /* Deadlock condition */ EDESTADDRREQ Errno = 17 /* Destination address required */ EDOM Errno = 18 /* Math arg out of domain of func */ EDQUOT Errno = 19 /* Quota exceeded */ EEXIST Errno = 20 /* File exists */ EFAULT Errno = 21 /* Bad address */ EFBIG Errno = 22 /* File too large */ EHOSTUNREACH Errno = 23 /* Host is unreachable */ EIDRM Errno = 24 /* Identifier removed */ EILSEQ Errno = 25 EINPROGRESS Errno = 26 /* Connection already in progress */ EINTR Errno = 27 /* Interrupted system call */ EINVAL Errno = 28 /* Invalid argument */ EIO Errno = 29 /* I/O error */ EISCONN Errno = 30 /* Socket is already connected */ EISDIR Errno = 31 /* Is a directory */ ELOOP Errno = 32 /* Too many symbolic links */ EMFILE Errno = 33 /* Too many open files */ EMLINK Errno = 34 /* Too many links */ EMSGSIZE Errno = 35 /* Message too long */ EMULTIHOP Errno = 36 /* Multihop attempted */ ENAMETOOLONG Errno = 37 /* File name too long */ ENETDOWN Errno = 38 /* Network interface is not configured */ ENETRESET Errno = 39 ENETUNREACH Errno = 40 /* Network is unreachable */ ENFILE Errno = 41 /* File table overflow */ ENOBUFS Errno = 42 /* No buffer space available */ ENODEV Errno = 43 /* No such device */ ENOENT Errno = 44 /* No such file or directory */ ENOEXEC Errno = 45 /* Exec format error */ ENOLCK Errno = 46 /* No record locks available */ ENOLINK Errno = 47 /* The link has been severed */ ENOMEM Errno = 48 /* Out of memory */ ENOMSG Errno = 49 /* No message of desired type */ ENOPROTOOPT Errno = 50 /* Protocol not available */ ENOSPC Errno = 51 /* No space left on device */ ENOSYS Errno = 52 /* Function not implemented */ ENOTCONN Errno = 53 /* Socket is not connected */ ENOTDIR Errno = 54 /* Not a directory */ ENOTEMPTY Errno = 55 /* Directory not empty */ ENOTRECOVERABLE Errno = 56 /* State not recoverable */ ENOTSOCK Errno = 57 /* Socket operation on non-socket */ ESOCKTNOSUPPORT Errno = 58 /* Socket type not supported */ EOPNOTSUPP Errno = 58 /* Operation not supported on transport endpoint */ ENOTSUP Errno = EOPNOTSUPP /* Not supported */ ENOTTY Errno = 59 /* Not a typewriter */ ENXIO Errno = 60 /* No such device or address */ EOVERFLOW Errno = 61 /* Value too large for defined data type */ EPERM Errno = 63 /* Operation not permitted */ EPIPE Errno = 64 /* Broken pipe */ EPROTO Errno = 65 /* Protocol error */ EPROTONOSUPPORT Errno = 66 /* Unknown protocol */ EPROTOTYPE Errno = 67 /* Protocol wrong type for socket */ ERANGE Errno = 68 /* Math result not representable */ EROFS Errno = 69 /* Read-only file system */ ESPIPE Errno = 70 /* Illegal seek */ ESRCH Errno = 71 /* No such process */ ESTALE Errno = 72 ETIMEDOUT Errno = 73 /* Connection timed out */ ETXTBSY Errno = 74 /* Text file busy */ EXDEV Errno = 75 /* Cross-device link */ ENOTCAPABLE Errno = 76 /* Extension: Capabilities insufficient. */ EWASIERROR Errno = 255 /* Unknown WASI error */ )
https://github.com/WebAssembly/wasi-libc/blob/main/libc-bottom-half/headers/public/__errno.h
type RawConn ¶ added in v0.14.0
type RawConn interface { // Control invokes f on the underlying connection's file // descriptor or handle. // The file descriptor fd is guaranteed to remain valid while // f executes but not after f returns. Control(f func(fd uintptr)) error // Read invokes f on the underlying connection's file // descriptor or handle; f is expected to try to read from the // file descriptor. // If f returns true, Read returns. Otherwise Read blocks // waiting for the connection to be ready for reading and // tries again repeatedly. // The file descriptor is guaranteed to remain valid while f // executes but not after f returns. Read(f func(fd uintptr) (done bool)) error // Write is like Read but for writing. Write(f func(fd uintptr) (done bool)) error }
A RawConn is a raw network connection.
type RawSockaddrInet4 ¶ added in v0.27.0
type RawSockaddrInet4 struct { }
type RawSockaddrInet6 ¶ added in v0.27.0
type RawSockaddrInet6 struct { }
type Stat_t ¶ added in v0.35.0
type Stat_t struct { Dev uint64 Ino uint64 Nlink uint64 Mode uint32 Uid uint32 Gid uint32 Pad_cgo_0 [4]byte Rdev uint64 Size int64 Blksize int32 Blocks int64 Atim Timespec Mtim Timespec Ctim Timespec Qspare [3]int64 }
https://github.com/WebAssembly/wasi-libc/blob/main/libc-bottom-half/headers/public/__struct_stat.h https://github.com/WebAssembly/wasi-libc/blob/main/libc-bottom-half/headers/public/__typedef_ino_t.h etc.
type SysProcAttr ¶ added in v0.20.0
type SysProcAttr struct{}
type Timespec ¶ added in v0.35.0
TODO(ydnar): remove Timespec for WASI Preview 2 (seconds is uint64).
type WaitStatus ¶ added in v0.20.0
type WaitStatus uint32
TODO
func (WaitStatus) Continued ¶ added in v0.20.0
func (w WaitStatus) Continued() bool
func (WaitStatus) CoreDump ¶ added in v0.20.0
func (w WaitStatus) CoreDump() bool
func (WaitStatus) ExitStatus ¶ added in v0.20.0
func (w WaitStatus) ExitStatus() int
func (WaitStatus) Exited ¶ added in v0.20.0
func (w WaitStatus) Exited() bool
func (WaitStatus) Signal ¶ added in v0.20.0
func (w WaitStatus) Signal() Signal
func (WaitStatus) Signaled ¶ added in v0.20.0
func (w WaitStatus) Signaled() bool
func (WaitStatus) StopSignal ¶ added in v0.20.0
func (w WaitStatus) StopSignal() Signal
func (WaitStatus) Stopped ¶ added in v0.20.0
func (w WaitStatus) Stopped() bool
func (WaitStatus) TrapCause ¶ added in v0.20.0
func (w WaitStatus) TrapCause() int