mirror of
https://github.com/fluencelabs/wasmer
synced 2024-12-12 22:05:33 +00:00
Trying to fix ___syscall220
This commit is contained in:
parent
6ce4f5dca4
commit
109acd2fa3
@ -76,6 +76,8 @@ lazy_static! {
|
||||
const GLOBAL_BASE: u32 = 1024;
|
||||
const STATIC_BASE: u32 = GLOBAL_BASE;
|
||||
|
||||
use ::libc::DIR as libcDIR;
|
||||
|
||||
pub struct EmscriptenData<'a> {
|
||||
pub malloc: Func<'a, u32, u32>,
|
||||
pub free: Func<'a, u32>,
|
||||
@ -83,6 +85,7 @@ pub struct EmscriptenData<'a> {
|
||||
pub memset: Func<'a, (u32, u32, u32), u32>,
|
||||
pub stack_alloc: Func<'a, u32, u32>,
|
||||
pub jumps: Vec<UnsafeCell<[u32; 27]>>,
|
||||
pub opened_dirs: HashMap<i32, Box<*mut libcDIR>>,
|
||||
|
||||
pub dyn_call_i: Option<Func<'a, i32, i32>>,
|
||||
pub dyn_call_ii: Option<Func<'a, (i32, i32), i32>>,
|
||||
@ -224,6 +227,8 @@ impl<'a> EmscriptenData<'a> {
|
||||
memset,
|
||||
stack_alloc,
|
||||
jumps: Vec::new(),
|
||||
opened_dirs: HashMap::new(),
|
||||
|
||||
dyn_call_i,
|
||||
dyn_call_ii,
|
||||
dyn_call_iii,
|
||||
|
@ -851,19 +851,25 @@ pub fn ___syscall196(ctx: &mut Ctx, _which: i32, mut varargs: VarArgs) -> i32 {
|
||||
// dirent structure is
|
||||
// i64, i64, u16 (280), i8, [i8; 256]
|
||||
pub fn ___syscall220(ctx: &mut Ctx, _which: i32, mut varargs: VarArgs) -> i32 {
|
||||
debug!("emscripten::___syscall220");
|
||||
use super::super::env::get_emscripten_data;
|
||||
|
||||
let fd: i32 = varargs.get(ctx);
|
||||
let dirp_addr: i32 = varargs.get(ctx);
|
||||
let count: u32 = varargs.get(ctx);
|
||||
debug!("emscripten::___syscall220 (getdents) {} {} {}", fd, dirp_addr, count);
|
||||
|
||||
let dirp = emscripten_memory_pointer!(ctx.memory(0), dirp_addr) as *mut u8;
|
||||
|
||||
let mut opened_dirs = &mut get_emscripten_data(ctx).opened_dirs;
|
||||
|
||||
// need to persist stream across calls?
|
||||
let dir: *mut libc::DIR = unsafe { libc::fdopendir(fd) };
|
||||
// let dir: *mut libc::DIR = unsafe { libc::fdopendir(fd) };
|
||||
let mut dir = &*opened_dirs.entry(fd).or_insert_with(|| unsafe { Box::new(libc::fdopendir(fd)) });
|
||||
|
||||
let mut pos = 0;
|
||||
let offset = 280;
|
||||
while pos + offset <= count as usize {
|
||||
let dirent = unsafe { readdir(dir) };
|
||||
let dirent = unsafe { readdir(**dir) };
|
||||
if dirent.is_null() {
|
||||
break;
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user