sysfs

package
v1.1.0 Latest Latest
Warning

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

Go to latest
Published: Jun 6, 2023 License: Apache-2.0 Imports: 11 Imported by: 0

Documentation

Overview

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

View Source
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
)
View Source
const (
	SupportsSymlinkNoFollow = true
)

Variables

This section is empty.

Functions

func Adapt

func Adapt(fs fs.FS) fsapi.FS

Adapt adapts the input to api.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 Chown

func Chown(path string, uid, gid int) syscall.Errno

Chown is like os.Chown, except it returns a syscall.Errno, not a fs.PathError. For example, this returns syscall.ENOENT if the path doesn't exist. A syscall.Errno of zero is success.

Note: This always returns syscall.ENOSYS on windows. See https://linux.die.net/man/3/chown

func Lchown

func Lchown(path string, uid, gid int) syscall.Errno

Lchown is like os.Lchown, except it returns a syscall.Errno, not a fs.PathError. For example, this returns syscall.ENOENT if the path doesn't exist. A syscall.Errno of zero is success.

Note: This always returns syscall.ENOSYS on windows. See https://linux.die.net/man/3/lchown

func NewDirFS

func NewDirFS(dir string) fsapi.FS

func NewReadFS

func NewReadFS(fs fsapi.FS) fsapi.FS

NewReadFS is used to mask an existing api.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 NewRootFS

func NewRootFS(fs []fsapi.FS, guestPaths []string) (fsapi.FS, error)

func NewStdioFile

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

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 StatFromDefaultFileInfo

func StatFromDefaultFileInfo(t fs.FileInfo) fsapi.Stat_t

func StripPrefixesAndTrailingSlash

func StripPrefixesAndTrailingSlash(path string) string
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:

  • 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

Types

type CompositeFS

type CompositeFS struct {
	fsapi.UnimplementedFS
	// contains filtered or unexported fields
}

func (*CompositeFS) Chmod

func (c *CompositeFS) Chmod(path string, perm fs.FileMode) syscall.Errno

Chmod implements the same method as documented on api.FS

func (*CompositeFS) Chown

func (c *CompositeFS) Chown(path string, uid, gid int) syscall.Errno

Chown implements the same method as documented on api.FS

func (*CompositeFS) FS

func (c *CompositeFS) FS() (fs []fsapi.FS)

FS returns the underlying filesystems in original order.

func (*CompositeFS) GuestPaths

func (c *CompositeFS) GuestPaths() (guestPaths []string)

GuestPaths returns the underlying pre-open paths in original order.

func (*CompositeFS) Lchown

func (c *CompositeFS) Lchown(path string, uid, gid int) syscall.Errno

Lchown implements the same method as documented on api.FS

func (c *CompositeFS) Link(oldName, newName string) syscall.Errno

Link implements the same method as documented on api.FS

func (*CompositeFS) Lstat

func (c *CompositeFS) Lstat(path string) (fsapi.Stat_t, syscall.Errno)

Lstat implements the same method as documented on api.FS

func (*CompositeFS) Mkdir

func (c *CompositeFS) Mkdir(path string, perm fs.FileMode) syscall.Errno

Mkdir implements the same method as documented on api.FS

func (*CompositeFS) OpenFile

func (c *CompositeFS) OpenFile(path string, flag int, perm fs.FileMode) (f fsapi.File, err syscall.Errno)

OpenFile implements the same method as documented on api.FS

func (c *CompositeFS) Readlink(path string) (string, syscall.Errno)

Readlink implements the same method as documented on api.FS

func (*CompositeFS) Rename

func (c *CompositeFS) Rename(from, to string) syscall.Errno

Rename implements the same method as documented on api.FS

func (*CompositeFS) Rmdir

func (c *CompositeFS) Rmdir(path string) syscall.Errno

Rmdir implements the same method as documented on api.FS

func (*CompositeFS) Stat

func (c *CompositeFS) Stat(path string) (fsapi.Stat_t, syscall.Errno)

Stat implements the same method as documented on api.FS

func (*CompositeFS) String

func (c *CompositeFS) String() string

String implements fmt.Stringer

func (c *CompositeFS) Symlink(oldName, link string) (err syscall.Errno)

Symlink implements the same method as documented on api.FS

func (*CompositeFS) Truncate

func (c *CompositeFS) Truncate(path string, size int64) syscall.Errno

Truncate implements the same method as documented on api.FS

func (c *CompositeFS) Unlink(path string) syscall.Errno

Unlink implements the same method as documented on api.FS

func (*CompositeFS) Utimens

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

Utimens implements the same method as documented on api.FS

Jump to

Keyboard shortcuts

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