wasi

package
v0.0.0-...-3940e3f Latest Latest
Warning

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

Go to latest
Published: Dec 18, 2021 License: BSD-3-Clause Imports: 18 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// The application has no advice to give on its behavior with respect to the specified data.
	AdviceNormal = wasiAdviceNormal
	// The application expects to access the specified data sequentially from lower offsets to higher offsets.
	AdviceSequential = wasiAdviceSequential
	// The application expects to access the specified data in a random order.
	AdviceRandom = wasiAdviceRandom
	// The application expects to access the specified data in the near future.
	AdviceWillneed = wasiAdviceWillneed
	// The application expects that it will not access the specified data in the near future.
	AdviceDontneed = wasiAdviceDontneed
	// The application expects to access the specified data once and then not reuse it thereafter.
	AdviceNoreuse = wasiAdviceNoreuse

	// Append mode: Data written to the file is always appended to the file's end.
	F_Append = wasiFdflagsAppend
	// Write according to synchronized I/O data integrity completion. Only the data stored in the file is synchronized.
	F_Dsync = wasiFdflagsDsync
	// Non-blocking mode.
	F_Nonblock = wasiFdflagsNonblock
	// Synchronized read I/O operations.
	F_Rsync = wasiFdflagsRsync
	// Write according to synchronized I/O file integrity completion. In
	// addition to synchronizing the data stored in the file, the implementation
	// may also synchronously update the file's metadata.
	F_Sync = wasiFdflagsSync

	// Create file if it does not exist.
	O_Create = wasiOflagsCreat
	// Fail if not a directory.
	O_Directory = wasiOflagsDirectory
	// Fail if file already exists.
	O_Excl = wasiOflagsExcl
	// Truncate file to size 0.
	O_Trunc = wasiOflagsTrunc

	// The given timeout has expired or deadline has been reached.
	SubscriptionTimer = 0
	// The given file has data available for reading.
	SubscriptionRead = 1
	// The given file has data available for writing.
	SubscriptionWrite = 2

	// The peer of this socket has closed or disconnected.
	EventHangup = wasiEventrwflagsFdReadwriteHangup

	// ErrnoIO indicates that an I/O error occurred during Poll.
	ErrnoIO = wasiErrnoIo
)
View Source
const (
	FileRights      = RightsFdAdvise | RightsFdAllocate | RightsFdDatasync | RightsFdFdstatSetFlags | RightsFdFilestatGet | RightsFdFilestatSetSize | RightsFdFilestatSetTimes | RightsFdRead | RightsFdSeek | RightsFdSync | RightsFdTell | RightsFdWrite | RightsPollFdReadwrite | RightsSockShutdown
	DirectoryRights = RightsFdReaddir | RightsPathCreateDirectory | RightsPathCreateFile | RightsPathFilestatGet | RightsPathFilestatSetSize | RightsPathFilestatSetTimes | RightsPathLinkSource | RightsPathLinkTarget | RightsPathOpen | RightsPathReadlink | RightsPathRemoveDirectory | RightsPathRenameSource | RightsPathRenameTarget | RightsPathSymlink | RightsPathUnlinkFile
	AllRights       = FileRights | DirectoryRights

	ReadOnlyRights = RightsFdRead | RightsFdSeek | RightsFdTell | RightsFdAdvise | RightsPathOpen | RightsFdReaddir | RightsPathReadlink | RightsPathFilestatGet | RightsFdFilestatGet | RightsPollFdReadwrite

	// The right to invoke `fd_datasync`.
	// If `path_open` is set, includes the right to invoke
	// `path_open` with `fdflags::dsync`.
	RightsFdDatasync = 1 << 0

	// The right to invoke `fd_read` and `sock_recv`.
	// If `rights::fd_seek` is set, includes the right to invoke `fd_pread`.
	RightsFdRead = 1 << 1

	// The right to invoke `fd_seek`. This flag implies `rights::fd_tell`.
	RightsFdSeek = 1 << 2

	// The right to invoke `fd_fdstat_set_flags`.
	RightsFdFdstatSetFlags = 1 << 3

	// The right to invoke `fd_sync`.
	// If `path_open` is set, includes the right to invoke
	// `path_open` with `fdflags::rsync` and `fdflags::dsync`.
	RightsFdSync = 1 << 4

	// The right to invoke `fd_seek` in such a way that the file offset
	// remains unaltered (i.e., `whence::cur` with offset zero), or to
	// invoke `fd_tell`.
	RightsFdTell = 1 << 5

	// The right to invoke `fd_write` and `sock_send`.
	// If `rights::fd_seek` is set, includes the right to invoke `fd_pwrite`.
	RightsFdWrite = 1 << 6

	// The right to invoke `fd_advise`.
	RightsFdAdvise = 1 << 7

	// The right to invoke `fd_allocate`.
	RightsFdAllocate = 1 << 8

	// The right to invoke `path_create_directory`.
	RightsPathCreateDirectory = 1 << 9

	// If `path_open` is set, the right to invoke `path_open` with `oflags::creat`.
	RightsPathCreateFile = 1 << 10

	// The right to invoke `path_link` with the file descriptor as the
	// source directory.
	RightsPathLinkSource = 1 << 11

	// The right to invoke `path_link` with the file descriptor as the
	// target directory.
	RightsPathLinkTarget = 1 << 12

	// The right to invoke `path_open`.
	RightsPathOpen = 1 << 13

	// The right to invoke `fd_readdir`.
	RightsFdReaddir = 1 << 14

	// The right to invoke `path_readlink`.
	RightsPathReadlink = 1 << 15

	// The right to invoke `path_rename` with the file descriptor as the source directory.
	RightsPathRenameSource = 1 << 16

	// The right to invoke `path_rename` with the file descriptor as the target directory.
	RightsPathRenameTarget = 1 << 17

	// The right to invoke `path_filestat_get`.
	RightsPathFilestatGet = 1 << 18

	// The right to change a file's size (there is no `path_filestat_set_size`).
	// If `path_open` is set, includes the right to invoke `path_open` with `oflags::trunc`.
	RightsPathFilestatSetSize = 1 << 19

	// The right to invoke `path_filestat_set_times`.
	RightsPathFilestatSetTimes = 1 << 20

	// The right to invoke `fd_filestat_get`.
	RightsFdFilestatGet = 1 << 21

	// The right to invoke `fd_filestat_set_size`.
	RightsFdFilestatSetSize = 1 << 22

	// The right to invoke `fd_filestat_set_times`.
	RightsFdFilestatSetTimes = 1 << 23

	// The right to invoke `path_symlink`.
	RightsPathSymlink = 1 << 24

	// The right to invoke `path_remove_directory`.
	RightsPathRemoveDirectory = 1 << 25

	// The right to invoke `path_unlink_file`.
	RightsPathUnlinkFile = 1 << 26

	// If `rights::fd_read` is set, includes the right to invoke `poll_oneoff` to subscribe to `eventtype::fd_read`.
	// If `rights::fd_write` is set, includes the right to invoke `poll_oneoff` to subscribe to `eventtype::fd_write`.
	RightsPollFdReadwrite = 1 << 27

	// The right to invoke `sock_shutdown`.
	RightsSockShutdown = 1 << 28
)

