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 int, perm fs.FileMode) (fsapi.File, syscall.Errno)
- func OpenFile(path string, flag int, perm fs.FileMode) (*os.File, syscall.Errno)
- func OpenOSFile(path string, flag int, perm fs.FileMode) (fsapi.File, syscall.Errno)
- func Rename(from, to string) syscall.Errno
- func Unlink(name string) (errno syscall.Errno)
- func Utimens(path string, times *[2]syscall.Timespec, symlinkFollow bool) syscall.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.
const NonBlockingFileIoSupported = false
const ( SupportsSymlinkNoFollow = false )
Define values even if not used except as sentinels.
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 OpenFile ¶
func OpenOSFile ¶
func Rename ¶
func Unlink ¶
func Utimens ¶
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:
- syscall.ENOSYS: the implementation does not support this function.
- syscall.EINVAL: `path` is invalid.
- syscall.EEXIST: `path` exists and is a directory.
- syscall.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 open_file_js.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.0
- Published
- Jul 11, 2023
- Platform
- js/wasm
- Imports
- 14 packages
- Last checked
- 6 minutes ago –
Tools for package owners.