mirror of
https://github.com/fluencelabs/wasmer
synced 2025-06-22 13:11:32 +00:00
move unix code to unix only location
This commit is contained in:
@ -276,44 +276,6 @@ pub fn ___syscall75(_ctx: &mut Ctx, _one: i32, _two: i32) -> i32 {
|
|||||||
-1
|
-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 {
|
pub fn ___syscall91(_ctx: &mut Ctx, _one: i32, _two: i32) -> i32 {
|
||||||
debug!("emscripten::___syscall91 - stub");
|
debug!("emscripten::___syscall91 - stub");
|
||||||
0
|
0
|
||||||
|
@ -80,7 +80,7 @@ use std::ffi::CStr;
|
|||||||
use wasmer_runtime_core::{memory::ptr::WasmPtr, vm::Ctx};
|
use wasmer_runtime_core::{memory::ptr::WasmPtr, vm::Ctx};
|
||||||
|
|
||||||
use crate::env::EmSockAddr;
|
use crate::env::EmSockAddr;
|
||||||
use crate::utils;
|
use crate::utils::{self, get_cstr_path};
|
||||||
#[allow(unused_imports)]
|
#[allow(unused_imports)]
|
||||||
use std::io::Error;
|
use std::io::Error;
|
||||||
use std::mem;
|
use std::mem;
|
||||||
@ -187,6 +187,35 @@ pub fn ___syscall83(ctx: &mut Ctx, _which: c_int, mut varargs: VarArgs) -> c_int
|
|||||||
result
|
result
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// 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 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() },
|
||||||
|
buf_size,
|
||||||
|
ret
|
||||||
|
);
|
||||||
|
ret
|
||||||
|
}
|
||||||
|
|
||||||
/// ftruncate64
|
/// ftruncate64
|
||||||
pub fn ___syscall194(ctx: &mut Ctx, _which: c_int, mut varargs: VarArgs) -> c_int {
|
pub fn ___syscall194(ctx: &mut Ctx, _which: c_int, mut varargs: VarArgs) -> c_int {
|
||||||
debug!("emscripten::___syscall194 (ftruncate64) {}", _which);
|
debug!("emscripten::___syscall194 (ftruncate64) {}", _which);
|
||||||
|
@ -128,6 +128,12 @@ pub fn ___syscall83(_ctx: &mut Ctx, _which: c_int, _varargs: VarArgs) -> c_int {
|
|||||||
unimplemented!()
|
unimplemented!()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// readlink
|
||||||
|
pub fn ___syscall85(_ctx: &mut Ctx, _which: c_int, _varargs: VarArgs) -> c_int {
|
||||||
|
debug!("emscripten::___syscall85 (readlink) {}", _which);
|
||||||
|
-1
|
||||||
|
}
|
||||||
|
|
||||||
/// lchown
|
/// lchown
|
||||||
pub fn ___syscall198(_ctx: &mut Ctx, _which: c_int, _varargs: VarArgs) -> c_int {
|
pub fn ___syscall198(_ctx: &mut Ctx, _which: c_int, _varargs: VarArgs) -> c_int {
|
||||||
debug!("emscripten::___syscall198 (lchown) {}", _which);
|
debug!("emscripten::___syscall198 (lchown) {}", _which);
|
||||||
|
Reference in New Issue
Block a user