From d20aeb8365107fbda961dfdbc2b7bd8b45e73e73 Mon Sep 17 00:00:00 2001 From: YAMAMOTO Takashi Date: Wed, 28 Feb 2024 19:16:17 +0900 Subject: [PATCH] wasi: swap the directory order for --mapdir to match wasmtime --dir cf. https://github.com/bytecodealliance/wasmtime/pull/7301 --- cli/main.c | 2 +- libwasi/wasi.c | 11 +++++++---- 2 files changed, 8 insertions(+), 5 deletions(-) diff --git a/cli/main.c b/cli/main.c index 0d8b053f..e3ff45ce 100644 --- a/cli/main.c +++ b/cli/main.c @@ -222,7 +222,7 @@ static const char *opt_metavars[] = { #if defined(TOYWASM_ENABLE_WASI) [opt_wasi_env] = "NAME=VAR", [opt_wasi_dir] = "DIR", - [opt_wasi_mapdir] = "GUEST_DIR::HOST_DIR", + [opt_wasi_mapdir] = "HOST_DIR::GUEST_DIR", #endif #if defined(TOYWASM_ENABLE_WASI_LITTLEFS) [opt_wasi_mapdir_littlefs] = "LITTLEFS_IMAGE_PATH::LFS_DIR::GUEST_DIR", diff --git a/libwasi/wasi.c b/libwasi/wasi.c index ae822a87..013fb107 100644 --- a/libwasi/wasi.c +++ b/libwasi/wasi.c @@ -219,9 +219,12 @@ wasi_instance_prestat_add_vfs(struct wasi_instance *wasi, const char *path, if (is_mapdir) { /* - * :: + * :: * - * intended to be compatible with wasmtime's --mapdir + * intended to be compatible with wasmtime's --dir + * + * cf. + * https://github.com/bytecodealliance/wasmtime/pull/7301 */ const char *colon = strchr(path, ':'); @@ -229,8 +232,8 @@ wasi_instance_prestat_add_vfs(struct wasi_instance *wasi, const char *path, ret = EINVAL; goto fail; } - wasm_path = strndup(path, colon - path); - host_path = strdup(colon + 2); + host_path = strndup(path, colon - path); + wasm_path = strdup(colon + 2); } else { host_path = strdup(path); }