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 Chown(path string, uid, gid int) syscall.Errno
- func Lchown(path string, uid, gid int) syscall.Errno
- func NewDirFS(dir string) fsapi.FS
- func NewReadFS(fs fsapi.FS) fsapi.FS
- func NewRootFS(fs []fsapi.FS, guestPaths []string) (fsapi.FS, error)
- 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 StatFromDefaultFileInfo(t fs.FileInfo) fsapi.Stat_t
- func StripPrefixesAndTrailingSlash(path string) string
- func Unlink(name string) syscall.Errno
- func Utimens(path string, times *[2]syscall.Timespec, symlinkFollow bool) syscall.Errno
- type CompositeFS
- func (c *CompositeFS) Chmod(path string, perm fs.FileMode) syscall.Errno
- func (c *CompositeFS) Chown(path string, uid, gid int) syscall.Errno
- func (c *CompositeFS) FS() (fs []fsapi.FS)
- func (c *CompositeFS) GuestPaths() (guestPaths []string)
- func (c *CompositeFS) Lchown(path string, uid, gid int) syscall.Errno
- func (c *CompositeFS) Link(oldName, newName string) syscall.Errno
- func (c *CompositeFS) Lstat(path string) (fsapi.Stat_t, syscall.Errno)
- func (c *CompositeFS) Mkdir(path string, perm fs.FileMode) syscall.Errno
- func (c *CompositeFS) OpenFile(path string, flag int, perm fs.FileMode) (f fsapi.File, err syscall.Errno)
- func (c *CompositeFS) Readlink(path string) (string, syscall.Errno)
- func (c *CompositeFS) Rename(from, to string) syscall.Errno
- func (c *CompositeFS) Rmdir(path string) syscall.Errno
- func (c *CompositeFS) Stat(path string) (fsapi.Stat_t, syscall.Errno)
- func (c *CompositeFS) String() string
- func (c *CompositeFS) Symlink(oldName, link string) (err syscall.Errno)
- func (c *CompositeFS) Truncate(path string, size int64) syscall.Errno
- func (c *CompositeFS) Unlink(path string) syscall.Errno
- func (c *CompositeFS) 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 the flag PEEK for syscall.Recvfrom on Windows. This constant is not exported on this platform.
const ( SupportsSymlinkNoFollow = false )
Define values even if not used except as sentinels.
Functions ¶
func Adapt ¶
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 ¶
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 ¶
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 NewReadFS ¶
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 NewStdioFile ¶
func NewTCPListenerFile ¶
func NewTCPListenerFile(tl *net.TCPListener) socketapi.TCPSock
func OpenFSFile ¶
func OpenFile ¶
func OpenOSFile ¶
func Rename ¶
func StatFromDefaultFileInfo ¶
func StripPrefixesAndTrailingSlash ¶
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
Types ¶
type CompositeFS ¶
type CompositeFS struct { fsapi.UnimplementedFS // contains filtered or unexported fields }
func (*CompositeFS) Chmod ¶
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 (*CompositeFS) Link ¶
func (c *CompositeFS) Link(oldName, newName string) syscall.Errno
Link implements the same method as documented on api.FS
func (*CompositeFS) Lstat ¶
Lstat implements the same method as documented on api.FS
func (*CompositeFS) Mkdir ¶
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 (*CompositeFS) Readlink ¶
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 ¶
Stat implements the same method as documented on api.FS
func (*CompositeFS) String ¶
func (c *CompositeFS) String() string
String implements fmt.Stringer
func (*CompositeFS) Symlink ¶
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 (*CompositeFS) Unlink ¶
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
Source Files ¶
adapter.go chown.go chown_unsupported.go datasync_unsupported.go dir.go dirfs.go file.go futimens.go futimens_windows.go nonblock_windows.go open_file_windows.go osfile.go readfs.go rename_windows.go rootfs.go select.go select_windows.go sock.go sock_windows.go stat.go stat_windows.go sync_windows.go sysfs.go unlink_windows.go
- Version
- v1.2.0
- Published
- Jun 2, 2023
- Platform
- windows/amd64
- Imports
- 15 packages
- Last checked
- 10 hours ago –
Tools for package owners.