Variables

View Source
var SnapshotPreview1 exec.ModuleDefinition = wasiSnapshotPreview1Definition(0)

SnapshotPreview1 is the definition for the module canonically named "wasi_snapshot_preview1".

Functions

func Main

func Main(def exec.ModuleDefinition)

func MainErr

func MainErr(def exec.ModuleDefinition) error

func NewModuleEventHandler

func NewModuleEventHandler(options *Options) exec.ModuleEventHandler

func Pread

func Pread(r io.ReaderAt, buffers [][]byte, offset int64) (uint32, error)

func Pwrite

func Pwrite(w io.WriterAt, buffers [][]byte, offset int64) (uint32, error)

func Readv

func Readv(r io.Reader, buffers [][]byte) (uint32, error)

func Run

func Run(name string, def exec.ModuleDefinition, runOptions *RunOptions) error

func Writev

func Writev(w io.Writer, buffers [][]byte) (uint32, error)

Types

type Directory

type Directory interface {
	File

	FileStat(path string, followSymlinks bool) (FileStat, error)
	Mkdir(path string) error
	Open(path string, oflags, fflags int) (File, error)
	ReadDir(n int) ([]os.DirEntry, error)
	ReadLink(path string) (string, error)
	Rmdir(path string) error
	SetFileTimes(path string, accessTime *time.Time, modTime *time.Time, followSymlinks bool) error
	UnlinkFile(path string) error
}

