sysfs

package
v0.3.0 Latest Latest
Warning

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

Go to latest
Published: Sep 7, 2026 License: Apache-2.0 Imports: 3 Imported by: 1 module, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Overview

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

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

This tracked in https://github.com/samyfodil/wazy/issues/1013

Index

Examples

Constants

This section is empty.

Variables

This section is empty.

Functions

func DirFS

func DirFS(dir string) sys.FS

DirFS is like os.DirFS except it returns sys.FS, which has more features.

Example

This example shows how to configure a sysfs.DirFS

package main

import (
	"github.com/samyfodil/wazy"
	"github.com/samyfodil/wazy/sysfs"
)

var moduleConfig wazy.ModuleConfig

func main() {
	root := sysfs.DirFS(".")

	moduleConfig = wazy.NewModuleConfig().
		WithFSConfig(wazy.NewFSConfig().WithSysFSMount(root, "/"))

}

Types

type AdaptFS

type AdaptFS = sysfs.AdaptFS

AdaptFS adapts the input to sys.FS. Use DirFS instead of adapting an os.DirFS as it handles interop issues such as windows support.

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

Example

This example shows how to adapt a fs.FS to a sys.FS

package main

import (
	"io/fs"
	"testing/fstest"

	"github.com/samyfodil/wazy"
	"github.com/samyfodil/wazy/sysfs"
)

var moduleConfig wazy.ModuleConfig

func main() {
	m := fstest.MapFS{
		"a/b.txt": &fstest.MapFile{Mode: 0o666},
		".":       &fstest.MapFile{Mode: 0o777 | fs.ModeDir},
	}
	root := &sysfs.AdaptFS{FS: m}

	moduleConfig = wazy.NewModuleConfig().
		WithFSConfig(wazy.NewFSConfig().WithSysFSMount(root, "/"))

}

type FSConfig deprecated

type FSConfig interface {
	WithSysFSMount(fs sys.FS, guestPath string) wazy.FSConfig
}

FSConfig is the type assertion that used to be the only way to reach WithSysFSMount, back when sys.FS was still experimental.

Deprecated: wazy.FSConfig declares WithSysFSMount directly now -- call it on the wazy.FSConfig, no assertion needed. This interface remains so existing `config.(sysfs.FSConfig).WithSysFSMount(...)` code keeps compiling.

type ReadFS

type ReadFS = sysfs.ReadFS

ReadFS is used to mask an existing sys.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.

Note: This implements read-only by returning sys.EROFS or sys.EBADF, depending on the operation that require write access.

Example

This example shows how to configure a sysfs.ReadFS

package main

import (
	"github.com/samyfodil/wazy"
	"github.com/samyfodil/wazy/sysfs"
)

var moduleConfig wazy.ModuleConfig

func main() {
	root := sysfs.DirFS(".")
	readOnly := &sysfs.ReadFS{FS: root}

	moduleConfig = wazy.NewModuleConfig().
		WithFSConfig(wazy.NewFSConfig().WithSysFSMount(readOnly, "/"))

}

Jump to

Keyboard shortcuts

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