diff --git a/AK/Debug.h.in b/AK/Debug.h.in index 3e9bbb5ce5..9c4525767f 100644 --- a/AK/Debug.h.in +++ b/AK/Debug.h.in @@ -478,6 +478,10 @@ # cmakedefine01 WASI_DEBUG #endif +#ifndef WASI_FINE_GRAINED_DEBUG +# cmakedefine01 WASI_FINE_GRAINED_DEBUG +#endif + #ifndef WASM_BINPARSER_DEBUG # cmakedefine01 WASM_BINPARSER_DEBUG #endif diff --git a/Meta/CMake/all_the_debug_macros.cmake b/Meta/CMake/all_the_debug_macros.cmake index ee82e3a84d..8e986fe121 100644 --- a/Meta/CMake/all_the_debug_macros.cmake +++ b/Meta/CMake/all_the_debug_macros.cmake @@ -197,6 +197,7 @@ set(VPX_DEBUG ON) set(WAITBLOCK_DEBUG ON) set(WAITQUEUE_DEBUG ON) set(WASI_DEBUG ON) +set(WASI_FINE_GRAINED_DEBUG ON) set(WASM_BINPARSER_DEBUG ON) set(WASM_TRACE_DEBUG ON) set(WASM_VALIDATOR_DEBUG ON) diff --git a/Userland/Libraries/LibWasm/WASI/Wasi.cpp b/Userland/Libraries/LibWasm/WASI/Wasi.cpp index b2e145a6de..68a2ac9684 100644 --- a/Userland/Libraries/LibWasm/WASI/Wasi.cpp +++ b/Userland/Libraries/LibWasm/WASI/Wasi.cpp @@ -636,12 +636,16 @@ ErrorOr> Implementation::impl$path_open(Configuration& configuration, auto path_data = TRY(slice_typed_memory(configuration, path, path_len)); auto path_string = DeprecatedString::copy(path_data); + dbgln_if(WASI_FINE_GRAINED_DEBUG, "path_open: dir_fd={}, path={}, open_flags={}", dir_fd, path_string, open_flags); + int opened_fd = openat(dir_fd, path_string.characters(), open_flags, 0644); if (opened_fd < 0) return errno_value_from_errno(errno); // FIXME: Implement Rights and RightsInheriting. + m_fd_map.insert(opened_fd, static_cast(opened_fd)); + return FD(opened_fd); }