Improved ioctl calls

This commit is contained in:
Syrus
2019-05-05 12:31:31 -07:00
parent 3093e65bc1
commit 789af39f9e

View File

@ -355,41 +355,46 @@ pub fn ___syscall54(ctx: &mut Ctx, _which: c_int, mut varargs: VarArgs) -> c_int
debug!("emscripten::___syscall54 (ioctl) {}", _which); debug!("emscripten::___syscall54 (ioctl) {}", _which);
let fd: i32 = varargs.get(ctx); let fd: i32 = varargs.get(ctx);
let request: u32 = varargs.get(ctx); let request: u32 = varargs.get(ctx);
debug!("fd: {}, op: {}", fd, request); debug!("=> fd: {}, op: {}", fd, request);
// Got the equivalents here: https://code.woboq.org/linux/linux/include/uapi/asm-generic/ioctls.h.html // Got the equivalents here: https://code.woboq.org/linux/linux/include/uapi/asm-generic/ioctls.h.html
match request as _ { let argp: u32 = varargs.get(ctx);
21537 => { let argp_ptr = emscripten_memory_pointer!(ctx.memory(0), argp) as *mut c_void;
// FIONBIO let ret = unsafe { ioctl(fd, request as _, argp_ptr) };
let argp: u32 = varargs.get(ctx); debug!("=> {}", ret);
let argp_ptr = emscripten_memory_pointer!(ctx.memory(0), argp) as *mut c_void; ret
let ret = unsafe { ioctl(fd, FIONBIO, argp_ptr) }; // match request as _ {
debug!("ret(FIONBIO): {}", ret); // 21537 => {
ret // // FIONBIO
// 0 // let argp: u32 = varargs.get(ctx);
} // let argp_ptr = emscripten_memory_pointer!(ctx.memory(0), argp) as *mut c_void;
21523 => { // let ret = unsafe { ioctl(fd, FIONBIO, argp_ptr) };
// TIOCGWINSZ // debug!("ret(FIONBIO): {}", ret);
let argp: u32 = varargs.get(ctx); // ret
let argp_ptr = emscripten_memory_pointer!(ctx.memory(0), argp) as *mut c_void; // // 0
let ret = unsafe { ioctl(fd, TIOCGWINSZ, argp_ptr) }; // }
debug!("ret(TIOCGWINSZ): {} (harcoded to 0)", ret); // 21523 => {
// ret // // TIOCGWINSZ
// TODO: We hardcode the value to have emscripten tests pass, as for some reason // let argp: u32 = varargs.get(ctx);
// when the capturer is active, ioctl returns -1 instead of 0 // let argp_ptr = emscripten_memory_pointer!(ctx.memory(0), argp) as *mut c_void;
if ret == -1 { // let ret = unsafe { ioctl(fd, TIOCGWINSZ, argp_ptr) };
0 // debug!("ret(TIOCGWINSZ): {} (harcoded to 0)", ret);
} else { // // ret
ret // // TODO: We hardcode the value to have emscripten tests pass, as for some reason
} // // when the capturer is active, ioctl returns -1 instead of 0
} // if ret == -1 {
_ => { // 0
debug!( // } else {
"emscripten::___syscall54 -> non implemented case {}", // ret
request // }
); // }
0 // _ => {
} // debug!(
} // "emscripten::___syscall54 -> non implemented case {}",
// request
// );
// 0
// }
// }
} }
// socketcall // socketcall