mirror of
https://github.com/fluencelabs/wasmer
synced 2025-06-20 04:06:30 +00:00
Merge remote-tracking branch 'origin/master' into feature/add-mapdir-for-emscripten
This commit is contained in:
@ -39,6 +39,7 @@ use libc::{
|
||||
// writev,
|
||||
stat,
|
||||
write,
|
||||
// readlink,
|
||||
};
|
||||
use wasmer_runtime_core::vm::Ctx;
|
||||
|
||||
@ -94,8 +95,7 @@ pub fn ___syscall6(ctx: &mut Ctx, _which: c_int, mut varargs: VarArgs) -> c_int
|
||||
// chdir
|
||||
pub fn ___syscall12(ctx: &mut Ctx, _which: c_int, mut varargs: VarArgs) -> c_int {
|
||||
debug!("emscripten::___syscall12 (chdir) {}", _which);
|
||||
let path_addr: i32 = varargs.get(ctx);
|
||||
let path_ptr = emscripten_memory_pointer!(ctx.memory(0), path_addr) as *const i8;
|
||||
let path_ptr = varargs.get_str(ctx);
|
||||
let real_path = get_cstr_path(ctx, path_ptr)
|
||||
.map(|cstr| cstr.as_c_str() as *const _ as *const i8)
|
||||
.unwrap_or(path_ptr);
|
||||
@ -127,10 +127,8 @@ pub fn ___syscall20(_ctx: &mut Ctx, _one: i32, _two: i32) -> i32 {
|
||||
// rename
|
||||
pub fn ___syscall38(ctx: &mut Ctx, _which: c_int, mut varargs: VarArgs) -> i32 {
|
||||
debug!("emscripten::___syscall38 (rename)");
|
||||
let old_path_addr: u32 = varargs.get(ctx);
|
||||
let new_path_addr: u32 = varargs.get(ctx);
|
||||
let old_path = emscripten_memory_pointer!(ctx.memory(0), old_path_addr) as *const i8;
|
||||
let new_path = emscripten_memory_pointer!(ctx.memory(0), new_path_addr) as *const i8;
|
||||
let old_path = varargs.get_str(ctx);
|
||||
let new_path = varargs.get_str(ctx);
|
||||
let real_old_path = get_cstr_path(ctx, old_path)
|
||||
.map(|cstr| cstr.as_c_str() as *const _ as *const i8)
|
||||
.unwrap_or(old_path);
|
||||
@ -150,8 +148,7 @@ pub fn ___syscall38(ctx: &mut Ctx, _which: c_int, mut varargs: VarArgs) -> i32 {
|
||||
// rmdir
|
||||
pub fn ___syscall40(ctx: &mut Ctx, _which: c_int, mut varargs: VarArgs) -> c_int {
|
||||
debug!("emscripten::___syscall40 (rmdir)");
|
||||
let pathname: u32 = varargs.get(ctx);
|
||||
let pathname_addr = emscripten_memory_pointer!(ctx.memory(0), pathname) as *const i8;
|
||||
let pathname_addr = varargs.get_str(ctx);
|
||||
let real_path = get_cstr_path(ctx, pathname_addr)
|
||||
.map(|cstr| cstr.as_c_str() as *const _ as *const i8)
|
||||
.unwrap_or(pathname_addr);
|
||||
@ -215,9 +212,32 @@ pub fn ___syscall75(_ctx: &mut Ctx, _one: i32, _two: i32) -> i32 {
|
||||
-1
|
||||
}
|
||||
|
||||
pub fn ___syscall85(_ctx: &mut Ctx, _one: i32, _two: i32) -> i32 {
|
||||
debug!("emscripten::___syscall85");
|
||||
-1
|
||||
// readlink
|
||||
pub fn ___syscall85(ctx: &mut Ctx, _which: c_int, mut varargs: VarArgs) -> i32 {
|
||||
debug!("emscripten::___syscall85 (readlink)");
|
||||
let _path = varargs.get_str(ctx);
|
||||
let buf = varargs.get_str(ctx);
|
||||
// let buf_addr: i32 = varargs.get(ctx);
|
||||
let buf_size: i32 = varargs.get(ctx);
|
||||
let fd = 3;
|
||||
let ret = unsafe { read(fd, buf as _, buf_size as _) as i32 };
|
||||
debug!(
|
||||
"=> buf: {}, buf_size: {}, return: {} ",
|
||||
unsafe { std::ffi::CStr::from_ptr(buf as _).to_str().unwrap() },
|
||||
buf_size,
|
||||
ret
|
||||
);
|
||||
// let ret = unsafe {
|
||||
// readlink(path, buf as _, buf_size as _) as i32
|
||||
// };
|
||||
// debug!("=> path: {}, buf: {}, buf_size: {}, return: {} ",
|
||||
// unsafe { std::ffi::CStr::from_ptr(path).to_str().unwrap() },
|
||||
// unsafe { std::ffi::CStr::from_ptr(buf as _).to_str().unwrap() },
|
||||
// // std::ffi::CStr::from_ptr(buf).to_str().unwrap(),
|
||||
// // buf,
|
||||
// buf_size,
|
||||
// ret);
|
||||
ret
|
||||
}
|
||||
|
||||
pub fn ___syscall91(_ctx: &mut Ctx, _one: i32, _two: i32) -> i32 {
|
||||
@ -410,10 +430,9 @@ pub fn ___syscall199(_ctx: &mut Ctx, _one: i32, _two: i32) -> i32 {
|
||||
// stat64
|
||||
pub fn ___syscall195(ctx: &mut Ctx, _which: c_int, mut varargs: VarArgs) -> c_int {
|
||||
debug!("emscripten::___syscall195 (stat64) {}", _which);
|
||||
let pathname: u32 = varargs.get(ctx);
|
||||
let pathname_addr = varargs.get_str(ctx);
|
||||
let buf: u32 = varargs.get(ctx);
|
||||
|
||||
let pathname_addr = emscripten_memory_pointer!(ctx.memory(0), pathname) as *const i8;
|
||||
let real_path = get_cstr_path(ctx, pathname_addr)
|
||||
.map(|cstr| cstr.as_c_str() as *const _ as *const i8)
|
||||
.unwrap_or(pathname_addr);
|
||||
@ -422,10 +441,9 @@ pub fn ___syscall195(ctx: &mut Ctx, _which: c_int, mut varargs: VarArgs) -> c_in
|
||||
let mut _stat: stat = std::mem::zeroed();
|
||||
let ret = stat(real_path, &mut _stat);
|
||||
debug!(
|
||||
"=> pathname: {}, buf: {}, path: {} = {}\nlast os error: {}",
|
||||
pathname,
|
||||
"=> pathname: {}, buf: {} = {}, last os error: {}",
|
||||
std::ffi::CStr::from_ptr(pathname_addr).to_str().unwrap(),
|
||||
buf,
|
||||
std::ffi::CStr::from_ptr(real_path).to_str().unwrap(),
|
||||
ret,
|
||||
Error::last_os_error()
|
||||
);
|
||||
|
Reference in New Issue
Block a user