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
- func Adapt(fs fs.FS) fsapi.FS
- func NewDirFS(dir string) fsapi.FS
- func NewReadFS(fs fsapi.FS) fsapi.FS
- func NewStdioFile(stdin bool, f fs.File) (fsapi.File, error)
- func NewTCPListenerFile(tl *net.TCPListener) socketapi.TCPSock
- func OpenFSFile(fs fs.FS, path string, flag fsapi.Oflag, perm fs.FileMode) (fsapi.File, experimentalsys.Errno)
- func OpenFile(path string, flag fsapi.Oflag, perm fs.FileMode) (*os.File, experimentalsys.Errno)
- func OpenOSFile(path string, flag fsapi.Oflag, perm fs.FileMode) (fsapi.File, experimentalsys.Errno)
- func Utimens(path string, times *[2]syscall.Timespec) experimentalsys.Errno
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 = 0x2
MSG_PEEK is a filler value.
Functions ¶
func Adapt ¶
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 NewReadFS ¶
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 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 fsapi.Oflag, perm fs.FileMode) (fsapi.File, experimentalsys.Errno)
func OpenFile ¶
func OpenOSFile ¶
func OpenOSFile(path string, flag fsapi.Oflag, perm fs.FileMode) (fsapi.File, experimentalsys.Errno)
func Utimens ¶
func Utimens(path string, times *[2]syscall.Timespec) experimentalsys.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. If the path is a symbolic link, the target of expanding that link is updated.
Errors
A zero sys.Errno is success. The below are expected otherwise:
- sys.ENOSYS: the implementation does not support this function.
- sys.EINVAL: `path` is invalid.
- sys.EEXIST: `path` exists and is a directory.
- sys.ENOTDIR: `path` exists and is a file.
Notes
- This is like syscall.UtimesNano and `utimensat` with `AT_FDCWD` in POSIX. See https://pubs.opengroup.org/onlinepubs/9699919799/functions/futimens.html
Source Files ¶
adapter.go datasync_unsupported.go dir.go dirfs.go file.go file_unsupported.go futimens.go futimens_unsupported.go nonblock_unix.go oflag.go open_file_notwindows.go open_file_unsupported.go osfile.go readfs.go rename.go select.go select_unsupported.go sock.go sock_unsupported.go stat.go stat_unsupported.go sync.go sysfs.go unlink.go
- Version
- v1.3.1
- Published
- Jul 22, 2023
- Platform
- js/wasm
- Imports
- 15 packages
- Last checked
- 6 minutes ago –
Tools for package owners.