package sysfs

import "github.com/tetratelabs/wazero/internal/sysfs"

Package sysfs includes a low-level filesystem interface and utilities needed for WebAssembly host functions (ABI) such as WASI and runtime.GOOS=js.

The name sysfs was chosen because wazero's public API has a "sys" package, which was named after https://github.com/golang/sys.

Index

Constants

const (
	// UTIME_NOW is a special syscall.Timespec NSec value used to set the
	// file's timestamp to a value close to, but not greater than the current
	// system time.
	UTIME_NOW = _UTIME_NOW

	// UTIME_OMIT is a special syscall.Timespec NSec value used to avoid
	// setting the file's timestamp.
	UTIME_OMIT = _UTIME_OMIT
)
const MSG_PEEK = syscall.MSG_PEEK

MSG_PEEK is the constant syscall.MSG_PEEK

const NonBlockingFileIoSupported = true
const (
	SupportsSymlinkNoFollow = true
)

Functions

func Adapt

func Adapt(fs fs.FS) fsapi.FS

Adapt adapts the input to fsapi.FS unless it is already one. Use NewDirFS instead of os.DirFS as it handles interop issues such as windows support.

Note: This performs no flag verification on OpenFile. fsapi.FS cannot read flags as there is no parameter to pass them through with. Moreover, fsapi.FS documentation does not require the file to be present. In summary, we can't enforce flag behavior.

func NewDirFS

func NewDirFS(dir string) fsapi.FS

func NewReadFS

func NewReadFS(fs fsapi.FS) fsapi.FS

NewReadFS is used to mask an existing fsapi.FS for reads. Notably, this allows the CLI to do read-only mounts of directories the host user can write, but doesn't want the guest wasm to. For example, Python libraries shouldn't be written to at runtime by the python wasm file.

func NewStdioFile

func NewStdioFile(stdin bool, f fs.File) (fsapi.File, error)

func NewTCPListenerFile

func NewTCPListenerFile(tl *net.TCPListener) socketapi.TCPSock

NewTCPListenerFile creates a socketapi.TCPSock for a given *net.TCPListener.

func OpenFSFile

func OpenFSFile(fs fs.FS, path string, flag int, perm fs.FileMode) (fsapi.File, syscall.Errno)

func OpenFile

func OpenFile(path string, flag int, perm fs.FileMode) (*os.File, syscall.Errno)

func OpenOSFile

func OpenOSFile(path string, flag int, perm fs.FileMode) (fsapi.File, syscall.Errno)

func Rename

func Rename(from, to string) syscall.Errno
func Unlink(name string) (errno syscall.Errno)

func Utimens

func Utimens(path string, times *[2]syscall.Timespec, symlinkFollow bool) syscall.Errno

Utimens set file access and modification times on a path resolved to the current working directory, at nanosecond precision.

Parameters

The `times` parameter includes the access and modification timestamps to assign. Special syscall.Timespec NSec values UTIME_NOW and UTIME_OMIT may be specified instead of real timestamps. A nil `times` parameter behaves the same as if both were set to UTIME_NOW.

When the `symlinkFollow` parameter is true and the path is a symbolic link, the target of expanding that link is updated.

Errors

A zero syscall.Errno is success. The below are expected otherwise:

Notes

Source Files

adapter.go datasync_unsupported.go dir.go dirfs.go file.go file_unix.go futimens.go futimens_darwin.go nonblock_unix.go open_file.go osfile.go readfs.go rename.go select.go select_darwin.go sock.go sock_unix.go stat.go stat_bsd.go sync.go syscall6_darwin.go sysfs.go unlink.go

Version
v1.3.0
Published
Jul 11, 2023
Platform
darwin/amd64
Imports
14 packages
Last checked
4 hours ago

Tools for package owners.