diff --git a/lib/emscripten/src/syscalls/mod.rs b/lib/emscripten/src/syscalls/mod.rs index 645b48a81..37f6e2f51 100644 --- a/lib/emscripten/src/syscalls/mod.rs +++ b/lib/emscripten/src/syscalls/mod.rs @@ -418,24 +418,6 @@ pub fn ___syscall197(ctx: &mut Ctx, _which: c_int, mut varargs: VarArgs) -> c_in 0 } -/// lstat64 -pub fn ___syscall196(ctx: &mut Ctx, _which: i32, mut varargs: VarArgs) -> i32 { - debug!("emscripten::___syscall196 (lstat64) {}", _which); - let path_ptr: c_int = varargs.get(ctx); - let buf_ptr: u32 = varargs.get(ctx); - let path = emscripten_memory_pointer!(ctx.memory(0), path_ptr) as *const i8; - unsafe { - let mut stat: stat = std::mem::zeroed(); - let ret = lstat64(path, &mut stat as *mut stat as *mut c_void); - debug!("ret: {}", ret); - if ret != 0 { - return ret; - } - copy_stat_into_wasm(ctx, buf_ptr, &stat); - } - 0 -} - pub fn ___syscall220(_ctx: &mut Ctx, _one: i32, _two: i32) -> i32 { debug!("emscripten::___syscall220"); -1 diff --git a/lib/emscripten/src/syscalls/unix.rs b/lib/emscripten/src/syscalls/unix.rs index a4bac74c6..ad7f65909 100644 --- a/lib/emscripten/src/syscalls/unix.rs +++ b/lib/emscripten/src/syscalls/unix.rs @@ -57,6 +57,7 @@ use libc::{ sockaddr, socket, socklen_t, + stat, symlink, uid_t, uname, @@ -73,6 +74,7 @@ use libc::{ }; use wasmer_runtime_core::vm::Ctx; +use crate::utils; #[allow(unused_imports)] use std::io::Error; use std::mem; @@ -775,3 +777,21 @@ pub fn ___syscall324(ctx: &mut Ctx, _which: c_int, mut varargs: VarArgs) -> c_in unimplemented!() } } + +/// lstat64 +pub fn ___syscall196(ctx: &mut Ctx, _which: i32, mut varargs: VarArgs) -> i32 { + debug!("emscripten::___syscall196 (lstat64) {}", _which); + let path_ptr: c_int = varargs.get(ctx); + let buf_ptr: u32 = varargs.get(ctx); + let path = emscripten_memory_pointer!(ctx.memory(0), path_ptr) as *const i8; + unsafe { + let mut stat: stat = std::mem::zeroed(); + let ret = lstat64(path, &mut stat as *mut stat as *mut c_void); + debug!("ret: {}", ret); + if ret != 0 { + return ret; + } + utils::copy_stat_into_wasm(ctx, buf_ptr, &stat); + } + 0 +} diff --git a/lib/emscripten/src/utils.rs b/lib/emscripten/src/utils.rs index 5dcfd4e11..725f0ba94 100644 --- a/lib/emscripten/src/utils.rs +++ b/lib/emscripten/src/utils.rs @@ -125,7 +125,7 @@ pub struct GuestStat { st_atime: u64, st_mtime: u64, st_ctime: u64, - st_ino: u64, + st_ino: u32, } #[allow(clippy::cast_ptr_alignment)] diff --git a/lib/runtime-core/src/types.rs b/lib/runtime-core/src/types.rs index 96a99a835..966bd4e39 100644 --- a/lib/runtime-core/src/types.rs +++ b/lib/runtime-core/src/types.rs @@ -1,5 +1,5 @@ use crate::{memory::MemoryType, module::ModuleInfo, structures::TypedIndex, units::Pages}; -use std::{borrow::Cow, mem}; +use std::borrow::Cow; /// Represents a WebAssembly type. #[derive(Serialize, Deserialize, Debug, Clone, Copy, PartialEq, Eq, Hash)]