func NewDirectory

func NewDirectory(path string, f *os.File) Directory

type ErrFile

type ErrFile int

func (ErrFile) Advise

func (ErrFile) Advise(offset, length uint64, advice int) error

func (ErrFile) Close

func (ErrFile) Close() error

func (ErrFile) Datasync

func (ErrFile) Datasync() error

func (ErrFile) Pread

func (ErrFile) Pread(buffers [][]byte, offset int64) (uint32, error)

func (ErrFile) Pwrite

func (ErrFile) Pwrite(buffers [][]byte, offset int64) (uint32, error)

func (ErrFile) Readv

func (ErrFile) Readv(buffers [][]byte) (uint32, error)

func (ErrFile) Seek

func (ErrFile) Seek(offset int64, whence int) (int64, error)

func (ErrFile) SetFlags

func (ErrFile) SetFlags(flags int) error

func (ErrFile) SetSize

func (ErrFile) SetSize(size uint64) error

func (ErrFile) SetTimes

func (ErrFile) SetTimes(accessTime *time.Time, modTime *time.Time) error

func (ErrFile) Stat

func (ErrFile) Stat() (FDStat, error)

func (ErrFile) Sync

func (ErrFile) Sync() error

func (ErrFile) Writev

func (ErrFile) Writev(buffers [][]byte) (uint32, error)

type Event

type Event struct {
	Kind      int
	Error     int
	Available uint
	Flags     int
	Userdata  uint64
}

type ExitError

type ExitError struct {
	// contains filtered or unexported fields
}

func (*ExitError) Code

func (e *ExitError) Code() int

func (*ExitError) Error

func (e *ExitError) Error() string

type FDStat

type FDStat struct {
	FileStat

	Flags int
}

type FS

type FS interface {
	OpenDirectory(path string) (Directory, error)
	Link(sourceDir Directory, sourceName string, targetDir Directory, targetName string) error
	Poll(subscriptions []Subscription) ([]Event, error)
	Rename(sourceDir Directory, sourceName string, targetDir Directory, targetName string) error
	Symlink(sourceDir Directory, sourceName string, targetDir Directory, targetName string) error
}

func NewFS

func NewFS() FS

type File

type File interface {
	Advise(offset, length uint64, advice int) error
	Close() error
	Datasync() error
	Pread(buffers [][]byte, offset int64) (uint32, error)
	Pwrite(buffers [][]byte, offset int64) (uint32, error)
	Readv(buffers [][]byte) (uint32, error)
	Seek(offset int64, whence int) (int64, error)
	SetFlags(flags int) error
	SetSize(size uint64) error
	SetTimes(accessTime *time.Time, modTime *time.Time) error
	Stat() (FDStat, error)
	Sync() error
	Writev(buffers [][]byte) (uint32, error)
}

func NewFile

func NewFile(f *os.File, flags int) File

func NewReader

func NewReader(r io.Reader) File

func NewWriter

func NewWriter(w io.Writer) File

type FileStat

type FileStat struct {
	Dev        uint64
	Inode      uint64
	Mode       os.FileMode
	LinkCount  uint64
	Size       uint64
	AccessTime time.Time
	ModTime    time.Time
	ChangeTime time.Time
}

type Options

type Options struct {
	Env  map[string]string
	Args []string

	Stdin  io.Reader
	Stdout io.Writer
	Stderr io.Writer

	FS      FS
	Preopen []Preopen
}

type Preopen

type Preopen struct {
	FSPath  string
	Path    string
	Rights  Rights
	Inherit Rights
}

type Resolver

type Resolver struct {
	// contains filtered or unexported fields
}

func NewResolver

func NewResolver(inner exec.ModuleResolver) Resolver

func (Resolver) ResolveModule

func (r Resolver) ResolveModule(name string) (exec.ModuleDefinition, error)

type Rights

type Rights wasiRights

type RunOptions

type RunOptions struct {
	*Options

	Debug    bool
	Trace    io.Writer
	Resolver exec.ModuleResolver
}

type Subscription

type Subscription struct {
	Kind     int
	File     File
	Timeout  time.Duration
	Deadline time.Time
	Userdata uint64
}

type TrapExit

type TrapExit int

Jump to

Keyboard shortcuts

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