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:
@@ -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
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user