Commit Graph

67 Commits

Author SHA1 Message Date
Crypt Keeper
15fa5c4de5 Changes build to test go 1.21rc2 (#1571)
Signed-off-by: Adrian Cole <adrian@tetrate.io>
2023-07-10 13:39:37 +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
Edoardo Vacchi
d3f09bdcff wasi: nonblocking pipes on Windows (#1570)
Signed-off-by: Edoardo Vacchi <evacchi@users.noreply.github.com>
2023-07-10 06:50:26 +08:00
Crypt Keeper
276257102f gojs: removes user/group behavior (#1566)
Signed-off-by: Adrian Cole <adrian@tetrate.io>
2023-07-07 10:27:41 +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
Crypt Keeper
d7193952e1 Allows wrapped filesystems to return dirent.ino except in windows (#1558)
Signed-off-by: Adrian Cole <adrian@tetrate.io>
2023-07-05 17:41:35 +08:00
Crypt Keeper
511b032fa6 readdir: defer re-opening when Seek(0,SeekStart) on a directory (#1551)
Signed-off-by: Adrian Cole <adrian@tetrate.io>
2023-07-02 12:59:44 +08:00
Crypt Keeper
820685c4b2 Simplifies filesystem implementations (#1548)
Signed-off-by: Adrian Cole <adrian@tetrate.io>
2023-07-01 06:53:09 +08:00
Edoardo Vacchi
39f2ff23a6 wasi: improve stdin support for nonblocking, fix stdout (#1542)
Signed-off-by: Edoardo Vacchi <evacchi@users.noreply.github.com>
2023-06-29 07:51:23 +08:00
Crypt Keeper
53ce5eea83 Allows wasip1 guests to use arbitrarily nested pre-opens (#1536)
Signed-off-by: Adrian Cole <adrian@tetrate.io>
2023-06-27 10:02:57 +08:00
Edoardo Vacchi
b01ba67fdc wasi: add nonblock_test.go from gotip, fix nonblock read on Unix-like (#1517)
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>
2023-06-15 07:08:44 +08:00
Crypt Keeper
f3778cae08 wasi: fix nonblocking sockets on *NIX (gotip net/http) (#1503)
Signed-off-by: Adrian Cole <adrian@tetrate.io>
Co-authored-by: Edoardo Vacchi <evacchi@users.noreply.github.com>
2023-06-13 06:51:32 +10:00
Edoardo Vacchi
390437e1fe Revert "wip"
This reverts commit 1588723735.
2023-06-09 15:23:25 +02:00
Edoardo Vacchi
1588723735 wip
Signed-off-by: Edoardo Vacchi <evacchi@users.noreply.github.com>
2023-06-09 15:21:32 +02: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
Achille
1b35900911 linux: support using huge pages (#1475)
Signed-off-by: Achille Roussel <achille.roussel@gmail.com>
2023-05-17 11:14:31 -07: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
4dd4d54cda Removes platform.Readdirnames (#1451)
Signed-off-by: Adrian Cole <adrian@tetrate.io>
2023-05-10 14:44:54 +08:00
Crypt Keeper
29c7c7667b Adds IsDir and Seek to platform.File (#1441)
Signed-off-by: Adrian Cole <adrian@tetrate.io>
2023-05-09 07:47:25 +08:00
Crypt Keeper
3bf7e342c2 Adds Utimens to platform.File (#1440)
Signed-off-by: Adrian Cole <adrian@tetrate.io>
2023-05-08 11:14:28 +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
Adrian Cole
cf5ebf6f6b Use require.ErrnoEquals for more precise failures
Signed-off-by: Adrian Cole <adrian@tetrate.io>
2023-05-03 13:54:12 +08:00
Crypt Keeper
c5871c772c Adds Datasync to platform.File (#1427)
Signed-off-by: Adrian Cole <adrian@tetrate.io>
2023-05-02 14:12:47 +08:00
Crypt Keeper
b79c45b91c Adds Sync to platform.File (#1426)
Signed-off-by: Adrian Cole <adrian@tetrate.io>
2023-05-02 13:16:50 +08:00
Crypt Keeper
18c793f8e6 Adds platform.File.Chmod (#1423)
Signed-off-by: Adrian Cole <adrian@tetrate.io>
2023-05-01 19:18:56 +08:00
Crypt Keeper
1047ddee78 Adds platform.File.Chown (#1422)
Signed-off-by: Adrian Cole <adrian@tetrate.io>
2023-05-01 18:32:13 +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
Achille
6471ac7dd7 path_filestat_get: interpret LOOKUP_SYMLINK_FOLLOW (#1252)
Signed-off-by: Achille Roussel <achille.roussel@gmail.com>
2023-03-18 08:23:44 +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
f3c83dbd8d dirfs: corrects path joining bug when mounting root (#1228)
Before, we created invalid directory paths when the host directory was
"/", and now we don't!

This brings tests left failing on GOOS=js to 7
```bash
$ wazero run -mount=/:/ --experimental-workdir=$(go env GOROOT)/src/os os.wasm| grep '^--- FAIL'|wc -l
       7
```

See #1222

Signed-off-by: Edoardo Vacchi <evacchi@users.noreply.github.com>
Co-authored-by: Edoardo Vacchi <evacchi@users.noreply.github.com>
2023-03-14 07:30:12 +08:00
Crypt Keeper
7e953d7483 gojs: introduces --experimental-workdir CLI arg (#1226)
When compiled to `GOOS=js`, wasm does not maintain the working
directory: it is defined by the host. While not explicitly documented,
`os.TestDirFSRootDir` in Go suggests the working directory must be valid
to pass (literally the directory holding the file).

This adds an experimental CLI flag that gives the initial working
directory. This is experimental because while GOOS=js uses this, current
WASI compilers will not, as they maintain working directory in code
managed by wasi-libc, or as a convention (e.g. in Zig).

It is not yet known if wasi-cli will maintain working directory
externally or not.

Signed-off-by: Adrian Cole <adrian@tetrate.io>
2023-03-13 15:43:45 +08:00
Crypt Keeper
6243091dc2 renames exit log scope to proc and resolves gojs files to cwd (#1223)
Many tests failed in gojs due to needing to be resolved against the CWD,
which is atypically stored host side. This fixes that and renames the
"exit" scope to "proc" so we can use it for other proc concerns besides
exit.

This reduces known failures on GOOS=js from 23 to 14:
```bash
$ wazero run -mount=/usr/local/go/src/os:/:ro -mount=/tmp:/tmp -mount=/etc:/etc:ro -mount=/usr:/usr:ro -mount=/dev:/dev:ro os.wasm |grep '^--- FAIL'|wc -l
      14
```

See #1222

Signed-off-by: Adrian Cole <adrian@tetrate.io>
2023-03-13 11:41:19 +08:00
Crypt Keeper
41ef17c5c2 wasi: implements path_filestat_set_times (#1220)
This implements `path_filestat_set_times` which is the last remaining filesystem function in wasi we formerly stubbed.

Other minor changes:
* this removes all places we import alias path as pathutil, introducing a utility function `joinPath` where that was used to reduce name conflicts.
* this fixes places where we used different variable names for the same parameter between main and test source.

Signed-off-by: Adrian Cole <adrian@tetrate.io>
2023-03-13 09:46:17 +08:00
Crypt Keeper
4d90a5c364 platform: Allows sysfs to implement utimens natively (#1215)
platform: Allows sysfs to implement utimesns natively

This moves away from `syscall.UtimesNano` as it has intentionally
avoided common features in POSIX, such as handling UTIME_NOW and
UTIME_OMIT. When we eventually expose this API, users will be free to
override `UTIME_NOW` with a fake clock, possibly the same that was
supplied to wazero's `ModuleConfig`.

Signed-off-by: Adrian Cole <adrian@tetrate.io>
Co-authored-by: Edoardo Vacchi <evacchi@users.noreply.github.com>
2023-03-09 13:14:09 +08:00
Crypt Keeper
f5d194c43c wasi: implements platform.UtimesFile for fd_filestat_set_times (#1199)
This implements `platform.UtimesFile` which is similar to futimes.
Before, we were using path-based functionality even though the call site
was for a file descriptor.

Note: right now, there's no obvious code in Go to invoke the `futimens`
syscall. This means non-windows isn't implemented at nanos granularity,
so ends up falling back to the path based option.

Finally, this removes tests for the seldom supported updates with
negative epoch time. There's little impact to this as setting times on
files before 1970 isn't a typical use case.

Signed-off-by: Adrian Cole <adrian@tetrate.io>
2023-03-07 13:44:46 +08:00
Crypt Keeper
b742c7a8cc gojs: implements chown (#1204)
This finishes the last remaining syscalls in `GOOS=js`. After this is
merged, further bugs are easier to hunt down as we know ENOSYS is not
expected on writeable file systems.

Signed-off-by: Adrian Cole <adrian@tetrate.io>
2023-03-06 17:43:46 +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
Edoardo Vacchi
f36d30b82d Ensure nil is accepted as FS config (#1182)
In previous releases, passing a `nil` value as an FS config
did not cause any error. However, in 1.0.0-rc.1 this leads
to the creation of an invalid `adapter{fs: nil}`, which
eventually leads to a panic (nil):

    (f *FileEntry) Stat(st *platform.Stat_t) =>
        (r *lazyDir) file() =>
            r.fs.OpenFile(".", os.O_RDONLY, 0)

with fs == nil

The backwards-compatible fix is to make Adapt()
return UnimplementedFS, and ensuring `nil` is a valid value
that config is able to handle.

However, we may want to consider returning an error somewhere,
because configuring a nil FS may be unintended.

Signed-off-by: Edoardo Vacchi <evacchi@users.noreply.github.com>
2023-03-03 10:01:31 +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