fix bug in stat, move lstat64 back to unix

This commit is contained in:
Mark McCaskey 2019-04-08 11:26:25 -07:00
parent 09a207364b
commit b3a765446a
4 changed files with 22 additions and 20 deletions

View File

@ -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

View File

@ -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
}

View File

@ -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)]

View File

@ -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)]