Commit Graph

118 Commits

Author SHA1 Message Date
Edoardo Vacchi
76dce033d3 Upgrade floor Go version to 1.19 everywhere. (#1622) 2023-08-10 06:09:16 +09:00
Crypt Keeper
1f8c908f1c Exposes writeable filesystem as experimentalsys.FS (#1605)
Signed-off-by: Adrian Cole <adrian@tetrate.io>
2023-07-31 07:56:28 +08:00
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
0300f4b3c1 experimental: adds close notification hook (#1574)
Signed-off-by: Adrian Cole <adrian@tetrate.io>
2023-07-11 09:27:43 +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
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
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
7498ad335f gojs: drops HTTP support to be compatible with Go 1.21 (#1557)
Signed-off-by: Adrian Cole <adrian@tetrate.io>
2023-07-05 16:56:18 +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
4dd4d54cda Removes platform.Readdirnames (#1451)
Signed-off-by: Adrian Cole <adrian@tetrate.io>
2023-05-10 14:44:54 +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
5380321eea Adds Truncate to platform.File (#1428)
Signed-off-by: Adrian Cole <adrian@tetrate.io>
2023-05-04 15:07:18 +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
40341af448 fs: returns EBADF on negative file descriptor (#1391)
This changes file descriptors from uint32 to int32 and the
corresponding file table to reject negative values. This ensures
invalid values aren't mistaken for very large descriptor entries, which
can use a lot of memory as the table implementation isn't designed to
be sparse.

See https://pubs.opengroup.org/onlinepubs/9699919799/functions/dirfd.html#tag_16_90

Signed-off-by: Adrian Cole <adrian@tetrate.io>
2023-04-21 16:08:35 +02:00
Crypt Keeper
cd34767954 Fixes race where HostFunc names are needlessly lazy set (#1375)
A prior change broke race tests as it lazy set HostFunc.Name even when
saved as a field. This sets name in all places we instantiate HostFunc
for use in fields.

Fixes #1373

Signed-off-by: Adrian Cole <adrian@tetrate.io>
2023-04-18 08:14:05 +09:00
Crypt Keeper
b9e03dc691 Makes host function index insertion order (#1370)
This makes host functions index consistently on insertion order, rather
than lexicographic order. This helps with ABI such as Emscripten, which
need an expected order.

This also constrains the internal code around host functions to only one
export name. More than one was never used. By restricting this, logic is
simpler and smaller.

Signed-off-by: Adrian Cole <adrian@tetrate.io>
2023-04-17 17:18:11 +01:00
Takeshi Yoneda
fa3090a022 Allows WithMemoryLimitPages to override the default pages (#1335)
Signed-off-by: Takeshi Yoneda <takeshi@tetrate.io>
2023-04-03 09:30:34 +09:00
Takeshi Yoneda
a4226906cf Deletes wasm.CallCtx (#1280)
Signed-off-by: Takeshi Yoneda <takeshi@tetrate.io>
2023-03-24 17:00:43 -07:00
Crypt Keeper
451c792ee8 Avoids returning ExitError on exit code zero, and optimizes for no allocations (#1284)
Fixes #1283

Signed-off-by: Adrian Cole <adrian@tetrate.io>
2023-03-24 16:42:30 +01: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
8464474e21 gojs: adds support for uid and gid (#1245)
This adds `gojs.WithOSUser` which passes through current user IDs so
that GOOS=js compiled wasm can read them. This also adds support for
reading back the uid and gid on files. In summary, this passes
`os.TestChown` except on windows where it will not work due to lack of
support.

Signed-off-by: Adrian Cole <adrian@tetrate.io>
2023-03-16 11:07:27 +08:00
Takeshi Yoneda
e17a85146a Holds wasm.Code as values on wasm.Module (#1243)
Signed-off-by: Takeshi Yoneda <takeshi@tetrate.io>
2023-03-15 14:45:54 +09:00
Takeshi Yoneda
aba4ede088 Removes usage of host functions with Wasm optocdes (#1241)
Signed-off-by: Takeshi Yoneda <takeshi@tetrate.io>
2023-03-15 13:42:53 +09:00
Takeshi Yoneda
f24a3f49a4 gojs: refactors out gojs.Config type (#1240)
In order to support more configuration, we should stop using context as
it is getting gnarly.

Signed-off-by: Takeshi Yoneda <takeshi@tetrate.io>
Signed-off-by: Adrian Cole <adrian@tetrate.io>
2023-03-15 12:27:47 +08:00
Crypt Keeper
8a92cd3841 returns EBADF when attempting to write to STDIN (#1237)
Found this problem while troubleshooting #1232

Signed-off-by: Adrian Cole <adrian@tetrate.io>
2023-03-14 12:30:09 +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
Takeshi Yoneda
37c041f3e1 gojs: fixes symlink (#1234)
Signed-off-by: Takeshi Yoneda <takeshi@tetrate.io>
2023-03-14 09:58:25 +09:00
Crypt Keeper
ec6a054119 gojs: implements umask (#1230)
This implements host-side umask for gojs, which allows
`os.TestMkdirStickyUmask` to pass.

Signed-off-by: Adrian Cole <adrian@tetrate.io>
2023-03-14 08:01:50 +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
a814cddcb6 Fixes file type mapping problem identified in /dev/null (#1225)
This fixes a file type mapping bug running go's `TestDevNullFile` test
via gojs.

See #1222

Signed-off-by: Adrian Cole <adrian@tetrate.io>
2023-03-13 13:06:09 +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
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
6626535f44 gojs: ensures Mkdir(path, 0) works (#1208)
Go has a test that forces us to handle Mkdir with zero as its
permissions. In GOOS=js, the result of fs.mkdir is a file descriptor,
and to open that, we can't use literally 0. Hence, to solve this we need
to coerce 0 to 0500 in GOOS=js.

Signed-off-by: Adrian Cole <adrian@tetrate.io>
2023-03-07 16:02:17 +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
25493fe271 gojs: makes experimental status explicit (#1200)
Before, our README said gojs `GOOS=js compiled wasm` was experimental.
However, as we head to 1.0 we should be more explicit about that.

When we started gojs, there was no likely future where `GOOS=wasi` would
happen in the standard go compiler. This has changed, so we'll only keep
the gojs package around until wasi is usable for two Go releases. Being
in an experimental package helps others know to watch out for this.

Signed-off-by: Adrian Cole <adrian@tetrate.io>
2023-03-06 09:22:58 +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