move unix code to unix only location

This commit is contained in:
Mark McCaskey
2019-07-01 16:50:55 -07:00
parent 623bec001f
commit a4171892ea
3 changed files with 36 additions and 39 deletions

View File

@ -276,44 +276,6 @@ pub fn ___syscall75(_ctx: &mut Ctx, _one: i32, _two: i32) -> i32 {
-1
}
// readlink
pub fn ___syscall85(ctx: &mut Ctx, _which: c_int, mut varargs: VarArgs) -> i32 {
debug!("emscripten::___syscall85 (readlink)");
let pathname_addr = 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 real_path_owned = get_cstr_path(ctx, pathname_addr);
let real_path = if let Some(ref rp) = real_path_owned {
rp.as_c_str().as_ptr()
} else {
pathname_addr
};
// 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 { libc::readlink(real_path, buf as _, buf_size as _) as i32 };
if ret == -1 {
debug!("readlink failed");
return ret;
}
debug!(
"=> path: {}, buf: {}, buf_size: {}, return: {} ",
unsafe { std::ffi::CStr::from_ptr(real_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 {
debug!("emscripten::___syscall91 - stub");
0