Commit Graph

28 Commits

Author SHA1 Message Date
Crypt Keeper
2382bbf730 sysfs: decouples FS and File from the syscall package (#1602)
Signed-off-by: Adrian Cole <adrian@tetrate.io>
2023-07-30 16:06:22 +08:00
Crypt Keeper
fb6147ca94 Emulates AT_SYMLINK_NOFOLLOW instead of sometimes implementing it (#1588)
Some checks failed
Release CLI / Pre-release build (push) Has been cancelled
Release CLI / Pre-release test (macos-12) (push) Has been cancelled
Release CLI / Pre-release test (ubuntu-22.04) (push) Has been cancelled
Release CLI / Pre-release test (windows-2022) (push) Has been cancelled
Release CLI / Release (push) Has been cancelled
Signed-off-by: Adrian Cole <adrian@tetrate.io>
2023-07-22 08:03:47 +08:00
Crypt Keeper
b842d6cbfd fsapi: adds Oflag to decouple from syscall package (#1586)
Signed-off-by: Adrian Cole <adrian@tetrate.io>
2023-07-19 16:01:44 +08:00
Crypt Keeper
2f8dd23097 adds experimental sys.Errno to begin decoupling from the syscall package (#1582)
Signed-off-by: Adrian Cole <adrian@tetrate.io>
2023-07-17 08:13:29 +08:00
Crypt Keeper
6efcf25505 Exposes sys.Stat_t as a portable alternative to syscall.Stat_t (#1567)
Signed-off-by: Adrian Cole <adrian@tetrate.io>
2023-07-10 11:46:20 +08:00
Crypt Keeper
6a9088b46b Centralizes docs on Ino, specifically zero (#1560)
Signed-off-by: Adrian Cole <adrian@tetrate.io>
2023-07-07 08:33:50 +08:00
Crypt Keeper
0ec3c852d6 fs: pares down to functions used in wasip1 and wasip2 (#1563)
Signed-off-by: Adrian Cole <adrian@tetrate.io>
2023-07-07 07:58:36 +08:00
Edoardo Vacchi
97d0d70b73 wasi: add support for sockets (#1493)
Some checks failed
Release CLI / Pre-release build (push) Has been cancelled
Release CLI / Pre-release test (macos-12) (push) Has been cancelled
Release CLI / Pre-release test (ubuntu-22.04) (push) Has been cancelled
Release CLI / Pre-release test (windows-2022) (push) Has been cancelled
Release CLI / Release (push) Has been cancelled
Signed-off-by: Edoardo Vacchi <evacchi@users.noreply.github.com>
Signed-off-by: Adrian Cole <adrian@tetrate.io>
Co-authored-by: Crypt Keeper <64215+codefromthecrypt@users.noreply.github.com>
Co-authored-by: Achille <achille.roussel@gmail.com>
Co-authored-by: Adrian Cole <adrian@tetrate.io>
2023-06-02 20:45:42 +08:00
Crypt Keeper
34324031cb extracts FS interfaces into fsapi package and consolidates impls (#1477)
Signed-off-by: Adrian Cole <adrian@tetrate.io>
Signed-off-by: Edoardo Vacchi <evacchi@users.noreply.github.com>
Co-authored-by: Edoardo Vacchi <evacchi@users.noreply.github.com>
2023-05-17 07:19:54 +03:00
Crypt Keeper
11b346ed75 Removes AccessMode from platform.File (#1472)
Signed-off-by: Adrian Cole <adrian@tetrate.io>
2023-05-16 11:32:50 +08:00
Crypt Keeper
2ad2921eed Separates fs.File from os.File implementations of platform.File (#1455)
Signed-off-by: Adrian Cole <adrian@tetrate.io>
2023-05-15 13:42:20 +08:00
Crypt Keeper
16baeaab47 Adds Readdir to platform.File and removes internal use of fs.FS (#1454)
Signed-off-by: Adrian Cole <adrian@tetrate.io>
2023-05-11 10:04:34 +08:00
Crypt Keeper
76ef347b8c Adds Read and Pread to platform.File (#1439)
Signed-off-by: Adrian Cole <adrian@tetrate.io>
2023-05-08 07:54:06 +08:00
Crypt Keeper
b5198a46ff Adds AccessMode Write and Pwrite to platform.File (#1438)
Signed-off-by: Adrian Cole <adrian@tetrate.io>
2023-05-05 13:23:30 +08:00
Crypt Keeper
e5dc733df7 Adds Path to platform.File and refactors tests (#1431)
Signed-off-by: Adrian Cole <adrian@tetrate.io>
Signed-off-by: Edoardo Vacchi <evacchi@users.noreply.github.com>
Co-authored-by: Edoardo Vacchi <evacchi@users.noreply.github.com>
2023-05-04 07:05:40 +08:00
Crypt Keeper
493fe2d410 sysfs: stubs in approach to defining a new file type (#1290)
Signed-off-by: Adrian Cole <adrian@tetrate.io>
2023-05-01 12:33:40 +08:00
Crypt Keeper
36bf277534 sysfs: requires all methods to return syscall.Errno (#1264)
This forces all syscall functions, notably filesystem, to return numeric
codes as opposed to mapping in two different areas. The result of this
change is better consolidation in call sites of `sysfs.FS`, while
further refactoring is needed to address consolidation of file errors.

Signed-off-by: Adrian Cole <adrian@tetrate.io>
2023-03-22 07:47:57 +01:00
Adrian Cole
a43a0f11e4 Revert "sysfs: requires all methods to return syscall.Errno"
This reverts commit 4ea9d1a7b5.
2023-03-21 22:22:36 +08:00
Adrian Cole
4ea9d1a7b5 sysfs: requires all methods to return syscall.Errno
This forces all syscall functions, notably filesystem, to return numeric
codes as opposed to mapping in two different areas. The result of this
change is better consolidation in call sites of `sysfs.FS`, while
further refactoring is needed to address consolidation of file errors.

Signed-off-by: Adrian Cole <adrian@tetrate.io>
2023-03-21 22:20:28 +08:00
Crypt Keeper
c46a6eb4ae sysfs: return st instead of accepting it (#1261)
This returns stat as a value instead of a pointer param. This is both
more efficient and faster. It is also more efficient than returning a
pointer to a stat.

Signed-off-by: Adrian Cole <adrian@tetrate.io>
2023-03-21 10:57:19 +08:00
Crypt Keeper
8c04ad4448 sysfs: maps syscall.EROFS (#1236)
Signed-off-by: Adrian Cole <adrian@tetrate.io>
2023-03-14 10:47:32 +08:00
Crypt Keeper
a9b3301862 gojs: implements remaining link functions (#1198)
This implements the last remaining link functions using the same logic
as WASI. In doing so, this changes the signature for FS.ReadLink to be
more similar to the rest of the functions. Particularly, it stops
reading the result into a buffer.

After this, the only syscalls left to implement in gojs are chown.

Signed-off-by: Adrian Cole <adrian@tetrate.io>
2023-03-05 16:11:36 +08:00
Crypt Keeper
e77f24fe31 sysfs: drops os.File special casing for fs.FS to pass wasi-testsuite (#1174)
This adds a wazero adapter which passes wasi-testsuite 100pct on darwin,
linux and windows. While the main change was adding inodes to the wasi
`fd_readdir` dirents, there was a lot of incidental work needed.

Most of the work was troubleshooting in nature, around windows
specifically, but also wrapping of files. This backfills a lot of tests
and reworked how wrapping works, particularly around windows.

To accommodate this, we drop `os.File` special casing except for
`sysfs.DirFS`

Signed-off-by: Adrian Cole <adrian@tetrate.io>
2023-03-01 13:28:57 +08:00
Crypt Keeper
3d5b6d609a implements lstat and fixes inode stat on windows go 1.20 (#1168)
gojs: implements lstat

This implements platform.Lstat and uses it in GOOS=js. Notably,
directory listings need to run lstat on their entries to get the correct
inodes back. In GOOS=js, directories are a fan-out of names, then lstat.

This also fixes stat for inodes on directories. We were missing a test
so we didn't know it was broken on windows. The approach used now is
reliable on go 1.20, and we should suggest anyone using windows to
compile with go 1.20.

Signed-off-by: Takeshi Yoneda <takeshi@tetrate.io>
2023-02-28 07:20:31 +08:00
Crypt Keeper
4ca0858e57 sysfs: adds FS.Stat and companions in platform (#1140)
This centralizes filestat logic by making our own `Stat_t` similar to
`syscall.Stat_t`. This exposes utilities in the platform package and
adds a new function `FS.Stat` which avoids having to use `fs.File` to
get the same info. Doing so at the FS abstraction allows us to optimize
how it is implemented internally using portable means (e.g.
`os.StatFile`) or OS-specific means where necessary, e.g. in windows.

This also ensures `platform.OpenFile` returns syscall.Errno and
centralizes error checking with a new `require.EqualErrno` test.

Signed-off-by: Adrian Cole <adrian@tetrate.io>
2023-02-21 10:13:37 +08:00
Crypt Keeper
cc68f8ee12 fs: adds FSConfig to replace experimental writefs (#1061)
This adds a new top-level type FSConfig, which is configured via
`ModuleConfig.WithFSConfig(fcfg)`. This implements read-only and
read-write directory mounts, something not formally supported before. It
also implements `WithFS` which adapts a normal `fs.FS`. For convenience,
we retain the old `ModuleConfig.WithFS` signature so as to not affect
existing users much. A new configuration for our emerging raw
filesystem, `FSConfig.WithSysfs()` will happen later without breaking
this API.

Here's an example:
```
moduleConfig = wazero.NewModuleConfig().
	// Make the current directory read-only accessible to the guest.
	WithReadOnlyDirMount(".", "/")
	// Make "/tmp/wasm" accessible to the guest as "/tmp".
	WithDirMount("/tmp/wasm", "/tmp")
```

Signed-off-by: Adrian Cole <adrian@tetrate.io>
2023-01-25 10:09:40 -10:00
Crypt Keeper
cb97d7a488 fs: decouples sysfs from fs.FS and consolidates guest path logic (#1058)
This decouples sysfs.FS from fs.FS by introducing a temporary type
FSHolder, which will be removed when we top-level FSConfig (shortly).

This further reduces complexity by consolidating guest path
configuration into the only type that uses it: CompositeFS.

Signed-off-by: Adrian Cole <adrian@tetrate.io>
2023-01-23 17:49:51 -10:00
Crypt Keeper
2a584a8937 fs: renames internal syscallfs package to sysfs and notes RATIONALE (#1056)
It will help for us to rename earlier vs later, and syscallfs will be
laborious, especially after we introduce an FSConfig type and need to
declare a method name that differentiates from normal fs.FS. e.g. WithFS
vs WithSysFS reads nicer than WithSyscallFS, and meanwhile sys is
already a public package.

Signed-off-by: Adrian Cole <adrian@tetrate.io>
2023-01-23 11:11:35 +08:00