syscall

package
v0.35.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Dec 20, 2024 License: BSD-3-Clause Imports: 2 Imported by: 0

Documentation

Index

Constants

View Source
const (
	MSG_DONTWAIT = 0x40
	AF_INET      = 0x2
	AF_INET6     = 0xa
)
View Source
const (
	Stdin  = 0
	Stdout = 1
	Stderr = 2
)
View Source
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
)
View Source
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.

View Source
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

View Source
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

func BytePtrFromString(s string) (*byte, error)

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 Chdir added in v0.35.0

func Chdir(path string) (err error)

func Chmod added in v0.35.0

func Chmod(path string, mode uint32) (err error)

func Chown added in v0.35.0

func Chown(path string, uid, gid int) (err error)

func Clearenv added in v0.22.0

func Clearenv() (err error)

func Close added in v0.20.0

func Close(fd int) (err error)

func Dup added in v0.35.0

func Dup(fd int) (fd2 int, err error)

func Environ added in v0.22.0

func Environ() []string

func Execve added in v0.35.0

func Execve(pathname string, argv []string, envv []string) (err error)

func Exit added in v0.7.0

func Exit(code int)

func Faccessat added in v0.35.0

func Faccessat(dirfd int, path string, mode uint32, flags int) (err error)

func Fdclosedir added in v0.35.0

func Fdclosedir(dir uintptr) (err error)

func Fdopendir added in v0.35.0

func Fdopendir(fd int) (dir uintptr, err error)

func Fork added in v0.35.0

func Fork() (err error)

func Fstat added in v0.35.0

func Fstat(fd int, p *Stat_t) (err error)

func Fsync added in v0.35.0

func Fsync(fd int) (err error)

func Getegid added in v0.19.0

func Getegid() int

func Getenv added in v0.20.0

func Getenv(key string) (value string, found bool)

func Geteuid added in v0.19.0

func Geteuid() int

func Getgid added in v0.19.0

func Getgid() int

func Getpagesize added in v0.24.0

func Getpagesize() int

TODO: should this return runtime.wasmPageSize?

func Getpid added in v0.19.0

func Getpid() int

func Getppid added in v0.19.0

func Getppid() int

func Getuid added in v0.19.0

func Getuid() int

func Getwd added in v0.21.0

func Getwd() (string, error)

func Kill added in v0.20.0

func Kill(pid int, sig Signal) (err error)
func Link(oldname, newname string) (err error)

func Lstat added in v0.35.0

func Lstat(path string, p *Stat_t) (err error)

func Mkdir added in v0.35.0

func Mkdir(path string, mode uint32) (err error)

func Mmap added in v0.23.0

func Mmap(fd int, offset int64, length int, prot int, flags int) (data []byte, err error)

func Mprotect added in v0.35.0

func Mprotect(b []byte, prot int) (err error)

func Munmap added in v0.23.0

func Munmap(b []byte) (err error)

func Open added in v0.20.0

func Open(path string, flag int, mode uint32) (fd int, err error)

func Pipe2 added in v0.23.0

func Pipe2(p []int, flags int) (err error)

func Pread added in v0.35.0

func Pread(fd int, p []byte, offset int64) (n int, err error)

func Pwrite added in v0.35.0

func Pwrite(fd int, p []byte, offset int64) (n int, err error)

func Read added in v0.20.0

func Read(fd int, p []byte) (n int, err error)
func Readlink(path string, p []byte) (n int, err error)

func Rename added in v0.35.0

func Rename(from, to string) (err error)

func Rmdir added in v0.35.0

func Rmdir(path string) (err error)

func Seek added in v0.20.0

func Seek(fd int, offset int64, whence int) (newoffset int64, err error)

func Setenv added in v0.22.0

func Setenv(key, val string) (err error)

func Setrlimit added in v0.31.0

func Setrlimit(resource int, rlim *Rlimit) error

func Stat added in v0.35.0

func Stat(path string, p *Stat_t) (err error)
func Symlink(from, to string) (err error)

func Truncate added in v0.35.0

func Truncate(path string, length int64) (err error)

func Uname added in v0.35.0

func Uname(buf *Utsname) (err error)

Stub Utsname, needed because WASI pretends to be linux/arm.

func Unlink(path string) (err error)

func Unsetenv added in v0.22.0

func Unsetenv(key string) (err error)

func Wait4 added in v0.20.0

func Wait4(pid int, wstatus *WaitStatus, options int, rusage uintptr) (wpid int, err error)

since rusage is quite a big struct and we stub it out anyway no need to define it here

func Write added in v0.35.0

func Write(fd int, p []byte) (n int, err error)

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

type Dirent struct {
	Ino  uint64
	Type uint8
}

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

func Readdir added in v0.35.0

func Readdir(dir uintptr) (dirent *Dirent, err error)

func (*Dirent) Name added in v0.35.0

func (dirent *Dirent) Name() []byte

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

func Syscall added in v0.35.0

func Syscall(trap, a1, a2, a3 uintptr) (r1, r2 uintptr, err Errno)

This is a stub, it is not functional.

func Syscall6 added in v0.35.0

func Syscall6(trap, a1, a2, a3, a4, a5, a6 uintptr) (r1, r2 uintptr, err Errno)

This is a stub, it is not functional.

func (Errno) Error

func (e Errno) Error() string

func (Errno) Is added in v0.18.0

func (e Errno) Is(target error) bool

func (Errno) Temporary

func (e Errno) Temporary() bool

func (Errno) Timeout

func (e Errno) Timeout() bool

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 Rlimit added in v0.31.0

type Rlimit struct {
	Cur uint64
	Max uint64
}

type Signal added in v0.20.0

type Signal int
const (
	SIGINT  Signal = 2
	SIGQUIT Signal = 3
	SIGILL  Signal = 4
	SIGTRAP Signal = 5
	SIGABRT Signal = 6
	SIGBUS  Signal = 7
	SIGFPE  Signal = 8
	SIGKILL Signal = 9
	SIGSEGV Signal = 11
	SIGPIPE Signal = 13
	SIGTERM Signal = 15
	SIGCHLD Signal = 17
)

func (Signal) Signal added in v0.23.0

func (s Signal) Signal()

func (Signal) String added in v0.23.0

func (s Signal) String() string

type SysProcAttr added in v0.20.0

type SysProcAttr struct{}

type Timespec added in v0.35.0

type Timespec struct {
	Sec  int32
	Nsec int64
}

TODO(ydnar): remove Timespec for WASI Preview 2 (seconds is uint64).

https://github.com/WebAssembly/wasi-libc/blob/main/libc-bottom-half/headers/public/__struct_timespec.h

func (*Timespec) Unix added in v0.35.0

func (ts *Timespec) Unix() (sec int64, nsec int64)

Unix returns the time stored in ts as seconds plus nanoseconds.

type Utsname added in v0.35.0

type Utsname struct {
	Sysname    [65]int8
	Nodename   [65]int8
	Release    [65]int8
	Version    [65]int8
	Machine    [65]int8
	Domainname [65]int8
}

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

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL