cli,wasi: passes mounts directly as preopens to run rust wasi-testsuite (#1078)

This allows wasi to see mounts as individual preopens instead of
virtualized under a root. (GOOS=js doesn't use pre-opens so it still
sees a virtual root). This allows us to progress wasi-testsuite rust
tests, but acknowledges a current glitch in zig support, which is
tracked separately as #1077

Signed-off-by: Adrian Cole <adrian@tetrate.io>
This commit is contained in:
Crypt Keeper
2023-01-30 08:11:16 +02:00
committed by GitHub
parent 574b2a70ab
commit d04199d1c3
7 changed files with 87 additions and 14 deletions

View File

@@ -226,14 +226,26 @@ func NewFSContext(stdin io.Reader, stdout, stderr io.Writer, rootFS sysfs.FS) (f
return fsc, nil
}
// TODO: destructure CompositeFS into multiple pre-opens after #1077
fsc.openedFiles.Insert(&FileEntry{
FS: rootFS,
Name: "/",
IsPreopen: true,
isDirectory: true,
File: &lazyDir{fs: rootFS},
})
if comp, ok := rootFS.(*sysfs.CompositeFS); ok {
preopens := comp.FS()
for i, p := range comp.GuestPaths() {
fsc.openedFiles.Insert(&FileEntry{
FS: preopens[i],
Name: p,
IsPreopen: true,
isDirectory: true,
File: &lazyDir{fs: rootFS},
})
}
} else {
fsc.openedFiles.Insert(&FileEntry{
FS: rootFS,
Name: "/",
IsPreopen: true,
isDirectory: true,
File: &lazyDir{fs: rootFS},
})
}
return fsc, nil
}