mirror of
https://github.com/fluencelabs/wasmer
synced 2025-06-18 03:11:21 +00:00
more emscripten stubs and urandom hack (#199)
This commit is contained in:
@ -28,7 +28,7 @@ use libc::{
|
||||
getpid,
|
||||
// iovec,
|
||||
lseek,
|
||||
open,
|
||||
// open,
|
||||
read,
|
||||
// readv,
|
||||
rmdir,
|
||||
@ -85,22 +85,6 @@ pub fn ___syscall4(ctx: &mut Ctx, which: c_int, mut varargs: VarArgs) -> c_int {
|
||||
unsafe { write(fd, buf_addr, count) as i32 }
|
||||
}
|
||||
|
||||
/// open
|
||||
pub fn ___syscall5(ctx: &mut Ctx, which: c_int, mut varargs: VarArgs) -> c_int {
|
||||
debug!("emscripten::___syscall5 (open) {}", which);
|
||||
let pathname: u32 = varargs.get(ctx);
|
||||
let flags: i32 = varargs.get(ctx);
|
||||
let mode: u32 = varargs.get(ctx);
|
||||
let pathname_addr = emscripten_memory_pointer!(ctx.memory(0), pathname) as *const i8;
|
||||
let path_str = unsafe { std::ffi::CStr::from_ptr(pathname_addr).to_str().unwrap() };
|
||||
let fd = unsafe { open(pathname_addr, flags, mode) };
|
||||
debug!(
|
||||
"=> pathname: {}, flags: {}, mode: {} = fd: {}\npath: {}",
|
||||
pathname, flags, mode, fd, path_str
|
||||
);
|
||||
fd
|
||||
}
|
||||
|
||||
/// close
|
||||
pub fn ___syscall6(ctx: &mut Ctx, which: c_int, mut varargs: VarArgs) -> c_int {
|
||||
debug!("emscripten::___syscall6 (close) {}", which);
|
||||
|
Reference in New Issue
Block a user