diff --git a/lib/wasm-micro-runtime b/lib/wasm-micro-runtime index 72c06b5..da95bab 160000 --- a/lib/wasm-micro-runtime +++ b/lib/wasm-micro-runtime @@ -1 +1 @@ -Subproject commit 72c06b5c507a01645909a67e9d7320b045cbbcf0 +Subproject commit da95babb0197dd37a8b227bf9e76ee7ec500414a diff --git a/src/wamr.cpp b/src/wamr.cpp index 3f24c94..ffa32fc 100644 --- a/src/wamr.cpp +++ b/src/wamr.cpp @@ -116,7 +116,7 @@ int WAMRInstance::invoke_fopen(std::string &path, uint32 option) { return -1; }; int WAMRInstance::invoke_frenumber(uint32 fd, uint32 to) { - auto name = "__wasi_fd_renumber"; + auto name = "fd_renumber"; if (!(func = wasm_runtime_lookup_function(module_inst, name, nullptr))) { LOGV(ERROR) << "The wasi fopen function is not found."; auto target_module = get_module_instance()->e; diff --git a/src/wamr_wasi_context.cpp b/src/wamr_wasi_context.cpp index 2a2ec08..105c19b 100644 --- a/src/wamr_wasi_context.cpp +++ b/src/wamr_wasi_context.cpp @@ -3,6 +3,7 @@ // #include "wamr_wasi_context.h" #include "wamr.h" +#include extern WAMRInstance *wamr; void WAMRWASIContext::dump_impl(WASIContext *env) { for (int i = 0; i < wamr->dir_.size(); i++) { @@ -20,6 +21,12 @@ void WAMRWASIContext::dump_impl(WASIContext *env) { } void WAMRWASIContext::restore_impl(WASIContext *env) { int r; + // std::string stdin_fd= "/dev/stdin"; + // wamr->invoke_fopen(stdin_fd, 0); + // std::string stdout_fd= "/dev/stdout"; + // wamr->invoke_fopen(stdout_fd, 0); + // std::string stderr_fd= "/dev/stderr"; + // wamr->invoke_fopen(stderr_fd, 0); for (auto [fd, res] : this->fd_map) { // differ from path from file LOGV(INFO) << "fd: " << fd << " path: " << std::get<0>(res) << " flags: " << std::get<1>(res) diff --git a/test/read-file.c b/test/read-file.c index 487dec9..484ce5b 100644 --- a/test/read-file.c +++ b/test/read-file.c @@ -65,6 +65,8 @@ int main() { size_t len2 = strlen(line2); fwrite(line1, sizeof(char), len1, file3); + //ntwritten + // checkpoint: lib_wasi_wrapper fwrite system record // volatile int c = 0;