Closed
Description
I have been trying to write to a pre-opened directory from a Wasm Reactor however I continually get the error.
Write fileopen /test.txt: errno 76
From looking into this I found this issue on wasmtime:
rust-lang/rust#79997 (comment)
It states that you must call _initialize
in order to use pre-opened directories but I have tried this and failed to get it working.
I am initiating the runtime using the following code.
public void init() {
WasiCtx wasi = new WasiCtxBuilder().inheritStdout().inheritStderr().preopenedDir(Path.of("./"), "/").build();
store = Store.withoutData(wasi);
engine = store.engine();
}
Then from Go I have a simple function, the complete wat can be found below.
//go:export write_file
func write_file() int {
fmt.Printf("Write file")
err := ioutil.WriteFile("/test.txt", []byte("Hello"), 0644)
if err != nil {
fmt.Println(err)
return 1
}
return 0
}
Before callingfile_write
I call _initialize
like so.
Func f = linker.get(store, "", "_initialize").get().func();
WasmFunctions.Consumer0 fn = WasmFunctions.consumer(store, f);
fn.accept();
I did get this working with a Command and adding the file write code into main
with the wasmtime
cli but not successfully from a reactor.
Kind regards,
Nic
Metadata
Metadata
Assignees
Labels
No labels