diff --git a/lib/emscripten/src/syscalls/unix/mod.rs b/lib/emscripten/src/syscalls/unix/mod.rs index 92aecfbae..f23133b1b 100644 --- a/lib/emscripten/src/syscalls/unix/mod.rs +++ b/lib/emscripten/src/syscalls/unix/mod.rs @@ -14,7 +14,7 @@ pub use vfs::*; /// NOTE: TODO: These syscalls only support wasm_32 for now because they assume offsets are u32 /// Syscall list: https://www.cs.utexas.edu/~bismith/test/syscalls/syscalls32.html -use libc::{c_int, dup2, fcntl, pid_t, rusage, setpgid, uname, utsname, EINVAL, F_GETFD, F_SETFD}; +use libc::{c_int, pid_t, rusage, setpgid, uname, utsname}; use wasmer_runtime_core::vm::Ctx; // Linking to functions that are not provided by rust libc @@ -103,37 +103,3 @@ pub fn ___syscall212(ctx: &mut Ctx, _which: c_int, mut varargs: VarArgs) -> c_in unsafe { libc::chown(pathname_addr, owner, group) } } - -/// dup3 -pub fn ___syscall330(ctx: &mut Ctx, _which: c_int, mut varargs: VarArgs) -> pid_t { - // Implementation based on description at https://linux.die.net/man/2/dup3 - debug!("emscripten::___syscall330 (dup3)"); - let oldfd: c_int = varargs.get(ctx); - let newfd: c_int = varargs.get(ctx); - let flags: c_int = varargs.get(ctx); - - if oldfd == newfd { - return EINVAL; - } - - let res = unsafe { dup2(oldfd, newfd) }; - - // Set flags on newfd (https://www.gnu.org/software/libc/manual/html_node/Descriptor-Flags.html) - let mut old_flags = unsafe { fcntl(newfd, F_GETFD, 0) }; - - if old_flags > 0 { - old_flags |= flags; - } else if old_flags == 0 { - old_flags &= !flags; - } - - unsafe { - fcntl(newfd, F_SETFD, old_flags); - } - - debug!( - "=> oldfd: {}, newfd: {}, flags: {} = pid: {}", - oldfd, newfd, flags, res - ); - res -} diff --git a/lib/emscripten/src/syscalls/unix/vfs.rs b/lib/emscripten/src/syscalls/unix/vfs.rs index 39f8ad025..3585885ce 100644 --- a/lib/emscripten/src/syscalls/unix/vfs.rs +++ b/lib/emscripten/src/syscalls/unix/vfs.rs @@ -114,7 +114,7 @@ pub fn ___syscall15(_ctx: &mut Ctx, _one: i32, _two: i32) -> i32 { 0 } -// mkdir +/// mkdir pub fn ___syscall39(ctx: &mut Ctx, _which: c_int, mut varargs: VarArgs) -> c_int { debug!("emscripten::___syscall39 (mkdir vfs) {}", _which); let pathname: u32 = varargs.get(ctx); @@ -132,7 +132,6 @@ pub fn ___syscall39(ctx: &mut Ctx, _which: c_int, mut varargs: VarArgs) -> c_int } else { -1 }; - // debug!("mkdir returns {}", ret); ret }