Files
wasmer/lib/emscripten/src/syscalls/mod.rs

735 lines
20 KiB
Rust
Raw Normal View History

#[cfg(unix)]
mod unix;
#[cfg(windows)]
mod windows;
#[cfg(unix)]
pub use self::unix::*;
#[cfg(windows)]
pub use self::windows::*;
use crate::utils::{copy_stat_into_wasm, get_cstr_path, get_current_directory};
use super::varargs::VarArgs;
use byteorder::{ByteOrder, LittleEndian};
/// 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,
c_void,
chdir,
Squashed commit of the following: commit 62d9da4e3e02251a0f61c904e826bc06cf964ff7 Author: Syrus <me@syrusakbary.com> Date: Sun Jul 7 18:16:34 2019 -0700 Fixed syscall221 commit a8fde9148d50d89616d8a85a68110b89e3273229 Author: Syrus <me@syrusakbary.com> Date: Sun Jul 7 18:16:04 2019 -0700 Improved ioctl use case commit 5ad109d39838624ad84232a4c17714b885835893 Merge: 61526e2c 5cab8161 Author: Syrus <me@syrusakbary.com> Date: Sun Jul 7 17:44:25 2019 -0700 Merge branch 'command/dash' into feature/emscripten-update commit 5cab816193d47d53aabb4be4ccaf448dca5ed0b2 Author: Jesús Leganés-Combarro 'piranna <piranna@gmail.com> Date: Sat Jul 6 20:11:49 2019 +0200 Generic IOCTLs mapping commit 5a0dc0374cdc5a3754e3ecc82584288df640d239 Merge: 61cfed79 9d120ed3 Author: Jesús Leganés-Combarro 'piranna <piranna@gmail.com> Date: Sat Jul 6 17:15:02 2019 +0200 Merge remote-tracking branch 'origin/master' into command/dash commit 61cfed7916078602eabbd4448b109f47dcfff1e8 Author: Jesús Leganés-Combarro 'piranna <piranna@gmail.com> Date: Sat Jul 6 13:04:04 2019 +0200 Fixed implementation for syscalls 200, 201 and 202 commit 91e26d1a0ee46d6f9ec4804ca13ca928d55e7bbb Author: Jesús Leganés-Combarro 'piranna <piranna@gmail.com> Date: Sat Jul 6 13:03:26 2019 +0200 Improved debug messages commit 53a8fbeb2a0912e928609f0afcea6ffb1e911193 Author: Jesús Leganés-Combarro 'piranna <piranna@gmail.com> Date: Sat Jul 6 13:03:04 2019 +0200 [___syscall146] Move loop out of `unsafe` zone commit d6dd3696f10f4cbb0722321bd9d06e45a9d464ac Author: Jesús Leganés-Combarro 'piranna <piranna@gmail.com> Date: Sat Jul 6 13:01:31 2019 +0200 [___syscall140] Fixed types commit c827a6a99346535764e22bfb5ab9147a52a0a543 Merge: 2bc16826 5e18d04d Author: Jesús Leganés-Combarro 'piranna <piranna@gmail.com> Date: Sat Jul 6 12:21:33 2019 +0200 Merge remote-tracking branch 'origin/master' into command/dash commit 2bc16826b5923dba56243fe3bd99f4be8a09c990 Author: Jesús Leganés-Combarro 'piranna <piranna@gmail.com> Date: Thu Jul 4 07:05:00 2019 +0200 Implement `getpgid` syscall commit d464954f5803e4d84b6f94dc9ef87cc577aa9c65 Author: Jesús Leganés-Combarro 'piranna <piranna@gmail.com> Date: Thu Jul 4 07:04:36 2019 +0200 [fcntl64] Replace mock for real implementation commit 3fe0183d853624bcdc968a890ac36ff7062905a7 Author: Jesús Leganés-Combarro 'piranna <piranna@gmail.com> Date: Thu Jul 4 07:03:39 2019 +0200 [ioctl] No-of for `TIOCSPGRP` command & code clean-up commit cc83ec9ac1cf1ad60748fd3bb5114a6e6e471d92 Author: Jesús Leganés-Combarro 'piranna <piranna@gmail.com> Date: Thu Jul 4 07:02:47 2019 +0200 [___syscall5] debug messages commit 91587c8bde9d2b02402a7843f37eee22322d86fb Author: Jesús Leganés-Combarro 'piranna <piranna@gmail.com> Date: Thu Jul 4 07:02:20 2019 +0200 [___syscall57] debug messages
2019-07-07 19:35:09 -07:00
// setsockopt, getppid
close,
dup2,
exit,
fstat,
getpid,
2019-06-13 20:46:05 +02:00
// readlink,
// iovec,
lseek,
// open,
read,
2019-05-05 12:09:55 -07:00
rename,
// sockaddr_in,
// readv,
rmdir,
// writev,
stat,
write,
Squashed commit of the following: commit 62d9da4e3e02251a0f61c904e826bc06cf964ff7 Author: Syrus <me@syrusakbary.com> Date: Sun Jul 7 18:16:34 2019 -0700 Fixed syscall221 commit a8fde9148d50d89616d8a85a68110b89e3273229 Author: Syrus <me@syrusakbary.com> Date: Sun Jul 7 18:16:04 2019 -0700 Improved ioctl use case commit 5ad109d39838624ad84232a4c17714b885835893 Merge: 61526e2c 5cab8161 Author: Syrus <me@syrusakbary.com> Date: Sun Jul 7 17:44:25 2019 -0700 Merge branch 'command/dash' into feature/emscripten-update commit 5cab816193d47d53aabb4be4ccaf448dca5ed0b2 Author: Jesús Leganés-Combarro 'piranna <piranna@gmail.com> Date: Sat Jul 6 20:11:49 2019 +0200 Generic IOCTLs mapping commit 5a0dc0374cdc5a3754e3ecc82584288df640d239 Merge: 61cfed79 9d120ed3 Author: Jesús Leganés-Combarro 'piranna <piranna@gmail.com> Date: Sat Jul 6 17:15:02 2019 +0200 Merge remote-tracking branch 'origin/master' into command/dash commit 61cfed7916078602eabbd4448b109f47dcfff1e8 Author: Jesús Leganés-Combarro 'piranna <piranna@gmail.com> Date: Sat Jul 6 13:04:04 2019 +0200 Fixed implementation for syscalls 200, 201 and 202 commit 91e26d1a0ee46d6f9ec4804ca13ca928d55e7bbb Author: Jesús Leganés-Combarro 'piranna <piranna@gmail.com> Date: Sat Jul 6 13:03:26 2019 +0200 Improved debug messages commit 53a8fbeb2a0912e928609f0afcea6ffb1e911193 Author: Jesús Leganés-Combarro 'piranna <piranna@gmail.com> Date: Sat Jul 6 13:03:04 2019 +0200 [___syscall146] Move loop out of `unsafe` zone commit d6dd3696f10f4cbb0722321bd9d06e45a9d464ac Author: Jesús Leganés-Combarro 'piranna <piranna@gmail.com> Date: Sat Jul 6 13:01:31 2019 +0200 [___syscall140] Fixed types commit c827a6a99346535764e22bfb5ab9147a52a0a543 Merge: 2bc16826 5e18d04d Author: Jesús Leganés-Combarro 'piranna <piranna@gmail.com> Date: Sat Jul 6 12:21:33 2019 +0200 Merge remote-tracking branch 'origin/master' into command/dash commit 2bc16826b5923dba56243fe3bd99f4be8a09c990 Author: Jesús Leganés-Combarro 'piranna <piranna@gmail.com> Date: Thu Jul 4 07:05:00 2019 +0200 Implement `getpgid` syscall commit d464954f5803e4d84b6f94dc9ef87cc577aa9c65 Author: Jesús Leganés-Combarro 'piranna <piranna@gmail.com> Date: Thu Jul 4 07:04:36 2019 +0200 [fcntl64] Replace mock for real implementation commit 3fe0183d853624bcdc968a890ac36ff7062905a7 Author: Jesús Leganés-Combarro 'piranna <piranna@gmail.com> Date: Thu Jul 4 07:03:39 2019 +0200 [ioctl] No-of for `TIOCSPGRP` command & code clean-up commit cc83ec9ac1cf1ad60748fd3bb5114a6e6e471d92 Author: Jesús Leganés-Combarro 'piranna <piranna@gmail.com> Date: Thu Jul 4 07:02:47 2019 +0200 [___syscall5] debug messages commit 91587c8bde9d2b02402a7843f37eee22322d86fb Author: Jesús Leganés-Combarro 'piranna <piranna@gmail.com> Date: Thu Jul 4 07:02:20 2019 +0200 [___syscall57] debug messages
2019-07-07 19:35:09 -07:00
// ENOTTY,
};
use wasmer_runtime_core::{
memory::ptr::{Array, WasmPtr},
vm::Ctx,
};
use super::env;
2019-03-01 10:54:39 -08:00
use std::cell::Cell;
2019-03-25 16:13:41 -07:00
#[allow(unused_imports)]
use std::io::Error;
use std::slice;
/// exit
fix(emscripten) Various warning fixes and cleanups (#266) * fix(emscripten) Remove unused imports. This patch removes unused imports reported by `rustc` as warnings. * fix(emscripten) Allow unreachable patterns in `_clock_gettime`. The compiler thinks `CLOCK_MONOTONIC_COARSE` is unreachable, which is not always the case. Add an attribute to allow unreachable patterns to remove the warning. * fix(emscripten) Rename unused variables. This patch renames various unused variables by appending an underscore to them. * fix(emscripten) Declare `table` as immutable. The `table` variable in `EmscriptenGlobals::new` was declared as mutable, but it's never mutated. * fix(emscripten) Remove an unnecessary `unsafe` block. * fix(emscripten) Remove duplicate definition of `SO_NOSIGPIPE`. The `SO_NOSIGPIPE` constant is defined in `syscalls/mod.rs` and `syscalls/unix.rs`. It's never used in the first case. We can safely remove it in this file, and keep it in `unix.rs`. * fix(emscripten) `read_string_from_wasm` is used only on Windows. Mark `read_string_from_wasm` as possible deadcode, since it's used only on Windows. * fix(emscripten) Remove `DYNAMICTOP_PTR_DIFF`, `stacktop`, `stack_max`, `dynamic_base` and `dynamic_ptr`. Four functions and one constant are used together but never used inside or outside this file. They are deadcode. * fix(emscripten) Remove `infinity` and `nan` fields of `EmscriptenGlobalsData`. Those fields are never used. * fix(emscripten) Allow non snake case in `emscripten_target.rs`. Many functions in this file don't follow the snake case style for Rust function names. The reason is that we want the names to match the emscripten symbol names; even if a mapping is done in `lib.rs`, it's easier to get the same names. * fix(emscripten) Rename `STATIC_TOP` to `static_top`. This variable is not a constant.
2019-03-12 22:00:33 +01:00
pub fn ___syscall1(ctx: &mut Ctx, _which: c_int, mut varargs: VarArgs) {
debug!("emscripten::___syscall1 (exit) {}", _which);
let status: i32 = varargs.get(ctx);
unsafe {
exit(status);
}
}
/// read
fix(emscripten) Various warning fixes and cleanups (#266) * fix(emscripten) Remove unused imports. This patch removes unused imports reported by `rustc` as warnings. * fix(emscripten) Allow unreachable patterns in `_clock_gettime`. The compiler thinks `CLOCK_MONOTONIC_COARSE` is unreachable, which is not always the case. Add an attribute to allow unreachable patterns to remove the warning. * fix(emscripten) Rename unused variables. This patch renames various unused variables by appending an underscore to them. * fix(emscripten) Declare `table` as immutable. The `table` variable in `EmscriptenGlobals::new` was declared as mutable, but it's never mutated. * fix(emscripten) Remove an unnecessary `unsafe` block. * fix(emscripten) Remove duplicate definition of `SO_NOSIGPIPE`. The `SO_NOSIGPIPE` constant is defined in `syscalls/mod.rs` and `syscalls/unix.rs`. It's never used in the first case. We can safely remove it in this file, and keep it in `unix.rs`. * fix(emscripten) `read_string_from_wasm` is used only on Windows. Mark `read_string_from_wasm` as possible deadcode, since it's used only on Windows. * fix(emscripten) Remove `DYNAMICTOP_PTR_DIFF`, `stacktop`, `stack_max`, `dynamic_base` and `dynamic_ptr`. Four functions and one constant are used together but never used inside or outside this file. They are deadcode. * fix(emscripten) Remove `infinity` and `nan` fields of `EmscriptenGlobalsData`. Those fields are never used. * fix(emscripten) Allow non snake case in `emscripten_target.rs`. Many functions in this file don't follow the snake case style for Rust function names. The reason is that we want the names to match the emscripten symbol names; even if a mapping is done in `lib.rs`, it's easier to get the same names. * fix(emscripten) Rename `STATIC_TOP` to `static_top`. This variable is not a constant.
2019-03-12 22:00:33 +01:00
pub fn ___syscall3(ctx: &mut Ctx, _which: i32, mut varargs: VarArgs) -> i32 {
// -> ssize_t
fix(emscripten) Various warning fixes and cleanups (#266) * fix(emscripten) Remove unused imports. This patch removes unused imports reported by `rustc` as warnings. * fix(emscripten) Allow unreachable patterns in `_clock_gettime`. The compiler thinks `CLOCK_MONOTONIC_COARSE` is unreachable, which is not always the case. Add an attribute to allow unreachable patterns to remove the warning. * fix(emscripten) Rename unused variables. This patch renames various unused variables by appending an underscore to them. * fix(emscripten) Declare `table` as immutable. The `table` variable in `EmscriptenGlobals::new` was declared as mutable, but it's never mutated. * fix(emscripten) Remove an unnecessary `unsafe` block. * fix(emscripten) Remove duplicate definition of `SO_NOSIGPIPE`. The `SO_NOSIGPIPE` constant is defined in `syscalls/mod.rs` and `syscalls/unix.rs`. It's never used in the first case. We can safely remove it in this file, and keep it in `unix.rs`. * fix(emscripten) `read_string_from_wasm` is used only on Windows. Mark `read_string_from_wasm` as possible deadcode, since it's used only on Windows. * fix(emscripten) Remove `DYNAMICTOP_PTR_DIFF`, `stacktop`, `stack_max`, `dynamic_base` and `dynamic_ptr`. Four functions and one constant are used together but never used inside or outside this file. They are deadcode. * fix(emscripten) Remove `infinity` and `nan` fields of `EmscriptenGlobalsData`. Those fields are never used. * fix(emscripten) Allow non snake case in `emscripten_target.rs`. Many functions in this file don't follow the snake case style for Rust function names. The reason is that we want the names to match the emscripten symbol names; even if a mapping is done in `lib.rs`, it's easier to get the same names. * fix(emscripten) Rename `STATIC_TOP` to `static_top`. This variable is not a constant.
2019-03-12 22:00:33 +01:00
debug!("emscripten::___syscall3 (read) {}", _which);
let fd: i32 = varargs.get(ctx);
let buf: u32 = varargs.get(ctx);
let count: i32 = varargs.get(ctx);
debug!("=> fd: {}, buf_offset: {}, count: {}", fd, buf, count);
let buf_addr = emscripten_memory_pointer!(ctx.memory(0), buf) as *mut c_void;
let ret = unsafe { read(fd, buf_addr, count as _) };
debug!("=> ret: {}", ret);
ret as _
}
/// write
fix(emscripten) Various warning fixes and cleanups (#266) * fix(emscripten) Remove unused imports. This patch removes unused imports reported by `rustc` as warnings. * fix(emscripten) Allow unreachable patterns in `_clock_gettime`. The compiler thinks `CLOCK_MONOTONIC_COARSE` is unreachable, which is not always the case. Add an attribute to allow unreachable patterns to remove the warning. * fix(emscripten) Rename unused variables. This patch renames various unused variables by appending an underscore to them. * fix(emscripten) Declare `table` as immutable. The `table` variable in `EmscriptenGlobals::new` was declared as mutable, but it's never mutated. * fix(emscripten) Remove an unnecessary `unsafe` block. * fix(emscripten) Remove duplicate definition of `SO_NOSIGPIPE`. The `SO_NOSIGPIPE` constant is defined in `syscalls/mod.rs` and `syscalls/unix.rs`. It's never used in the first case. We can safely remove it in this file, and keep it in `unix.rs`. * fix(emscripten) `read_string_from_wasm` is used only on Windows. Mark `read_string_from_wasm` as possible deadcode, since it's used only on Windows. * fix(emscripten) Remove `DYNAMICTOP_PTR_DIFF`, `stacktop`, `stack_max`, `dynamic_base` and `dynamic_ptr`. Four functions and one constant are used together but never used inside or outside this file. They are deadcode. * fix(emscripten) Remove `infinity` and `nan` fields of `EmscriptenGlobalsData`. Those fields are never used. * fix(emscripten) Allow non snake case in `emscripten_target.rs`. Many functions in this file don't follow the snake case style for Rust function names. The reason is that we want the names to match the emscripten symbol names; even if a mapping is done in `lib.rs`, it's easier to get the same names. * fix(emscripten) Rename `STATIC_TOP` to `static_top`. This variable is not a constant.
2019-03-12 22:00:33 +01:00
pub fn ___syscall4(ctx: &mut Ctx, _which: c_int, mut varargs: VarArgs) -> c_int {
debug!("emscripten::___syscall4 (write) {}", _which);
let fd: i32 = varargs.get(ctx);
let buf: i32 = varargs.get(ctx);
let count: i32 = varargs.get(ctx);
debug!("=> fd: {}, buf: {}, count: {}", fd, buf, count);
let buf_addr = emscripten_memory_pointer!(ctx.memory(0), buf) as *const c_void;
unsafe { write(fd, buf_addr, count as _) as i32 }
}
/// close
fix(emscripten) Various warning fixes and cleanups (#266) * fix(emscripten) Remove unused imports. This patch removes unused imports reported by `rustc` as warnings. * fix(emscripten) Allow unreachable patterns in `_clock_gettime`. The compiler thinks `CLOCK_MONOTONIC_COARSE` is unreachable, which is not always the case. Add an attribute to allow unreachable patterns to remove the warning. * fix(emscripten) Rename unused variables. This patch renames various unused variables by appending an underscore to them. * fix(emscripten) Declare `table` as immutable. The `table` variable in `EmscriptenGlobals::new` was declared as mutable, but it's never mutated. * fix(emscripten) Remove an unnecessary `unsafe` block. * fix(emscripten) Remove duplicate definition of `SO_NOSIGPIPE`. The `SO_NOSIGPIPE` constant is defined in `syscalls/mod.rs` and `syscalls/unix.rs`. It's never used in the first case. We can safely remove it in this file, and keep it in `unix.rs`. * fix(emscripten) `read_string_from_wasm` is used only on Windows. Mark `read_string_from_wasm` as possible deadcode, since it's used only on Windows. * fix(emscripten) Remove `DYNAMICTOP_PTR_DIFF`, `stacktop`, `stack_max`, `dynamic_base` and `dynamic_ptr`. Four functions and one constant are used together but never used inside or outside this file. They are deadcode. * fix(emscripten) Remove `infinity` and `nan` fields of `EmscriptenGlobalsData`. Those fields are never used. * fix(emscripten) Allow non snake case in `emscripten_target.rs`. Many functions in this file don't follow the snake case style for Rust function names. The reason is that we want the names to match the emscripten symbol names; even if a mapping is done in `lib.rs`, it's easier to get the same names. * fix(emscripten) Rename `STATIC_TOP` to `static_top`. This variable is not a constant.
2019-03-12 22:00:33 +01:00
pub fn ___syscall6(ctx: &mut Ctx, _which: c_int, mut varargs: VarArgs) -> c_int {
debug!("emscripten::___syscall6 (close) {}", _which);
let fd: i32 = varargs.get(ctx);
debug!("fd: {}", fd);
unsafe { close(fd) }
}
// chdir
fix(emscripten) Various warning fixes and cleanups (#266) * fix(emscripten) Remove unused imports. This patch removes unused imports reported by `rustc` as warnings. * fix(emscripten) Allow unreachable patterns in `_clock_gettime`. The compiler thinks `CLOCK_MONOTONIC_COARSE` is unreachable, which is not always the case. Add an attribute to allow unreachable patterns to remove the warning. * fix(emscripten) Rename unused variables. This patch renames various unused variables by appending an underscore to them. * fix(emscripten) Declare `table` as immutable. The `table` variable in `EmscriptenGlobals::new` was declared as mutable, but it's never mutated. * fix(emscripten) Remove an unnecessary `unsafe` block. * fix(emscripten) Remove duplicate definition of `SO_NOSIGPIPE`. The `SO_NOSIGPIPE` constant is defined in `syscalls/mod.rs` and `syscalls/unix.rs`. It's never used in the first case. We can safely remove it in this file, and keep it in `unix.rs`. * fix(emscripten) `read_string_from_wasm` is used only on Windows. Mark `read_string_from_wasm` as possible deadcode, since it's used only on Windows. * fix(emscripten) Remove `DYNAMICTOP_PTR_DIFF`, `stacktop`, `stack_max`, `dynamic_base` and `dynamic_ptr`. Four functions and one constant are used together but never used inside or outside this file. They are deadcode. * fix(emscripten) Remove `infinity` and `nan` fields of `EmscriptenGlobalsData`. Those fields are never used. * fix(emscripten) Allow non snake case in `emscripten_target.rs`. Many functions in this file don't follow the snake case style for Rust function names. The reason is that we want the names to match the emscripten symbol names; even if a mapping is done in `lib.rs`, it's easier to get the same names. * fix(emscripten) Rename `STATIC_TOP` to `static_top`. This variable is not a constant.
2019-03-12 22:00:33 +01:00
pub fn ___syscall12(ctx: &mut Ctx, _which: c_int, mut varargs: VarArgs) -> c_int {
debug!("emscripten::___syscall12 (chdir) {}", _which);
let path_ptr = varargs.get_str(ctx);
let real_path_owned = get_cstr_path(ctx, path_ptr);
let real_path = if let Some(ref rp) = real_path_owned {
rp.as_c_str().as_ptr()
} else {
path_ptr
};
let ret = unsafe { chdir(real_path) };
debug!(
"=> path: {:?}, ret: {}",
unsafe { std::ffi::CStr::from_ptr(real_path) },
ret
);
ret
}
pub fn ___syscall10(_ctx: &mut Ctx, _one: i32, _two: i32) -> i32 {
debug!("emscripten::___syscall10");
-1
}
pub fn ___syscall14(_ctx: &mut Ctx, _one: i32, _two: i32) -> i32 {
debug!("emscripten::___syscall14");
-1
}
pub fn ___syscall15(_ctx: &mut Ctx, _one: i32, _two: i32) -> i32 {
debug!("emscripten::___syscall15");
-1
}
// getpid
pub fn ___syscall20(_ctx: &mut Ctx, _one: i32, _two: i32) -> i32 {
debug!("emscripten::___syscall20 (getpid)");
unsafe { getpid() }
}
pub fn ___syscall21(_ctx: &mut Ctx, _one: i32, _two: i32) -> i32 {
debug!("emscripten::___syscall21");
-1
}
pub fn ___syscall25(_ctx: &mut Ctx, _one: i32, _two: i32) -> i32 {
debug!("emscripten::___syscall25");
-1
}
pub fn ___syscall29(_ctx: &mut Ctx, _one: i32, _two: i32) -> i32 {
debug!("emscripten::___syscall29");
-1
}
pub fn ___syscall32(_ctx: &mut Ctx, _one: i32, _two: i32) -> i32 {
debug!("emscripten::___syscall32");
-1
}
pub fn ___syscall33(_ctx: &mut Ctx, _one: i32, _two: i32) -> i32 {
debug!("emscripten::___syscall33");
-1
}
pub fn ___syscall36(_ctx: &mut Ctx, _one: i32, _two: i32) -> i32 {
debug!("emscripten::___syscall36");
-1
}
2019-05-05 12:09:27 -07:00
// rename
pub fn ___syscall38(ctx: &mut Ctx, _which: c_int, mut varargs: VarArgs) -> i32 {
debug!("emscripten::___syscall38 (rename)");
let old_path = varargs.get_str(ctx);
let new_path = varargs.get_str(ctx);
let real_old_path_owned = get_cstr_path(ctx, old_path);
let real_old_path = if let Some(ref rp) = real_old_path_owned {
rp.as_c_str().as_ptr()
} else {
old_path
};
let real_new_path_owned = get_cstr_path(ctx, new_path);
let real_new_path = if let Some(ref rp) = real_new_path_owned {
rp.as_c_str().as_ptr()
} else {
new_path
};
let result = unsafe { rename(real_old_path, real_new_path) };
2019-05-06 14:17:23 -07:00
debug!(
"=> old_path: {}, new_path: {}, result: {}",
unsafe { std::ffi::CStr::from_ptr(real_old_path).to_str().unwrap() },
unsafe { std::ffi::CStr::from_ptr(real_new_path).to_str().unwrap() },
2019-05-06 14:17:23 -07:00
result
);
2019-05-05 12:09:27 -07:00
result
}
// rmdir
pub fn ___syscall40(ctx: &mut Ctx, _which: c_int, mut varargs: VarArgs) -> c_int {
debug!("emscripten::___syscall40 (rmdir)");
let pathname_addr = varargs.get_str(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
};
unsafe { rmdir(real_path) }
}
2019-03-01 10:54:39 -08:00
// pipe
pub fn ___syscall42(ctx: &mut Ctx, _which: c_int, mut varargs: VarArgs) -> c_int {
debug!("emscripten::___syscall42 (pipe)");
// offset to a file descriptor, which contains a read end and write end, 2 integers
let fd_offset: u32 = varargs.get(ctx);
let emscripten_memory = ctx.memory(0);
// convert the file descriptor into a vec with two slots
let mut fd_vec: Vec<c_int> = emscripten_memory.view()[((fd_offset / 4) as usize)..]
.iter()
.map(|pipe_end: &Cell<c_int>| pipe_end.get())
.take(2)
.collect();
// get it as a mutable pointer
let fd_ptr = fd_vec.as_mut_ptr();
// call pipe and store the pointers in this array
#[cfg(target_os = "windows")]
let result: c_int = unsafe { libc::pipe(fd_ptr, 2048, 0) };
#[cfg(not(target_os = "windows"))]
let result: c_int = unsafe { libc::pipe(fd_ptr) };
Squashed commit of the following: commit 62d9da4e3e02251a0f61c904e826bc06cf964ff7 Author: Syrus <me@syrusakbary.com> Date: Sun Jul 7 18:16:34 2019 -0700 Fixed syscall221 commit a8fde9148d50d89616d8a85a68110b89e3273229 Author: Syrus <me@syrusakbary.com> Date: Sun Jul 7 18:16:04 2019 -0700 Improved ioctl use case commit 5ad109d39838624ad84232a4c17714b885835893 Merge: 61526e2c 5cab8161 Author: Syrus <me@syrusakbary.com> Date: Sun Jul 7 17:44:25 2019 -0700 Merge branch 'command/dash' into feature/emscripten-update commit 5cab816193d47d53aabb4be4ccaf448dca5ed0b2 Author: Jesús Leganés-Combarro 'piranna <piranna@gmail.com> Date: Sat Jul 6 20:11:49 2019 +0200 Generic IOCTLs mapping commit 5a0dc0374cdc5a3754e3ecc82584288df640d239 Merge: 61cfed79 9d120ed3 Author: Jesús Leganés-Combarro 'piranna <piranna@gmail.com> Date: Sat Jul 6 17:15:02 2019 +0200 Merge remote-tracking branch 'origin/master' into command/dash commit 61cfed7916078602eabbd4448b109f47dcfff1e8 Author: Jesús Leganés-Combarro 'piranna <piranna@gmail.com> Date: Sat Jul 6 13:04:04 2019 +0200 Fixed implementation for syscalls 200, 201 and 202 commit 91e26d1a0ee46d6f9ec4804ca13ca928d55e7bbb Author: Jesús Leganés-Combarro 'piranna <piranna@gmail.com> Date: Sat Jul 6 13:03:26 2019 +0200 Improved debug messages commit 53a8fbeb2a0912e928609f0afcea6ffb1e911193 Author: Jesús Leganés-Combarro 'piranna <piranna@gmail.com> Date: Sat Jul 6 13:03:04 2019 +0200 [___syscall146] Move loop out of `unsafe` zone commit d6dd3696f10f4cbb0722321bd9d06e45a9d464ac Author: Jesús Leganés-Combarro 'piranna <piranna@gmail.com> Date: Sat Jul 6 13:01:31 2019 +0200 [___syscall140] Fixed types commit c827a6a99346535764e22bfb5ab9147a52a0a543 Merge: 2bc16826 5e18d04d Author: Jesús Leganés-Combarro 'piranna <piranna@gmail.com> Date: Sat Jul 6 12:21:33 2019 +0200 Merge remote-tracking branch 'origin/master' into command/dash commit 2bc16826b5923dba56243fe3bd99f4be8a09c990 Author: Jesús Leganés-Combarro 'piranna <piranna@gmail.com> Date: Thu Jul 4 07:05:00 2019 +0200 Implement `getpgid` syscall commit d464954f5803e4d84b6f94dc9ef87cc577aa9c65 Author: Jesús Leganés-Combarro 'piranna <piranna@gmail.com> Date: Thu Jul 4 07:04:36 2019 +0200 [fcntl64] Replace mock for real implementation commit 3fe0183d853624bcdc968a890ac36ff7062905a7 Author: Jesús Leganés-Combarro 'piranna <piranna@gmail.com> Date: Thu Jul 4 07:03:39 2019 +0200 [ioctl] No-of for `TIOCSPGRP` command & code clean-up commit cc83ec9ac1cf1ad60748fd3bb5114a6e6e471d92 Author: Jesús Leganés-Combarro 'piranna <piranna@gmail.com> Date: Thu Jul 4 07:02:47 2019 +0200 [___syscall5] debug messages commit 91587c8bde9d2b02402a7843f37eee22322d86fb Author: Jesús Leganés-Combarro 'piranna <piranna@gmail.com> Date: Thu Jul 4 07:02:20 2019 +0200 [___syscall57] debug messages
2019-07-07 19:35:09 -07:00
if result == -1 {
debug!("=> os error: {}", Error::last_os_error());
}
2019-03-01 10:54:39 -08:00
result
}
pub fn ___syscall51(_ctx: &mut Ctx, _one: i32, _two: i32) -> i32 {
debug!("emscripten::___syscall51");
-1
}
pub fn ___syscall52(_ctx: &mut Ctx, _one: i32, _two: i32) -> i32 {
debug!("emscripten::___syscall52");
-1
}
pub fn ___syscall53(_ctx: &mut Ctx, _one: i32, _two: i32) -> i32 {
debug!("emscripten::___syscall53");
-1
}
pub fn ___syscall60(_ctx: &mut Ctx, _one: i32, _two: i32) -> i32 {
debug!("emscripten::___syscall60");
-1
}
// dup2
fix(emscripten) Various warning fixes and cleanups (#266) * fix(emscripten) Remove unused imports. This patch removes unused imports reported by `rustc` as warnings. * fix(emscripten) Allow unreachable patterns in `_clock_gettime`. The compiler thinks `CLOCK_MONOTONIC_COARSE` is unreachable, which is not always the case. Add an attribute to allow unreachable patterns to remove the warning. * fix(emscripten) Rename unused variables. This patch renames various unused variables by appending an underscore to them. * fix(emscripten) Declare `table` as immutable. The `table` variable in `EmscriptenGlobals::new` was declared as mutable, but it's never mutated. * fix(emscripten) Remove an unnecessary `unsafe` block. * fix(emscripten) Remove duplicate definition of `SO_NOSIGPIPE`. The `SO_NOSIGPIPE` constant is defined in `syscalls/mod.rs` and `syscalls/unix.rs`. It's never used in the first case. We can safely remove it in this file, and keep it in `unix.rs`. * fix(emscripten) `read_string_from_wasm` is used only on Windows. Mark `read_string_from_wasm` as possible deadcode, since it's used only on Windows. * fix(emscripten) Remove `DYNAMICTOP_PTR_DIFF`, `stacktop`, `stack_max`, `dynamic_base` and `dynamic_ptr`. Four functions and one constant are used together but never used inside or outside this file. They are deadcode. * fix(emscripten) Remove `infinity` and `nan` fields of `EmscriptenGlobalsData`. Those fields are never used. * fix(emscripten) Allow non snake case in `emscripten_target.rs`. Many functions in this file don't follow the snake case style for Rust function names. The reason is that we want the names to match the emscripten symbol names; even if a mapping is done in `lib.rs`, it's easier to get the same names. * fix(emscripten) Rename `STATIC_TOP` to `static_top`. This variable is not a constant.
2019-03-12 22:00:33 +01:00
pub fn ___syscall63(ctx: &mut Ctx, _which: c_int, mut varargs: VarArgs) -> c_int {
debug!("emscripten::___syscall63 (dup2) {}", _which);
let src: i32 = varargs.get(ctx);
let dst: i32 = varargs.get(ctx);
unsafe { dup2(src, dst) }
}
// getppid
pub fn ___syscall64(_ctx: &mut Ctx, _one: i32, _two: i32) -> i32 {
debug!("emscripten::___syscall64 (getppid)");
unsafe { getpid() }
}
pub fn ___syscall66(_ctx: &mut Ctx, _one: i32, _two: i32) -> i32 {
debug!("emscripten::___syscall66");
-1
}
pub fn ___syscall75(_ctx: &mut Ctx, _one: i32, _two: i32) -> i32 {
debug!("emscripten::___syscall75");
-1
}
pub fn ___syscall91(_ctx: &mut Ctx, _one: i32, _two: i32) -> i32 {
2019-04-05 12:06:30 -07:00
debug!("emscripten::___syscall91 - stub");
0
}
pub fn ___syscall96(_ctx: &mut Ctx, _one: i32, _two: i32) -> i32 {
debug!("emscripten::___syscall96");
-1
}
pub fn ___syscall97(_ctx: &mut Ctx, _one: i32, _two: i32) -> i32 {
debug!("emscripten::___syscall97");
-1
}
pub fn ___syscall110(_ctx: &mut Ctx, _one: i32, _two: i32) -> i32 {
debug!("emscripten::___syscall110");
-1
}
pub fn ___syscall121(_ctx: &mut Ctx, _one: i32, _two: i32) -> i32 {
debug!("emscripten::___syscall121");
-1
}
pub fn ___syscall125(_ctx: &mut Ctx, _one: i32, _two: i32) -> i32 {
debug!("emscripten::___syscall125");
-1
}
pub fn ___syscall133(_ctx: &mut Ctx, _one: i32, _two: i32) -> i32 {
debug!("emscripten::___syscall133");
-1
}
pub fn ___syscall144(_ctx: &mut Ctx, _one: i32, _two: i32) -> i32 {
debug!("emscripten::___syscall144");
-1
}
pub fn ___syscall147(_ctx: &mut Ctx, _one: i32, _two: i32) -> i32 {
debug!("emscripten::___syscall147");
-1
}
pub fn ___syscall150(_ctx: &mut Ctx, _one: i32, _two: i32) -> i32 {
debug!("emscripten::___syscall150");
-1
}
pub fn ___syscall151(_ctx: &mut Ctx, _one: i32, _two: i32) -> i32 {
debug!("emscripten::___syscall151");
-1
}
pub fn ___syscall152(_ctx: &mut Ctx, _one: i32, _two: i32) -> i32 {
debug!("emscripten::___syscall152");
-1
}
pub fn ___syscall153(_ctx: &mut Ctx, _one: i32, _two: i32) -> i32 {
debug!("emscripten::___syscall153");
-1
}
pub fn ___syscall163(_ctx: &mut Ctx, _one: i32, _two: i32) -> i32 {
debug!("emscripten::___syscall163");
-1
}
2019-02-22 12:32:14 -08:00
// getcwd
2019-03-26 14:37:47 -07:00
pub fn ___syscall183(ctx: &mut Ctx, _which: c_int, mut varargs: VarArgs) -> i32 {
2019-02-22 12:32:14 -08:00
debug!("emscripten::___syscall183");
let buf_offset: WasmPtr<libc::c_char, Array> = varargs.get(ctx);
2019-03-26 14:37:47 -07:00
let _size: c_int = varargs.get(ctx);
let path = get_current_directory(ctx);
let path_string = path.unwrap().display().to_string();
let len = path_string.len();
let buf_writer = buf_offset.deref(ctx.memory(0), 0, len as u32 + 1).unwrap();
for (i, byte) in path_string.bytes().enumerate() {
buf_writer[i].set(byte as i8);
2019-02-22 12:32:14 -08:00
}
buf_writer[len].set(0);
buf_offset.offset() as i32
2019-02-22 12:32:14 -08:00
}
// mmap2
fix(emscripten) Various warning fixes and cleanups (#266) * fix(emscripten) Remove unused imports. This patch removes unused imports reported by `rustc` as warnings. * fix(emscripten) Allow unreachable patterns in `_clock_gettime`. The compiler thinks `CLOCK_MONOTONIC_COARSE` is unreachable, which is not always the case. Add an attribute to allow unreachable patterns to remove the warning. * fix(emscripten) Rename unused variables. This patch renames various unused variables by appending an underscore to them. * fix(emscripten) Declare `table` as immutable. The `table` variable in `EmscriptenGlobals::new` was declared as mutable, but it's never mutated. * fix(emscripten) Remove an unnecessary `unsafe` block. * fix(emscripten) Remove duplicate definition of `SO_NOSIGPIPE`. The `SO_NOSIGPIPE` constant is defined in `syscalls/mod.rs` and `syscalls/unix.rs`. It's never used in the first case. We can safely remove it in this file, and keep it in `unix.rs`. * fix(emscripten) `read_string_from_wasm` is used only on Windows. Mark `read_string_from_wasm` as possible deadcode, since it's used only on Windows. * fix(emscripten) Remove `DYNAMICTOP_PTR_DIFF`, `stacktop`, `stack_max`, `dynamic_base` and `dynamic_ptr`. Four functions and one constant are used together but never used inside or outside this file. They are deadcode. * fix(emscripten) Remove `infinity` and `nan` fields of `EmscriptenGlobalsData`. Those fields are never used. * fix(emscripten) Allow non snake case in `emscripten_target.rs`. Many functions in this file don't follow the snake case style for Rust function names. The reason is that we want the names to match the emscripten symbol names; even if a mapping is done in `lib.rs`, it's easier to get the same names. * fix(emscripten) Rename `STATIC_TOP` to `static_top`. This variable is not a constant.
2019-03-12 22:00:33 +01:00
pub fn ___syscall192(ctx: &mut Ctx, _which: c_int, mut varargs: VarArgs) -> c_int {
debug!("emscripten::___syscall192 (mmap2) {}", _which);
let _addr: i32 = varargs.get(ctx);
let len: u32 = varargs.get(ctx);
fix(emscripten) Various warning fixes and cleanups (#266) * fix(emscripten) Remove unused imports. This patch removes unused imports reported by `rustc` as warnings. * fix(emscripten) Allow unreachable patterns in `_clock_gettime`. The compiler thinks `CLOCK_MONOTONIC_COARSE` is unreachable, which is not always the case. Add an attribute to allow unreachable patterns to remove the warning. * fix(emscripten) Rename unused variables. This patch renames various unused variables by appending an underscore to them. * fix(emscripten) Declare `table` as immutable. The `table` variable in `EmscriptenGlobals::new` was declared as mutable, but it's never mutated. * fix(emscripten) Remove an unnecessary `unsafe` block. * fix(emscripten) Remove duplicate definition of `SO_NOSIGPIPE`. The `SO_NOSIGPIPE` constant is defined in `syscalls/mod.rs` and `syscalls/unix.rs`. It's never used in the first case. We can safely remove it in this file, and keep it in `unix.rs`. * fix(emscripten) `read_string_from_wasm` is used only on Windows. Mark `read_string_from_wasm` as possible deadcode, since it's used only on Windows. * fix(emscripten) Remove `DYNAMICTOP_PTR_DIFF`, `stacktop`, `stack_max`, `dynamic_base` and `dynamic_ptr`. Four functions and one constant are used together but never used inside or outside this file. They are deadcode. * fix(emscripten) Remove `infinity` and `nan` fields of `EmscriptenGlobalsData`. Those fields are never used. * fix(emscripten) Allow non snake case in `emscripten_target.rs`. Many functions in this file don't follow the snake case style for Rust function names. The reason is that we want the names to match the emscripten symbol names; even if a mapping is done in `lib.rs`, it's easier to get the same names. * fix(emscripten) Rename `STATIC_TOP` to `static_top`. This variable is not a constant.
2019-03-12 22:00:33 +01:00
let _prot: i32 = varargs.get(ctx);
let _flags: i32 = varargs.get(ctx);
let fd: i32 = varargs.get(ctx);
fix(emscripten) Various warning fixes and cleanups (#266) * fix(emscripten) Remove unused imports. This patch removes unused imports reported by `rustc` as warnings. * fix(emscripten) Allow unreachable patterns in `_clock_gettime`. The compiler thinks `CLOCK_MONOTONIC_COARSE` is unreachable, which is not always the case. Add an attribute to allow unreachable patterns to remove the warning. * fix(emscripten) Rename unused variables. This patch renames various unused variables by appending an underscore to them. * fix(emscripten) Declare `table` as immutable. The `table` variable in `EmscriptenGlobals::new` was declared as mutable, but it's never mutated. * fix(emscripten) Remove an unnecessary `unsafe` block. * fix(emscripten) Remove duplicate definition of `SO_NOSIGPIPE`. The `SO_NOSIGPIPE` constant is defined in `syscalls/mod.rs` and `syscalls/unix.rs`. It's never used in the first case. We can safely remove it in this file, and keep it in `unix.rs`. * fix(emscripten) `read_string_from_wasm` is used only on Windows. Mark `read_string_from_wasm` as possible deadcode, since it's used only on Windows. * fix(emscripten) Remove `DYNAMICTOP_PTR_DIFF`, `stacktop`, `stack_max`, `dynamic_base` and `dynamic_ptr`. Four functions and one constant are used together but never used inside or outside this file. They are deadcode. * fix(emscripten) Remove `infinity` and `nan` fields of `EmscriptenGlobalsData`. Those fields are never used. * fix(emscripten) Allow non snake case in `emscripten_target.rs`. Many functions in this file don't follow the snake case style for Rust function names. The reason is that we want the names to match the emscripten symbol names; even if a mapping is done in `lib.rs`, it's easier to get the same names. * fix(emscripten) Rename `STATIC_TOP` to `static_top`. This variable is not a constant.
2019-03-12 22:00:33 +01:00
let _off: i32 = varargs.get(ctx);
debug!(
"=> addr: {}, len: {}, prot: {}, flags: {}, fd: {}, off: {}",
fix(emscripten) Various warning fixes and cleanups (#266) * fix(emscripten) Remove unused imports. This patch removes unused imports reported by `rustc` as warnings. * fix(emscripten) Allow unreachable patterns in `_clock_gettime`. The compiler thinks `CLOCK_MONOTONIC_COARSE` is unreachable, which is not always the case. Add an attribute to allow unreachable patterns to remove the warning. * fix(emscripten) Rename unused variables. This patch renames various unused variables by appending an underscore to them. * fix(emscripten) Declare `table` as immutable. The `table` variable in `EmscriptenGlobals::new` was declared as mutable, but it's never mutated. * fix(emscripten) Remove an unnecessary `unsafe` block. * fix(emscripten) Remove duplicate definition of `SO_NOSIGPIPE`. The `SO_NOSIGPIPE` constant is defined in `syscalls/mod.rs` and `syscalls/unix.rs`. It's never used in the first case. We can safely remove it in this file, and keep it in `unix.rs`. * fix(emscripten) `read_string_from_wasm` is used only on Windows. Mark `read_string_from_wasm` as possible deadcode, since it's used only on Windows. * fix(emscripten) Remove `DYNAMICTOP_PTR_DIFF`, `stacktop`, `stack_max`, `dynamic_base` and `dynamic_ptr`. Four functions and one constant are used together but never used inside or outside this file. They are deadcode. * fix(emscripten) Remove `infinity` and `nan` fields of `EmscriptenGlobalsData`. Those fields are never used. * fix(emscripten) Allow non snake case in `emscripten_target.rs`. Many functions in this file don't follow the snake case style for Rust function names. The reason is that we want the names to match the emscripten symbol names; even if a mapping is done in `lib.rs`, it's easier to get the same names. * fix(emscripten) Rename `STATIC_TOP` to `static_top`. This variable is not a constant.
2019-03-12 22:00:33 +01:00
_addr, len, _prot, _flags, fd, _off
);
if fd == -1 {
let ptr = env::call_memalign(ctx, 16384, len);
if ptr == 0 {
2019-05-03 17:34:57 -07:00
// ENOMEM
return -12;
}
2019-05-03 17:34:57 -07:00
let real_ptr = emscripten_memory_pointer!(ctx.memory(0), ptr) as *const u8;
env::call_memset(ctx, ptr, 0, len);
2019-05-03 17:34:57 -07:00
for i in 0..(len as usize) {
unsafe {
assert_eq!(*real_ptr.add(i), 0);
}
}
debug!("=> ptr: {}", ptr);
return ptr as i32;
} else {
2019-05-03 17:34:57 -07:00
// return ENODEV
return -19;
}
}
/// lseek
fix(emscripten) Various warning fixes and cleanups (#266) * fix(emscripten) Remove unused imports. This patch removes unused imports reported by `rustc` as warnings. * fix(emscripten) Allow unreachable patterns in `_clock_gettime`. The compiler thinks `CLOCK_MONOTONIC_COARSE` is unreachable, which is not always the case. Add an attribute to allow unreachable patterns to remove the warning. * fix(emscripten) Rename unused variables. This patch renames various unused variables by appending an underscore to them. * fix(emscripten) Declare `table` as immutable. The `table` variable in `EmscriptenGlobals::new` was declared as mutable, but it's never mutated. * fix(emscripten) Remove an unnecessary `unsafe` block. * fix(emscripten) Remove duplicate definition of `SO_NOSIGPIPE`. The `SO_NOSIGPIPE` constant is defined in `syscalls/mod.rs` and `syscalls/unix.rs`. It's never used in the first case. We can safely remove it in this file, and keep it in `unix.rs`. * fix(emscripten) `read_string_from_wasm` is used only on Windows. Mark `read_string_from_wasm` as possible deadcode, since it's used only on Windows. * fix(emscripten) Remove `DYNAMICTOP_PTR_DIFF`, `stacktop`, `stack_max`, `dynamic_base` and `dynamic_ptr`. Four functions and one constant are used together but never used inside or outside this file. They are deadcode. * fix(emscripten) Remove `infinity` and `nan` fields of `EmscriptenGlobalsData`. Those fields are never used. * fix(emscripten) Allow non snake case in `emscripten_target.rs`. Many functions in this file don't follow the snake case style for Rust function names. The reason is that we want the names to match the emscripten symbol names; even if a mapping is done in `lib.rs`, it's easier to get the same names. * fix(emscripten) Rename `STATIC_TOP` to `static_top`. This variable is not a constant.
2019-03-12 22:00:33 +01:00
pub fn ___syscall140(ctx: &mut Ctx, _which: i32, mut varargs: VarArgs) -> i32 {
// -> c_int
fix(emscripten) Various warning fixes and cleanups (#266) * fix(emscripten) Remove unused imports. This patch removes unused imports reported by `rustc` as warnings. * fix(emscripten) Allow unreachable patterns in `_clock_gettime`. The compiler thinks `CLOCK_MONOTONIC_COARSE` is unreachable, which is not always the case. Add an attribute to allow unreachable patterns to remove the warning. * fix(emscripten) Rename unused variables. This patch renames various unused variables by appending an underscore to them. * fix(emscripten) Declare `table` as immutable. The `table` variable in `EmscriptenGlobals::new` was declared as mutable, but it's never mutated. * fix(emscripten) Remove an unnecessary `unsafe` block. * fix(emscripten) Remove duplicate definition of `SO_NOSIGPIPE`. The `SO_NOSIGPIPE` constant is defined in `syscalls/mod.rs` and `syscalls/unix.rs`. It's never used in the first case. We can safely remove it in this file, and keep it in `unix.rs`. * fix(emscripten) `read_string_from_wasm` is used only on Windows. Mark `read_string_from_wasm` as possible deadcode, since it's used only on Windows. * fix(emscripten) Remove `DYNAMICTOP_PTR_DIFF`, `stacktop`, `stack_max`, `dynamic_base` and `dynamic_ptr`. Four functions and one constant are used together but never used inside or outside this file. They are deadcode. * fix(emscripten) Remove `infinity` and `nan` fields of `EmscriptenGlobalsData`. Those fields are never used. * fix(emscripten) Allow non snake case in `emscripten_target.rs`. Many functions in this file don't follow the snake case style for Rust function names. The reason is that we want the names to match the emscripten symbol names; even if a mapping is done in `lib.rs`, it's easier to get the same names. * fix(emscripten) Rename `STATIC_TOP` to `static_top`. This variable is not a constant.
2019-03-12 22:00:33 +01:00
debug!("emscripten::___syscall140 (lseek) {}", _which);
let fd: i32 = varargs.get(ctx);
Squashed commit of the following: commit 62d9da4e3e02251a0f61c904e826bc06cf964ff7 Author: Syrus <me@syrusakbary.com> Date: Sun Jul 7 18:16:34 2019 -0700 Fixed syscall221 commit a8fde9148d50d89616d8a85a68110b89e3273229 Author: Syrus <me@syrusakbary.com> Date: Sun Jul 7 18:16:04 2019 -0700 Improved ioctl use case commit 5ad109d39838624ad84232a4c17714b885835893 Merge: 61526e2c 5cab8161 Author: Syrus <me@syrusakbary.com> Date: Sun Jul 7 17:44:25 2019 -0700 Merge branch 'command/dash' into feature/emscripten-update commit 5cab816193d47d53aabb4be4ccaf448dca5ed0b2 Author: Jesús Leganés-Combarro 'piranna <piranna@gmail.com> Date: Sat Jul 6 20:11:49 2019 +0200 Generic IOCTLs mapping commit 5a0dc0374cdc5a3754e3ecc82584288df640d239 Merge: 61cfed79 9d120ed3 Author: Jesús Leganés-Combarro 'piranna <piranna@gmail.com> Date: Sat Jul 6 17:15:02 2019 +0200 Merge remote-tracking branch 'origin/master' into command/dash commit 61cfed7916078602eabbd4448b109f47dcfff1e8 Author: Jesús Leganés-Combarro 'piranna <piranna@gmail.com> Date: Sat Jul 6 13:04:04 2019 +0200 Fixed implementation for syscalls 200, 201 and 202 commit 91e26d1a0ee46d6f9ec4804ca13ca928d55e7bbb Author: Jesús Leganés-Combarro 'piranna <piranna@gmail.com> Date: Sat Jul 6 13:03:26 2019 +0200 Improved debug messages commit 53a8fbeb2a0912e928609f0afcea6ffb1e911193 Author: Jesús Leganés-Combarro 'piranna <piranna@gmail.com> Date: Sat Jul 6 13:03:04 2019 +0200 [___syscall146] Move loop out of `unsafe` zone commit d6dd3696f10f4cbb0722321bd9d06e45a9d464ac Author: Jesús Leganés-Combarro 'piranna <piranna@gmail.com> Date: Sat Jul 6 13:01:31 2019 +0200 [___syscall140] Fixed types commit c827a6a99346535764e22bfb5ab9147a52a0a543 Merge: 2bc16826 5e18d04d Author: Jesús Leganés-Combarro 'piranna <piranna@gmail.com> Date: Sat Jul 6 12:21:33 2019 +0200 Merge remote-tracking branch 'origin/master' into command/dash commit 2bc16826b5923dba56243fe3bd99f4be8a09c990 Author: Jesús Leganés-Combarro 'piranna <piranna@gmail.com> Date: Thu Jul 4 07:05:00 2019 +0200 Implement `getpgid` syscall commit d464954f5803e4d84b6f94dc9ef87cc577aa9c65 Author: Jesús Leganés-Combarro 'piranna <piranna@gmail.com> Date: Thu Jul 4 07:04:36 2019 +0200 [fcntl64] Replace mock for real implementation commit 3fe0183d853624bcdc968a890ac36ff7062905a7 Author: Jesús Leganés-Combarro 'piranna <piranna@gmail.com> Date: Thu Jul 4 07:03:39 2019 +0200 [ioctl] No-of for `TIOCSPGRP` command & code clean-up commit cc83ec9ac1cf1ad60748fd3bb5114a6e6e471d92 Author: Jesús Leganés-Combarro 'piranna <piranna@gmail.com> Date: Thu Jul 4 07:02:47 2019 +0200 [___syscall5] debug messages commit 91587c8bde9d2b02402a7843f37eee22322d86fb Author: Jesús Leganés-Combarro 'piranna <piranna@gmail.com> Date: Thu Jul 4 07:02:20 2019 +0200 [___syscall57] debug messages
2019-07-07 19:35:09 -07:00
let _offset_high: u32 = varargs.get(ctx); // We don't use the offset high as emscripten skips it
let offset_low: u32 = varargs.get(ctx);
2019-06-27 12:37:29 -07:00
let result_ptr_value: WasmPtr<i64> = varargs.get(ctx);
let whence: i32 = varargs.get(ctx);
2019-07-07 22:50:50 -07:00
let offset = offset_low;
let ret = unsafe { lseek(fd, offset as _, whence) as i64 };
2019-06-27 12:37:29 -07:00
let result_ptr = result_ptr_value.deref(ctx.memory(0)).unwrap();
result_ptr.set(ret);
2019-03-25 16:13:41 -07:00
debug!(
2019-06-27 11:14:38 -07:00
"=> fd: {}, offset: {}, result: {}, whence: {} = {}\nlast os error: {}",
2019-03-25 16:13:41 -07:00
fd,
offset,
2019-06-27 11:14:38 -07:00
ret,
2019-03-25 16:13:41 -07:00
whence,
0,
Error::last_os_error(),
);
0
}
/// readv
#[allow(clippy::cast_ptr_alignment)]
fix(emscripten) Various warning fixes and cleanups (#266) * fix(emscripten) Remove unused imports. This patch removes unused imports reported by `rustc` as warnings. * fix(emscripten) Allow unreachable patterns in `_clock_gettime`. The compiler thinks `CLOCK_MONOTONIC_COARSE` is unreachable, which is not always the case. Add an attribute to allow unreachable patterns to remove the warning. * fix(emscripten) Rename unused variables. This patch renames various unused variables by appending an underscore to them. * fix(emscripten) Declare `table` as immutable. The `table` variable in `EmscriptenGlobals::new` was declared as mutable, but it's never mutated. * fix(emscripten) Remove an unnecessary `unsafe` block. * fix(emscripten) Remove duplicate definition of `SO_NOSIGPIPE`. The `SO_NOSIGPIPE` constant is defined in `syscalls/mod.rs` and `syscalls/unix.rs`. It's never used in the first case. We can safely remove it in this file, and keep it in `unix.rs`. * fix(emscripten) `read_string_from_wasm` is used only on Windows. Mark `read_string_from_wasm` as possible deadcode, since it's used only on Windows. * fix(emscripten) Remove `DYNAMICTOP_PTR_DIFF`, `stacktop`, `stack_max`, `dynamic_base` and `dynamic_ptr`. Four functions and one constant are used together but never used inside or outside this file. They are deadcode. * fix(emscripten) Remove `infinity` and `nan` fields of `EmscriptenGlobalsData`. Those fields are never used. * fix(emscripten) Allow non snake case in `emscripten_target.rs`. Many functions in this file don't follow the snake case style for Rust function names. The reason is that we want the names to match the emscripten symbol names; even if a mapping is done in `lib.rs`, it's easier to get the same names. * fix(emscripten) Rename `STATIC_TOP` to `static_top`. This variable is not a constant.
2019-03-12 22:00:33 +01:00
pub fn ___syscall145(ctx: &mut Ctx, _which: c_int, mut varargs: VarArgs) -> i32 {
// -> ssize_t
fix(emscripten) Various warning fixes and cleanups (#266) * fix(emscripten) Remove unused imports. This patch removes unused imports reported by `rustc` as warnings. * fix(emscripten) Allow unreachable patterns in `_clock_gettime`. The compiler thinks `CLOCK_MONOTONIC_COARSE` is unreachable, which is not always the case. Add an attribute to allow unreachable patterns to remove the warning. * fix(emscripten) Rename unused variables. This patch renames various unused variables by appending an underscore to them. * fix(emscripten) Declare `table` as immutable. The `table` variable in `EmscriptenGlobals::new` was declared as mutable, but it's never mutated. * fix(emscripten) Remove an unnecessary `unsafe` block. * fix(emscripten) Remove duplicate definition of `SO_NOSIGPIPE`. The `SO_NOSIGPIPE` constant is defined in `syscalls/mod.rs` and `syscalls/unix.rs`. It's never used in the first case. We can safely remove it in this file, and keep it in `unix.rs`. * fix(emscripten) `read_string_from_wasm` is used only on Windows. Mark `read_string_from_wasm` as possible deadcode, since it's used only on Windows. * fix(emscripten) Remove `DYNAMICTOP_PTR_DIFF`, `stacktop`, `stack_max`, `dynamic_base` and `dynamic_ptr`. Four functions and one constant are used together but never used inside or outside this file. They are deadcode. * fix(emscripten) Remove `infinity` and `nan` fields of `EmscriptenGlobalsData`. Those fields are never used. * fix(emscripten) Allow non snake case in `emscripten_target.rs`. Many functions in this file don't follow the snake case style for Rust function names. The reason is that we want the names to match the emscripten symbol names; even if a mapping is done in `lib.rs`, it's easier to get the same names. * fix(emscripten) Rename `STATIC_TOP` to `static_top`. This variable is not a constant.
2019-03-12 22:00:33 +01:00
debug!("emscripten::___syscall145 (readv) {}", _which);
let fd: i32 = varargs.get(ctx);
let iov: i32 = varargs.get(ctx);
let iovcnt: i32 = varargs.get(ctx);
#[repr(C)]
struct GuestIovec {
iov_base: i32,
iov_len: i32,
}
debug!("=> fd: {}, iov: {}, iovcnt = {}", fd, iov, iovcnt);
let mut ret = 0;
unsafe {
for i in 0..iovcnt {
let guest_iov_addr =
emscripten_memory_pointer!(ctx.memory(0), (iov + i * 8)) as *mut GuestIovec;
let iov_base = emscripten_memory_pointer!(ctx.memory(0), (*guest_iov_addr).iov_base)
as *mut c_void;
let iov_len = (*guest_iov_addr).iov_len as _;
// debug!("=> iov_addr: {:?}, {:?}", iov_base, iov_len);
let curr = read(fd, iov_base, iov_len);
if curr < 0 {
return -1;
}
ret += curr;
}
// debug!(" => ret: {}", ret);
ret as _
}
}
// writev
#[allow(clippy::cast_ptr_alignment)]
fix(emscripten) Various warning fixes and cleanups (#266) * fix(emscripten) Remove unused imports. This patch removes unused imports reported by `rustc` as warnings. * fix(emscripten) Allow unreachable patterns in `_clock_gettime`. The compiler thinks `CLOCK_MONOTONIC_COARSE` is unreachable, which is not always the case. Add an attribute to allow unreachable patterns to remove the warning. * fix(emscripten) Rename unused variables. This patch renames various unused variables by appending an underscore to them. * fix(emscripten) Declare `table` as immutable. The `table` variable in `EmscriptenGlobals::new` was declared as mutable, but it's never mutated. * fix(emscripten) Remove an unnecessary `unsafe` block. * fix(emscripten) Remove duplicate definition of `SO_NOSIGPIPE`. The `SO_NOSIGPIPE` constant is defined in `syscalls/mod.rs` and `syscalls/unix.rs`. It's never used in the first case. We can safely remove it in this file, and keep it in `unix.rs`. * fix(emscripten) `read_string_from_wasm` is used only on Windows. Mark `read_string_from_wasm` as possible deadcode, since it's used only on Windows. * fix(emscripten) Remove `DYNAMICTOP_PTR_DIFF`, `stacktop`, `stack_max`, `dynamic_base` and `dynamic_ptr`. Four functions and one constant are used together but never used inside or outside this file. They are deadcode. * fix(emscripten) Remove `infinity` and `nan` fields of `EmscriptenGlobalsData`. Those fields are never used. * fix(emscripten) Allow non snake case in `emscripten_target.rs`. Many functions in this file don't follow the snake case style for Rust function names. The reason is that we want the names to match the emscripten symbol names; even if a mapping is done in `lib.rs`, it's easier to get the same names. * fix(emscripten) Rename `STATIC_TOP` to `static_top`. This variable is not a constant.
2019-03-12 22:00:33 +01:00
pub fn ___syscall146(ctx: &mut Ctx, _which: i32, mut varargs: VarArgs) -> i32 {
// -> ssize_t
fix(emscripten) Various warning fixes and cleanups (#266) * fix(emscripten) Remove unused imports. This patch removes unused imports reported by `rustc` as warnings. * fix(emscripten) Allow unreachable patterns in `_clock_gettime`. The compiler thinks `CLOCK_MONOTONIC_COARSE` is unreachable, which is not always the case. Add an attribute to allow unreachable patterns to remove the warning. * fix(emscripten) Rename unused variables. This patch renames various unused variables by appending an underscore to them. * fix(emscripten) Declare `table` as immutable. The `table` variable in `EmscriptenGlobals::new` was declared as mutable, but it's never mutated. * fix(emscripten) Remove an unnecessary `unsafe` block. * fix(emscripten) Remove duplicate definition of `SO_NOSIGPIPE`. The `SO_NOSIGPIPE` constant is defined in `syscalls/mod.rs` and `syscalls/unix.rs`. It's never used in the first case. We can safely remove it in this file, and keep it in `unix.rs`. * fix(emscripten) `read_string_from_wasm` is used only on Windows. Mark `read_string_from_wasm` as possible deadcode, since it's used only on Windows. * fix(emscripten) Remove `DYNAMICTOP_PTR_DIFF`, `stacktop`, `stack_max`, `dynamic_base` and `dynamic_ptr`. Four functions and one constant are used together but never used inside or outside this file. They are deadcode. * fix(emscripten) Remove `infinity` and `nan` fields of `EmscriptenGlobalsData`. Those fields are never used. * fix(emscripten) Allow non snake case in `emscripten_target.rs`. Many functions in this file don't follow the snake case style for Rust function names. The reason is that we want the names to match the emscripten symbol names; even if a mapping is done in `lib.rs`, it's easier to get the same names. * fix(emscripten) Rename `STATIC_TOP` to `static_top`. This variable is not a constant.
2019-03-12 22:00:33 +01:00
debug!("emscripten::___syscall146 (writev) {}", _which);
let fd: i32 = varargs.get(ctx);
let iov: i32 = varargs.get(ctx);
let iovcnt: i32 = varargs.get(ctx);
#[repr(C)]
struct GuestIovec {
iov_base: i32,
iov_len: i32,
}
debug!("=> fd: {}, iov: {}, iovcnt = {}", fd, iov, iovcnt);
let mut ret = 0;
Squashed commit of the following: commit 62d9da4e3e02251a0f61c904e826bc06cf964ff7 Author: Syrus <me@syrusakbary.com> Date: Sun Jul 7 18:16:34 2019 -0700 Fixed syscall221 commit a8fde9148d50d89616d8a85a68110b89e3273229 Author: Syrus <me@syrusakbary.com> Date: Sun Jul 7 18:16:04 2019 -0700 Improved ioctl use case commit 5ad109d39838624ad84232a4c17714b885835893 Merge: 61526e2c 5cab8161 Author: Syrus <me@syrusakbary.com> Date: Sun Jul 7 17:44:25 2019 -0700 Merge branch 'command/dash' into feature/emscripten-update commit 5cab816193d47d53aabb4be4ccaf448dca5ed0b2 Author: Jesús Leganés-Combarro 'piranna <piranna@gmail.com> Date: Sat Jul 6 20:11:49 2019 +0200 Generic IOCTLs mapping commit 5a0dc0374cdc5a3754e3ecc82584288df640d239 Merge: 61cfed79 9d120ed3 Author: Jesús Leganés-Combarro 'piranna <piranna@gmail.com> Date: Sat Jul 6 17:15:02 2019 +0200 Merge remote-tracking branch 'origin/master' into command/dash commit 61cfed7916078602eabbd4448b109f47dcfff1e8 Author: Jesús Leganés-Combarro 'piranna <piranna@gmail.com> Date: Sat Jul 6 13:04:04 2019 +0200 Fixed implementation for syscalls 200, 201 and 202 commit 91e26d1a0ee46d6f9ec4804ca13ca928d55e7bbb Author: Jesús Leganés-Combarro 'piranna <piranna@gmail.com> Date: Sat Jul 6 13:03:26 2019 +0200 Improved debug messages commit 53a8fbeb2a0912e928609f0afcea6ffb1e911193 Author: Jesús Leganés-Combarro 'piranna <piranna@gmail.com> Date: Sat Jul 6 13:03:04 2019 +0200 [___syscall146] Move loop out of `unsafe` zone commit d6dd3696f10f4cbb0722321bd9d06e45a9d464ac Author: Jesús Leganés-Combarro 'piranna <piranna@gmail.com> Date: Sat Jul 6 13:01:31 2019 +0200 [___syscall140] Fixed types commit c827a6a99346535764e22bfb5ab9147a52a0a543 Merge: 2bc16826 5e18d04d Author: Jesús Leganés-Combarro 'piranna <piranna@gmail.com> Date: Sat Jul 6 12:21:33 2019 +0200 Merge remote-tracking branch 'origin/master' into command/dash commit 2bc16826b5923dba56243fe3bd99f4be8a09c990 Author: Jesús Leganés-Combarro 'piranna <piranna@gmail.com> Date: Thu Jul 4 07:05:00 2019 +0200 Implement `getpgid` syscall commit d464954f5803e4d84b6f94dc9ef87cc577aa9c65 Author: Jesús Leganés-Combarro 'piranna <piranna@gmail.com> Date: Thu Jul 4 07:04:36 2019 +0200 [fcntl64] Replace mock for real implementation commit 3fe0183d853624bcdc968a890ac36ff7062905a7 Author: Jesús Leganés-Combarro 'piranna <piranna@gmail.com> Date: Thu Jul 4 07:03:39 2019 +0200 [ioctl] No-of for `TIOCSPGRP` command & code clean-up commit cc83ec9ac1cf1ad60748fd3bb5114a6e6e471d92 Author: Jesús Leganés-Combarro 'piranna <piranna@gmail.com> Date: Thu Jul 4 07:02:47 2019 +0200 [___syscall5] debug messages commit 91587c8bde9d2b02402a7843f37eee22322d86fb Author: Jesús Leganés-Combarro 'piranna <piranna@gmail.com> Date: Thu Jul 4 07:02:20 2019 +0200 [___syscall57] debug messages
2019-07-07 19:35:09 -07:00
for i in 0..iovcnt {
unsafe {
let guest_iov_addr =
emscripten_memory_pointer!(ctx.memory(0), (iov + i * 8)) as *mut GuestIovec;
let iov_base = emscripten_memory_pointer!(ctx.memory(0), (*guest_iov_addr).iov_base)
as *const c_void;
let iov_len = (*guest_iov_addr).iov_len as _;
// debug!("=> iov_addr: {:?}, {:?}", iov_base, iov_len);
let curr = write(fd, iov_base, iov_len);
Squashed commit of the following: commit 62d9da4e3e02251a0f61c904e826bc06cf964ff7 Author: Syrus <me@syrusakbary.com> Date: Sun Jul 7 18:16:34 2019 -0700 Fixed syscall221 commit a8fde9148d50d89616d8a85a68110b89e3273229 Author: Syrus <me@syrusakbary.com> Date: Sun Jul 7 18:16:04 2019 -0700 Improved ioctl use case commit 5ad109d39838624ad84232a4c17714b885835893 Merge: 61526e2c 5cab8161 Author: Syrus <me@syrusakbary.com> Date: Sun Jul 7 17:44:25 2019 -0700 Merge branch 'command/dash' into feature/emscripten-update commit 5cab816193d47d53aabb4be4ccaf448dca5ed0b2 Author: Jesús Leganés-Combarro 'piranna <piranna@gmail.com> Date: Sat Jul 6 20:11:49 2019 +0200 Generic IOCTLs mapping commit 5a0dc0374cdc5a3754e3ecc82584288df640d239 Merge: 61cfed79 9d120ed3 Author: Jesús Leganés-Combarro 'piranna <piranna@gmail.com> Date: Sat Jul 6 17:15:02 2019 +0200 Merge remote-tracking branch 'origin/master' into command/dash commit 61cfed7916078602eabbd4448b109f47dcfff1e8 Author: Jesús Leganés-Combarro 'piranna <piranna@gmail.com> Date: Sat Jul 6 13:04:04 2019 +0200 Fixed implementation for syscalls 200, 201 and 202 commit 91e26d1a0ee46d6f9ec4804ca13ca928d55e7bbb Author: Jesús Leganés-Combarro 'piranna <piranna@gmail.com> Date: Sat Jul 6 13:03:26 2019 +0200 Improved debug messages commit 53a8fbeb2a0912e928609f0afcea6ffb1e911193 Author: Jesús Leganés-Combarro 'piranna <piranna@gmail.com> Date: Sat Jul 6 13:03:04 2019 +0200 [___syscall146] Move loop out of `unsafe` zone commit d6dd3696f10f4cbb0722321bd9d06e45a9d464ac Author: Jesús Leganés-Combarro 'piranna <piranna@gmail.com> Date: Sat Jul 6 13:01:31 2019 +0200 [___syscall140] Fixed types commit c827a6a99346535764e22bfb5ab9147a52a0a543 Merge: 2bc16826 5e18d04d Author: Jesús Leganés-Combarro 'piranna <piranna@gmail.com> Date: Sat Jul 6 12:21:33 2019 +0200 Merge remote-tracking branch 'origin/master' into command/dash commit 2bc16826b5923dba56243fe3bd99f4be8a09c990 Author: Jesús Leganés-Combarro 'piranna <piranna@gmail.com> Date: Thu Jul 4 07:05:00 2019 +0200 Implement `getpgid` syscall commit d464954f5803e4d84b6f94dc9ef87cc577aa9c65 Author: Jesús Leganés-Combarro 'piranna <piranna@gmail.com> Date: Thu Jul 4 07:04:36 2019 +0200 [fcntl64] Replace mock for real implementation commit 3fe0183d853624bcdc968a890ac36ff7062905a7 Author: Jesús Leganés-Combarro 'piranna <piranna@gmail.com> Date: Thu Jul 4 07:03:39 2019 +0200 [ioctl] No-of for `TIOCSPGRP` command & code clean-up commit cc83ec9ac1cf1ad60748fd3bb5114a6e6e471d92 Author: Jesús Leganés-Combarro 'piranna <piranna@gmail.com> Date: Thu Jul 4 07:02:47 2019 +0200 [___syscall5] debug messages commit 91587c8bde9d2b02402a7843f37eee22322d86fb Author: Jesús Leganés-Combarro 'piranna <piranna@gmail.com> Date: Thu Jul 4 07:02:20 2019 +0200 [___syscall57] debug messages
2019-07-07 19:35:09 -07:00
debug!(
"=> iov_base: {}, iov_len: {}, curr = {}",
(*guest_iov_addr).iov_base,
iov_len,
curr
);
if curr < 0 {
Squashed commit of the following: commit 62d9da4e3e02251a0f61c904e826bc06cf964ff7 Author: Syrus <me@syrusakbary.com> Date: Sun Jul 7 18:16:34 2019 -0700 Fixed syscall221 commit a8fde9148d50d89616d8a85a68110b89e3273229 Author: Syrus <me@syrusakbary.com> Date: Sun Jul 7 18:16:04 2019 -0700 Improved ioctl use case commit 5ad109d39838624ad84232a4c17714b885835893 Merge: 61526e2c 5cab8161 Author: Syrus <me@syrusakbary.com> Date: Sun Jul 7 17:44:25 2019 -0700 Merge branch 'command/dash' into feature/emscripten-update commit 5cab816193d47d53aabb4be4ccaf448dca5ed0b2 Author: Jesús Leganés-Combarro 'piranna <piranna@gmail.com> Date: Sat Jul 6 20:11:49 2019 +0200 Generic IOCTLs mapping commit 5a0dc0374cdc5a3754e3ecc82584288df640d239 Merge: 61cfed79 9d120ed3 Author: Jesús Leganés-Combarro 'piranna <piranna@gmail.com> Date: Sat Jul 6 17:15:02 2019 +0200 Merge remote-tracking branch 'origin/master' into command/dash commit 61cfed7916078602eabbd4448b109f47dcfff1e8 Author: Jesús Leganés-Combarro 'piranna <piranna@gmail.com> Date: Sat Jul 6 13:04:04 2019 +0200 Fixed implementation for syscalls 200, 201 and 202 commit 91e26d1a0ee46d6f9ec4804ca13ca928d55e7bbb Author: Jesús Leganés-Combarro 'piranna <piranna@gmail.com> Date: Sat Jul 6 13:03:26 2019 +0200 Improved debug messages commit 53a8fbeb2a0912e928609f0afcea6ffb1e911193 Author: Jesús Leganés-Combarro 'piranna <piranna@gmail.com> Date: Sat Jul 6 13:03:04 2019 +0200 [___syscall146] Move loop out of `unsafe` zone commit d6dd3696f10f4cbb0722321bd9d06e45a9d464ac Author: Jesús Leganés-Combarro 'piranna <piranna@gmail.com> Date: Sat Jul 6 13:01:31 2019 +0200 [___syscall140] Fixed types commit c827a6a99346535764e22bfb5ab9147a52a0a543 Merge: 2bc16826 5e18d04d Author: Jesús Leganés-Combarro 'piranna <piranna@gmail.com> Date: Sat Jul 6 12:21:33 2019 +0200 Merge remote-tracking branch 'origin/master' into command/dash commit 2bc16826b5923dba56243fe3bd99f4be8a09c990 Author: Jesús Leganés-Combarro 'piranna <piranna@gmail.com> Date: Thu Jul 4 07:05:00 2019 +0200 Implement `getpgid` syscall commit d464954f5803e4d84b6f94dc9ef87cc577aa9c65 Author: Jesús Leganés-Combarro 'piranna <piranna@gmail.com> Date: Thu Jul 4 07:04:36 2019 +0200 [fcntl64] Replace mock for real implementation commit 3fe0183d853624bcdc968a890ac36ff7062905a7 Author: Jesús Leganés-Combarro 'piranna <piranna@gmail.com> Date: Thu Jul 4 07:03:39 2019 +0200 [ioctl] No-of for `TIOCSPGRP` command & code clean-up commit cc83ec9ac1cf1ad60748fd3bb5114a6e6e471d92 Author: Jesús Leganés-Combarro 'piranna <piranna@gmail.com> Date: Thu Jul 4 07:02:47 2019 +0200 [___syscall5] debug messages commit 91587c8bde9d2b02402a7843f37eee22322d86fb Author: Jesús Leganés-Combarro 'piranna <piranna@gmail.com> Date: Thu Jul 4 07:02:20 2019 +0200 [___syscall57] debug messages
2019-07-07 19:35:09 -07:00
debug!("=> os error: {}", Error::last_os_error());
return -1;
}
ret += curr;
}
}
Squashed commit of the following: commit 62d9da4e3e02251a0f61c904e826bc06cf964ff7 Author: Syrus <me@syrusakbary.com> Date: Sun Jul 7 18:16:34 2019 -0700 Fixed syscall221 commit a8fde9148d50d89616d8a85a68110b89e3273229 Author: Syrus <me@syrusakbary.com> Date: Sun Jul 7 18:16:04 2019 -0700 Improved ioctl use case commit 5ad109d39838624ad84232a4c17714b885835893 Merge: 61526e2c 5cab8161 Author: Syrus <me@syrusakbary.com> Date: Sun Jul 7 17:44:25 2019 -0700 Merge branch 'command/dash' into feature/emscripten-update commit 5cab816193d47d53aabb4be4ccaf448dca5ed0b2 Author: Jesús Leganés-Combarro 'piranna <piranna@gmail.com> Date: Sat Jul 6 20:11:49 2019 +0200 Generic IOCTLs mapping commit 5a0dc0374cdc5a3754e3ecc82584288df640d239 Merge: 61cfed79 9d120ed3 Author: Jesús Leganés-Combarro 'piranna <piranna@gmail.com> Date: Sat Jul 6 17:15:02 2019 +0200 Merge remote-tracking branch 'origin/master' into command/dash commit 61cfed7916078602eabbd4448b109f47dcfff1e8 Author: Jesús Leganés-Combarro 'piranna <piranna@gmail.com> Date: Sat Jul 6 13:04:04 2019 +0200 Fixed implementation for syscalls 200, 201 and 202 commit 91e26d1a0ee46d6f9ec4804ca13ca928d55e7bbb Author: Jesús Leganés-Combarro 'piranna <piranna@gmail.com> Date: Sat Jul 6 13:03:26 2019 +0200 Improved debug messages commit 53a8fbeb2a0912e928609f0afcea6ffb1e911193 Author: Jesús Leganés-Combarro 'piranna <piranna@gmail.com> Date: Sat Jul 6 13:03:04 2019 +0200 [___syscall146] Move loop out of `unsafe` zone commit d6dd3696f10f4cbb0722321bd9d06e45a9d464ac Author: Jesús Leganés-Combarro 'piranna <piranna@gmail.com> Date: Sat Jul 6 13:01:31 2019 +0200 [___syscall140] Fixed types commit c827a6a99346535764e22bfb5ab9147a52a0a543 Merge: 2bc16826 5e18d04d Author: Jesús Leganés-Combarro 'piranna <piranna@gmail.com> Date: Sat Jul 6 12:21:33 2019 +0200 Merge remote-tracking branch 'origin/master' into command/dash commit 2bc16826b5923dba56243fe3bd99f4be8a09c990 Author: Jesús Leganés-Combarro 'piranna <piranna@gmail.com> Date: Thu Jul 4 07:05:00 2019 +0200 Implement `getpgid` syscall commit d464954f5803e4d84b6f94dc9ef87cc577aa9c65 Author: Jesús Leganés-Combarro 'piranna <piranna@gmail.com> Date: Thu Jul 4 07:04:36 2019 +0200 [fcntl64] Replace mock for real implementation commit 3fe0183d853624bcdc968a890ac36ff7062905a7 Author: Jesús Leganés-Combarro 'piranna <piranna@gmail.com> Date: Thu Jul 4 07:03:39 2019 +0200 [ioctl] No-of for `TIOCSPGRP` command & code clean-up commit cc83ec9ac1cf1ad60748fd3bb5114a6e6e471d92 Author: Jesús Leganés-Combarro 'piranna <piranna@gmail.com> Date: Thu Jul 4 07:02:47 2019 +0200 [___syscall5] debug messages commit 91587c8bde9d2b02402a7843f37eee22322d86fb Author: Jesús Leganés-Combarro 'piranna <piranna@gmail.com> Date: Thu Jul 4 07:02:20 2019 +0200 [___syscall57] debug messages
2019-07-07 19:35:09 -07:00
debug!(" => ret: {}", ret);
ret as _
}
2019-06-06 11:55:05 -07:00
pub fn ___syscall191(ctx: &mut Ctx, _which: i32, mut varargs: VarArgs) -> i32 {
let _resource: i32 = varargs.get(ctx);
debug!(
"emscripten::___syscall191 - mostly stub, resource: {}",
_resource
);
let rlim_emptr: i32 = varargs.get(ctx);
let rlim_ptr = emscripten_memory_pointer!(ctx.memory(0), rlim_emptr) as *mut u8;
let rlim = unsafe { slice::from_raw_parts_mut(rlim_ptr, 16) };
// set all to RLIM_INIFINTY
LittleEndian::write_i64(&mut rlim[..], -1);
LittleEndian::write_i64(&mut rlim[8..], -1);
2019-06-06 11:55:05 -07:00
0
}
pub fn ___syscall193(_ctx: &mut Ctx, _one: i32, _two: i32) -> i32 {
debug!("emscripten::___syscall193");
-1
}
// stat64
fix(emscripten) Various warning fixes and cleanups (#266) * fix(emscripten) Remove unused imports. This patch removes unused imports reported by `rustc` as warnings. * fix(emscripten) Allow unreachable patterns in `_clock_gettime`. The compiler thinks `CLOCK_MONOTONIC_COARSE` is unreachable, which is not always the case. Add an attribute to allow unreachable patterns to remove the warning. * fix(emscripten) Rename unused variables. This patch renames various unused variables by appending an underscore to them. * fix(emscripten) Declare `table` as immutable. The `table` variable in `EmscriptenGlobals::new` was declared as mutable, but it's never mutated. * fix(emscripten) Remove an unnecessary `unsafe` block. * fix(emscripten) Remove duplicate definition of `SO_NOSIGPIPE`. The `SO_NOSIGPIPE` constant is defined in `syscalls/mod.rs` and `syscalls/unix.rs`. It's never used in the first case. We can safely remove it in this file, and keep it in `unix.rs`. * fix(emscripten) `read_string_from_wasm` is used only on Windows. Mark `read_string_from_wasm` as possible deadcode, since it's used only on Windows. * fix(emscripten) Remove `DYNAMICTOP_PTR_DIFF`, `stacktop`, `stack_max`, `dynamic_base` and `dynamic_ptr`. Four functions and one constant are used together but never used inside or outside this file. They are deadcode. * fix(emscripten) Remove `infinity` and `nan` fields of `EmscriptenGlobalsData`. Those fields are never used. * fix(emscripten) Allow non snake case in `emscripten_target.rs`. Many functions in this file don't follow the snake case style for Rust function names. The reason is that we want the names to match the emscripten symbol names; even if a mapping is done in `lib.rs`, it's easier to get the same names. * fix(emscripten) Rename `STATIC_TOP` to `static_top`. This variable is not a constant.
2019-03-12 22:00:33 +01:00
pub fn ___syscall195(ctx: &mut Ctx, _which: c_int, mut varargs: VarArgs) -> c_int {
debug!("emscripten::___syscall195 (stat64) {}", _which);
let pathname_addr = varargs.get_str(ctx);
let buf: u32 = 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
};
unsafe {
let mut _stat: stat = std::mem::zeroed();
let ret = stat(real_path, &mut _stat);
2019-03-25 16:13:41 -07:00
debug!(
Squashed commit of the following: commit 62d9da4e3e02251a0f61c904e826bc06cf964ff7 Author: Syrus <me@syrusakbary.com> Date: Sun Jul 7 18:16:34 2019 -0700 Fixed syscall221 commit a8fde9148d50d89616d8a85a68110b89e3273229 Author: Syrus <me@syrusakbary.com> Date: Sun Jul 7 18:16:04 2019 -0700 Improved ioctl use case commit 5ad109d39838624ad84232a4c17714b885835893 Merge: 61526e2c 5cab8161 Author: Syrus <me@syrusakbary.com> Date: Sun Jul 7 17:44:25 2019 -0700 Merge branch 'command/dash' into feature/emscripten-update commit 5cab816193d47d53aabb4be4ccaf448dca5ed0b2 Author: Jesús Leganés-Combarro 'piranna <piranna@gmail.com> Date: Sat Jul 6 20:11:49 2019 +0200 Generic IOCTLs mapping commit 5a0dc0374cdc5a3754e3ecc82584288df640d239 Merge: 61cfed79 9d120ed3 Author: Jesús Leganés-Combarro 'piranna <piranna@gmail.com> Date: Sat Jul 6 17:15:02 2019 +0200 Merge remote-tracking branch 'origin/master' into command/dash commit 61cfed7916078602eabbd4448b109f47dcfff1e8 Author: Jesús Leganés-Combarro 'piranna <piranna@gmail.com> Date: Sat Jul 6 13:04:04 2019 +0200 Fixed implementation for syscalls 200, 201 and 202 commit 91e26d1a0ee46d6f9ec4804ca13ca928d55e7bbb Author: Jesús Leganés-Combarro 'piranna <piranna@gmail.com> Date: Sat Jul 6 13:03:26 2019 +0200 Improved debug messages commit 53a8fbeb2a0912e928609f0afcea6ffb1e911193 Author: Jesús Leganés-Combarro 'piranna <piranna@gmail.com> Date: Sat Jul 6 13:03:04 2019 +0200 [___syscall146] Move loop out of `unsafe` zone commit d6dd3696f10f4cbb0722321bd9d06e45a9d464ac Author: Jesús Leganés-Combarro 'piranna <piranna@gmail.com> Date: Sat Jul 6 13:01:31 2019 +0200 [___syscall140] Fixed types commit c827a6a99346535764e22bfb5ab9147a52a0a543 Merge: 2bc16826 5e18d04d Author: Jesús Leganés-Combarro 'piranna <piranna@gmail.com> Date: Sat Jul 6 12:21:33 2019 +0200 Merge remote-tracking branch 'origin/master' into command/dash commit 2bc16826b5923dba56243fe3bd99f4be8a09c990 Author: Jesús Leganés-Combarro 'piranna <piranna@gmail.com> Date: Thu Jul 4 07:05:00 2019 +0200 Implement `getpgid` syscall commit d464954f5803e4d84b6f94dc9ef87cc577aa9c65 Author: Jesús Leganés-Combarro 'piranna <piranna@gmail.com> Date: Thu Jul 4 07:04:36 2019 +0200 [fcntl64] Replace mock for real implementation commit 3fe0183d853624bcdc968a890ac36ff7062905a7 Author: Jesús Leganés-Combarro 'piranna <piranna@gmail.com> Date: Thu Jul 4 07:03:39 2019 +0200 [ioctl] No-of for `TIOCSPGRP` command & code clean-up commit cc83ec9ac1cf1ad60748fd3bb5114a6e6e471d92 Author: Jesús Leganés-Combarro 'piranna <piranna@gmail.com> Date: Thu Jul 4 07:02:47 2019 +0200 [___syscall5] debug messages commit 91587c8bde9d2b02402a7843f37eee22322d86fb Author: Jesús Leganés-Combarro 'piranna <piranna@gmail.com> Date: Thu Jul 4 07:02:20 2019 +0200 [___syscall57] debug messages
2019-07-07 19:35:09 -07:00
"=> pathname: {}, buf: {} = {}",
std::ffi::CStr::from_ptr(real_path).to_str().unwrap(),
buf,
Squashed commit of the following: commit 62d9da4e3e02251a0f61c904e826bc06cf964ff7 Author: Syrus <me@syrusakbary.com> Date: Sun Jul 7 18:16:34 2019 -0700 Fixed syscall221 commit a8fde9148d50d89616d8a85a68110b89e3273229 Author: Syrus <me@syrusakbary.com> Date: Sun Jul 7 18:16:04 2019 -0700 Improved ioctl use case commit 5ad109d39838624ad84232a4c17714b885835893 Merge: 61526e2c 5cab8161 Author: Syrus <me@syrusakbary.com> Date: Sun Jul 7 17:44:25 2019 -0700 Merge branch 'command/dash' into feature/emscripten-update commit 5cab816193d47d53aabb4be4ccaf448dca5ed0b2 Author: Jesús Leganés-Combarro 'piranna <piranna@gmail.com> Date: Sat Jul 6 20:11:49 2019 +0200 Generic IOCTLs mapping commit 5a0dc0374cdc5a3754e3ecc82584288df640d239 Merge: 61cfed79 9d120ed3 Author: Jesús Leganés-Combarro 'piranna <piranna@gmail.com> Date: Sat Jul 6 17:15:02 2019 +0200 Merge remote-tracking branch 'origin/master' into command/dash commit 61cfed7916078602eabbd4448b109f47dcfff1e8 Author: Jesús Leganés-Combarro 'piranna <piranna@gmail.com> Date: Sat Jul 6 13:04:04 2019 +0200 Fixed implementation for syscalls 200, 201 and 202 commit 91e26d1a0ee46d6f9ec4804ca13ca928d55e7bbb Author: Jesús Leganés-Combarro 'piranna <piranna@gmail.com> Date: Sat Jul 6 13:03:26 2019 +0200 Improved debug messages commit 53a8fbeb2a0912e928609f0afcea6ffb1e911193 Author: Jesús Leganés-Combarro 'piranna <piranna@gmail.com> Date: Sat Jul 6 13:03:04 2019 +0200 [___syscall146] Move loop out of `unsafe` zone commit d6dd3696f10f4cbb0722321bd9d06e45a9d464ac Author: Jesús Leganés-Combarro 'piranna <piranna@gmail.com> Date: Sat Jul 6 13:01:31 2019 +0200 [___syscall140] Fixed types commit c827a6a99346535764e22bfb5ab9147a52a0a543 Merge: 2bc16826 5e18d04d Author: Jesús Leganés-Combarro 'piranna <piranna@gmail.com> Date: Sat Jul 6 12:21:33 2019 +0200 Merge remote-tracking branch 'origin/master' into command/dash commit 2bc16826b5923dba56243fe3bd99f4be8a09c990 Author: Jesús Leganés-Combarro 'piranna <piranna@gmail.com> Date: Thu Jul 4 07:05:00 2019 +0200 Implement `getpgid` syscall commit d464954f5803e4d84b6f94dc9ef87cc577aa9c65 Author: Jesús Leganés-Combarro 'piranna <piranna@gmail.com> Date: Thu Jul 4 07:04:36 2019 +0200 [fcntl64] Replace mock for real implementation commit 3fe0183d853624bcdc968a890ac36ff7062905a7 Author: Jesús Leganés-Combarro 'piranna <piranna@gmail.com> Date: Thu Jul 4 07:03:39 2019 +0200 [ioctl] No-of for `TIOCSPGRP` command & code clean-up commit cc83ec9ac1cf1ad60748fd3bb5114a6e6e471d92 Author: Jesús Leganés-Combarro 'piranna <piranna@gmail.com> Date: Thu Jul 4 07:02:47 2019 +0200 [___syscall5] debug messages commit 91587c8bde9d2b02402a7843f37eee22322d86fb Author: Jesús Leganés-Combarro 'piranna <piranna@gmail.com> Date: Thu Jul 4 07:02:20 2019 +0200 [___syscall57] debug messages
2019-07-07 19:35:09 -07:00
ret
2019-03-25 16:13:41 -07:00
);
if ret != 0 {
Squashed commit of the following: commit 62d9da4e3e02251a0f61c904e826bc06cf964ff7 Author: Syrus <me@syrusakbary.com> Date: Sun Jul 7 18:16:34 2019 -0700 Fixed syscall221 commit a8fde9148d50d89616d8a85a68110b89e3273229 Author: Syrus <me@syrusakbary.com> Date: Sun Jul 7 18:16:04 2019 -0700 Improved ioctl use case commit 5ad109d39838624ad84232a4c17714b885835893 Merge: 61526e2c 5cab8161 Author: Syrus <me@syrusakbary.com> Date: Sun Jul 7 17:44:25 2019 -0700 Merge branch 'command/dash' into feature/emscripten-update commit 5cab816193d47d53aabb4be4ccaf448dca5ed0b2 Author: Jesús Leganés-Combarro 'piranna <piranna@gmail.com> Date: Sat Jul 6 20:11:49 2019 +0200 Generic IOCTLs mapping commit 5a0dc0374cdc5a3754e3ecc82584288df640d239 Merge: 61cfed79 9d120ed3 Author: Jesús Leganés-Combarro 'piranna <piranna@gmail.com> Date: Sat Jul 6 17:15:02 2019 +0200 Merge remote-tracking branch 'origin/master' into command/dash commit 61cfed7916078602eabbd4448b109f47dcfff1e8 Author: Jesús Leganés-Combarro 'piranna <piranna@gmail.com> Date: Sat Jul 6 13:04:04 2019 +0200 Fixed implementation for syscalls 200, 201 and 202 commit 91e26d1a0ee46d6f9ec4804ca13ca928d55e7bbb Author: Jesús Leganés-Combarro 'piranna <piranna@gmail.com> Date: Sat Jul 6 13:03:26 2019 +0200 Improved debug messages commit 53a8fbeb2a0912e928609f0afcea6ffb1e911193 Author: Jesús Leganés-Combarro 'piranna <piranna@gmail.com> Date: Sat Jul 6 13:03:04 2019 +0200 [___syscall146] Move loop out of `unsafe` zone commit d6dd3696f10f4cbb0722321bd9d06e45a9d464ac Author: Jesús Leganés-Combarro 'piranna <piranna@gmail.com> Date: Sat Jul 6 13:01:31 2019 +0200 [___syscall140] Fixed types commit c827a6a99346535764e22bfb5ab9147a52a0a543 Merge: 2bc16826 5e18d04d Author: Jesús Leganés-Combarro 'piranna <piranna@gmail.com> Date: Sat Jul 6 12:21:33 2019 +0200 Merge remote-tracking branch 'origin/master' into command/dash commit 2bc16826b5923dba56243fe3bd99f4be8a09c990 Author: Jesús Leganés-Combarro 'piranna <piranna@gmail.com> Date: Thu Jul 4 07:05:00 2019 +0200 Implement `getpgid` syscall commit d464954f5803e4d84b6f94dc9ef87cc577aa9c65 Author: Jesús Leganés-Combarro 'piranna <piranna@gmail.com> Date: Thu Jul 4 07:04:36 2019 +0200 [fcntl64] Replace mock for real implementation commit 3fe0183d853624bcdc968a890ac36ff7062905a7 Author: Jesús Leganés-Combarro 'piranna <piranna@gmail.com> Date: Thu Jul 4 07:03:39 2019 +0200 [ioctl] No-of for `TIOCSPGRP` command & code clean-up commit cc83ec9ac1cf1ad60748fd3bb5114a6e6e471d92 Author: Jesús Leganés-Combarro 'piranna <piranna@gmail.com> Date: Thu Jul 4 07:02:47 2019 +0200 [___syscall5] debug messages commit 91587c8bde9d2b02402a7843f37eee22322d86fb Author: Jesús Leganés-Combarro 'piranna <piranna@gmail.com> Date: Thu Jul 4 07:02:20 2019 +0200 [___syscall57] debug messages
2019-07-07 19:35:09 -07:00
debug!("=> os error: {}", Error::last_os_error());
return ret;
}
copy_stat_into_wasm(ctx, buf, &_stat);
}
0
}
// fstat64
fix(emscripten) Various warning fixes and cleanups (#266) * fix(emscripten) Remove unused imports. This patch removes unused imports reported by `rustc` as warnings. * fix(emscripten) Allow unreachable patterns in `_clock_gettime`. The compiler thinks `CLOCK_MONOTONIC_COARSE` is unreachable, which is not always the case. Add an attribute to allow unreachable patterns to remove the warning. * fix(emscripten) Rename unused variables. This patch renames various unused variables by appending an underscore to them. * fix(emscripten) Declare `table` as immutable. The `table` variable in `EmscriptenGlobals::new` was declared as mutable, but it's never mutated. * fix(emscripten) Remove an unnecessary `unsafe` block. * fix(emscripten) Remove duplicate definition of `SO_NOSIGPIPE`. The `SO_NOSIGPIPE` constant is defined in `syscalls/mod.rs` and `syscalls/unix.rs`. It's never used in the first case. We can safely remove it in this file, and keep it in `unix.rs`. * fix(emscripten) `read_string_from_wasm` is used only on Windows. Mark `read_string_from_wasm` as possible deadcode, since it's used only on Windows. * fix(emscripten) Remove `DYNAMICTOP_PTR_DIFF`, `stacktop`, `stack_max`, `dynamic_base` and `dynamic_ptr`. Four functions and one constant are used together but never used inside or outside this file. They are deadcode. * fix(emscripten) Remove `infinity` and `nan` fields of `EmscriptenGlobalsData`. Those fields are never used. * fix(emscripten) Allow non snake case in `emscripten_target.rs`. Many functions in this file don't follow the snake case style for Rust function names. The reason is that we want the names to match the emscripten symbol names; even if a mapping is done in `lib.rs`, it's easier to get the same names. * fix(emscripten) Rename `STATIC_TOP` to `static_top`. This variable is not a constant.
2019-03-12 22:00:33 +01:00
pub fn ___syscall197(ctx: &mut Ctx, _which: c_int, mut varargs: VarArgs) -> c_int {
debug!("emscripten::___syscall197 (fstat64) {}", _which);
Squashed commit of the following: commit 62d9da4e3e02251a0f61c904e826bc06cf964ff7 Author: Syrus <me@syrusakbary.com> Date: Sun Jul 7 18:16:34 2019 -0700 Fixed syscall221 commit a8fde9148d50d89616d8a85a68110b89e3273229 Author: Syrus <me@syrusakbary.com> Date: Sun Jul 7 18:16:04 2019 -0700 Improved ioctl use case commit 5ad109d39838624ad84232a4c17714b885835893 Merge: 61526e2c 5cab8161 Author: Syrus <me@syrusakbary.com> Date: Sun Jul 7 17:44:25 2019 -0700 Merge branch 'command/dash' into feature/emscripten-update commit 5cab816193d47d53aabb4be4ccaf448dca5ed0b2 Author: Jesús Leganés-Combarro 'piranna <piranna@gmail.com> Date: Sat Jul 6 20:11:49 2019 +0200 Generic IOCTLs mapping commit 5a0dc0374cdc5a3754e3ecc82584288df640d239 Merge: 61cfed79 9d120ed3 Author: Jesús Leganés-Combarro 'piranna <piranna@gmail.com> Date: Sat Jul 6 17:15:02 2019 +0200 Merge remote-tracking branch 'origin/master' into command/dash commit 61cfed7916078602eabbd4448b109f47dcfff1e8 Author: Jesús Leganés-Combarro 'piranna <piranna@gmail.com> Date: Sat Jul 6 13:04:04 2019 +0200 Fixed implementation for syscalls 200, 201 and 202 commit 91e26d1a0ee46d6f9ec4804ca13ca928d55e7bbb Author: Jesús Leganés-Combarro 'piranna <piranna@gmail.com> Date: Sat Jul 6 13:03:26 2019 +0200 Improved debug messages commit 53a8fbeb2a0912e928609f0afcea6ffb1e911193 Author: Jesús Leganés-Combarro 'piranna <piranna@gmail.com> Date: Sat Jul 6 13:03:04 2019 +0200 [___syscall146] Move loop out of `unsafe` zone commit d6dd3696f10f4cbb0722321bd9d06e45a9d464ac Author: Jesús Leganés-Combarro 'piranna <piranna@gmail.com> Date: Sat Jul 6 13:01:31 2019 +0200 [___syscall140] Fixed types commit c827a6a99346535764e22bfb5ab9147a52a0a543 Merge: 2bc16826 5e18d04d Author: Jesús Leganés-Combarro 'piranna <piranna@gmail.com> Date: Sat Jul 6 12:21:33 2019 +0200 Merge remote-tracking branch 'origin/master' into command/dash commit 2bc16826b5923dba56243fe3bd99f4be8a09c990 Author: Jesús Leganés-Combarro 'piranna <piranna@gmail.com> Date: Thu Jul 4 07:05:00 2019 +0200 Implement `getpgid` syscall commit d464954f5803e4d84b6f94dc9ef87cc577aa9c65 Author: Jesús Leganés-Combarro 'piranna <piranna@gmail.com> Date: Thu Jul 4 07:04:36 2019 +0200 [fcntl64] Replace mock for real implementation commit 3fe0183d853624bcdc968a890ac36ff7062905a7 Author: Jesús Leganés-Combarro 'piranna <piranna@gmail.com> Date: Thu Jul 4 07:03:39 2019 +0200 [ioctl] No-of for `TIOCSPGRP` command & code clean-up commit cc83ec9ac1cf1ad60748fd3bb5114a6e6e471d92 Author: Jesús Leganés-Combarro 'piranna <piranna@gmail.com> Date: Thu Jul 4 07:02:47 2019 +0200 [___syscall5] debug messages commit 91587c8bde9d2b02402a7843f37eee22322d86fb Author: Jesús Leganés-Combarro 'piranna <piranna@gmail.com> Date: Thu Jul 4 07:02:20 2019 +0200 [___syscall57] debug messages
2019-07-07 19:35:09 -07:00
let fd: c_int = varargs.get(ctx);
let buf: u32 = varargs.get(ctx);
unsafe {
let mut stat = std::mem::zeroed();
let ret = fstat(fd, &mut stat);
Squashed commit of the following: commit 62d9da4e3e02251a0f61c904e826bc06cf964ff7 Author: Syrus <me@syrusakbary.com> Date: Sun Jul 7 18:16:34 2019 -0700 Fixed syscall221 commit a8fde9148d50d89616d8a85a68110b89e3273229 Author: Syrus <me@syrusakbary.com> Date: Sun Jul 7 18:16:04 2019 -0700 Improved ioctl use case commit 5ad109d39838624ad84232a4c17714b885835893 Merge: 61526e2c 5cab8161 Author: Syrus <me@syrusakbary.com> Date: Sun Jul 7 17:44:25 2019 -0700 Merge branch 'command/dash' into feature/emscripten-update commit 5cab816193d47d53aabb4be4ccaf448dca5ed0b2 Author: Jesús Leganés-Combarro 'piranna <piranna@gmail.com> Date: Sat Jul 6 20:11:49 2019 +0200 Generic IOCTLs mapping commit 5a0dc0374cdc5a3754e3ecc82584288df640d239 Merge: 61cfed79 9d120ed3 Author: Jesús Leganés-Combarro 'piranna <piranna@gmail.com> Date: Sat Jul 6 17:15:02 2019 +0200 Merge remote-tracking branch 'origin/master' into command/dash commit 61cfed7916078602eabbd4448b109f47dcfff1e8 Author: Jesús Leganés-Combarro 'piranna <piranna@gmail.com> Date: Sat Jul 6 13:04:04 2019 +0200 Fixed implementation for syscalls 200, 201 and 202 commit 91e26d1a0ee46d6f9ec4804ca13ca928d55e7bbb Author: Jesús Leganés-Combarro 'piranna <piranna@gmail.com> Date: Sat Jul 6 13:03:26 2019 +0200 Improved debug messages commit 53a8fbeb2a0912e928609f0afcea6ffb1e911193 Author: Jesús Leganés-Combarro 'piranna <piranna@gmail.com> Date: Sat Jul 6 13:03:04 2019 +0200 [___syscall146] Move loop out of `unsafe` zone commit d6dd3696f10f4cbb0722321bd9d06e45a9d464ac Author: Jesús Leganés-Combarro 'piranna <piranna@gmail.com> Date: Sat Jul 6 13:01:31 2019 +0200 [___syscall140] Fixed types commit c827a6a99346535764e22bfb5ab9147a52a0a543 Merge: 2bc16826 5e18d04d Author: Jesús Leganés-Combarro 'piranna <piranna@gmail.com> Date: Sat Jul 6 12:21:33 2019 +0200 Merge remote-tracking branch 'origin/master' into command/dash commit 2bc16826b5923dba56243fe3bd99f4be8a09c990 Author: Jesús Leganés-Combarro 'piranna <piranna@gmail.com> Date: Thu Jul 4 07:05:00 2019 +0200 Implement `getpgid` syscall commit d464954f5803e4d84b6f94dc9ef87cc577aa9c65 Author: Jesús Leganés-Combarro 'piranna <piranna@gmail.com> Date: Thu Jul 4 07:04:36 2019 +0200 [fcntl64] Replace mock for real implementation commit 3fe0183d853624bcdc968a890ac36ff7062905a7 Author: Jesús Leganés-Combarro 'piranna <piranna@gmail.com> Date: Thu Jul 4 07:03:39 2019 +0200 [ioctl] No-of for `TIOCSPGRP` command & code clean-up commit cc83ec9ac1cf1ad60748fd3bb5114a6e6e471d92 Author: Jesús Leganés-Combarro 'piranna <piranna@gmail.com> Date: Thu Jul 4 07:02:47 2019 +0200 [___syscall5] debug messages commit 91587c8bde9d2b02402a7843f37eee22322d86fb Author: Jesús Leganés-Combarro 'piranna <piranna@gmail.com> Date: Thu Jul 4 07:02:20 2019 +0200 [___syscall57] debug messages
2019-07-07 19:35:09 -07:00
debug!("=> fd: {}, buf: {} = {}", fd, buf, ret);
if ret != 0 {
Squashed commit of the following: commit 62d9da4e3e02251a0f61c904e826bc06cf964ff7 Author: Syrus <me@syrusakbary.com> Date: Sun Jul 7 18:16:34 2019 -0700 Fixed syscall221 commit a8fde9148d50d89616d8a85a68110b89e3273229 Author: Syrus <me@syrusakbary.com> Date: Sun Jul 7 18:16:04 2019 -0700 Improved ioctl use case commit 5ad109d39838624ad84232a4c17714b885835893 Merge: 61526e2c 5cab8161 Author: Syrus <me@syrusakbary.com> Date: Sun Jul 7 17:44:25 2019 -0700 Merge branch 'command/dash' into feature/emscripten-update commit 5cab816193d47d53aabb4be4ccaf448dca5ed0b2 Author: Jesús Leganés-Combarro 'piranna <piranna@gmail.com> Date: Sat Jul 6 20:11:49 2019 +0200 Generic IOCTLs mapping commit 5a0dc0374cdc5a3754e3ecc82584288df640d239 Merge: 61cfed79 9d120ed3 Author: Jesús Leganés-Combarro 'piranna <piranna@gmail.com> Date: Sat Jul 6 17:15:02 2019 +0200 Merge remote-tracking branch 'origin/master' into command/dash commit 61cfed7916078602eabbd4448b109f47dcfff1e8 Author: Jesús Leganés-Combarro 'piranna <piranna@gmail.com> Date: Sat Jul 6 13:04:04 2019 +0200 Fixed implementation for syscalls 200, 201 and 202 commit 91e26d1a0ee46d6f9ec4804ca13ca928d55e7bbb Author: Jesús Leganés-Combarro 'piranna <piranna@gmail.com> Date: Sat Jul 6 13:03:26 2019 +0200 Improved debug messages commit 53a8fbeb2a0912e928609f0afcea6ffb1e911193 Author: Jesús Leganés-Combarro 'piranna <piranna@gmail.com> Date: Sat Jul 6 13:03:04 2019 +0200 [___syscall146] Move loop out of `unsafe` zone commit d6dd3696f10f4cbb0722321bd9d06e45a9d464ac Author: Jesús Leganés-Combarro 'piranna <piranna@gmail.com> Date: Sat Jul 6 13:01:31 2019 +0200 [___syscall140] Fixed types commit c827a6a99346535764e22bfb5ab9147a52a0a543 Merge: 2bc16826 5e18d04d Author: Jesús Leganés-Combarro 'piranna <piranna@gmail.com> Date: Sat Jul 6 12:21:33 2019 +0200 Merge remote-tracking branch 'origin/master' into command/dash commit 2bc16826b5923dba56243fe3bd99f4be8a09c990 Author: Jesús Leganés-Combarro 'piranna <piranna@gmail.com> Date: Thu Jul 4 07:05:00 2019 +0200 Implement `getpgid` syscall commit d464954f5803e4d84b6f94dc9ef87cc577aa9c65 Author: Jesús Leganés-Combarro 'piranna <piranna@gmail.com> Date: Thu Jul 4 07:04:36 2019 +0200 [fcntl64] Replace mock for real implementation commit 3fe0183d853624bcdc968a890ac36ff7062905a7 Author: Jesús Leganés-Combarro 'piranna <piranna@gmail.com> Date: Thu Jul 4 07:03:39 2019 +0200 [ioctl] No-of for `TIOCSPGRP` command & code clean-up commit cc83ec9ac1cf1ad60748fd3bb5114a6e6e471d92 Author: Jesús Leganés-Combarro 'piranna <piranna@gmail.com> Date: Thu Jul 4 07:02:47 2019 +0200 [___syscall5] debug messages commit 91587c8bde9d2b02402a7843f37eee22322d86fb Author: Jesús Leganés-Combarro 'piranna <piranna@gmail.com> Date: Thu Jul 4 07:02:20 2019 +0200 [___syscall57] debug messages
2019-07-07 19:35:09 -07:00
debug!("=> os error: {}", Error::last_os_error());
return ret;
}
copy_stat_into_wasm(ctx, buf, &stat);
}
0
}
pub fn ___syscall209(_ctx: &mut Ctx, _one: i32, _two: i32) -> i32 {
debug!("emscripten::___syscall209");
-1
}
pub fn ___syscall211(_ctx: &mut Ctx, _one: i32, _two: i32) -> i32 {
debug!("emscripten::___syscall211");
-1
}
pub fn ___syscall218(_ctx: &mut Ctx, _one: i32, _two: i32) -> i32 {
debug!("emscripten::___syscall218");
-1
}
pub fn ___syscall268(_ctx: &mut Ctx, _one: i32, _two: i32) -> i32 {
debug!("emscripten::___syscall268");
-1
}
pub fn ___syscall269(_ctx: &mut Ctx, _one: i32, _two: i32) -> i32 {
debug!("emscripten::___syscall269");
-1
}
pub fn ___syscall272(_ctx: &mut Ctx, _one: i32, _two: i32) -> i32 {
debug!("emscripten::___syscall272");
-1
}
pub fn ___syscall295(_ctx: &mut Ctx, _one: i32, _two: i32) -> i32 {
debug!("emscripten::___syscall295");
-1
}
pub fn ___syscall296(_ctx: &mut Ctx, _one: i32, _two: i32) -> i32 {
debug!("emscripten::___syscall296");
-1
}
pub fn ___syscall297(_ctx: &mut Ctx, _one: i32, _two: i32) -> i32 {
debug!("emscripten::___syscall297");
-1
}
pub fn ___syscall298(_ctx: &mut Ctx, _one: i32, _two: i32) -> i32 {
debug!("emscripten::___syscall298");
-1
}
pub fn ___syscall300(_ctx: &mut Ctx, _one: i32, _two: i32) -> i32 {
debug!("emscripten::___syscall300");
-1
}
pub fn ___syscall301(_ctx: &mut Ctx, _one: i32, _two: i32) -> i32 {
debug!("emscripten::___syscall301");
-1
}
pub fn ___syscall302(_ctx: &mut Ctx, _one: i32, _two: i32) -> i32 {
debug!("emscripten::___syscall302");
-1
}
pub fn ___syscall303(_ctx: &mut Ctx, _one: i32, _two: i32) -> i32 {
debug!("emscripten::___syscall303");
-1
}
pub fn ___syscall304(_ctx: &mut Ctx, _one: i32, _two: i32) -> i32 {
debug!("emscripten::___syscall304");
-1
}
pub fn ___syscall305(_ctx: &mut Ctx, _one: i32, _two: i32) -> i32 {
debug!("emscripten::___syscall305");
-1
}
pub fn ___syscall306(_ctx: &mut Ctx, _one: i32, _two: i32) -> i32 {
debug!("emscripten::___syscall306");
-1
}
pub fn ___syscall307(_ctx: &mut Ctx, _one: i32, _two: i32) -> i32 {
debug!("emscripten::___syscall307");
-1
}
pub fn ___syscall308(_ctx: &mut Ctx, _one: i32, _two: i32) -> i32 {
debug!("emscripten::___syscall308");
-1
}
2019-05-05 11:24:57 -07:00
// utimensat
2019-05-06 14:17:23 -07:00
pub fn ___syscall320(_ctx: &mut Ctx, _which: c_int, mut _varargs: VarArgs) -> c_int {
2019-05-05 11:24:57 -07:00
debug!("emscripten::___syscall320 (utimensat), {}", _which);
0
}
pub fn ___syscall331(_ctx: &mut Ctx, _one: i32, _two: i32) -> i32 {
debug!("emscripten::___syscall331");
-1
}
pub fn ___syscall333(_ctx: &mut Ctx, _one: i32, _two: i32) -> i32 {
debug!("emscripten::___syscall333");
-1
}
pub fn ___syscall334(_ctx: &mut Ctx, _one: i32, _two: i32) -> i32 {
debug!("emscripten::___syscall334");
-1
}
pub fn ___syscall337(_ctx: &mut Ctx, _one: i32, _two: i32) -> i32 {
debug!("emscripten::___syscall337");
-1
}
// prlimit64
fix(emscripten) Various warning fixes and cleanups (#266) * fix(emscripten) Remove unused imports. This patch removes unused imports reported by `rustc` as warnings. * fix(emscripten) Allow unreachable patterns in `_clock_gettime`. The compiler thinks `CLOCK_MONOTONIC_COARSE` is unreachable, which is not always the case. Add an attribute to allow unreachable patterns to remove the warning. * fix(emscripten) Rename unused variables. This patch renames various unused variables by appending an underscore to them. * fix(emscripten) Declare `table` as immutable. The `table` variable in `EmscriptenGlobals::new` was declared as mutable, but it's never mutated. * fix(emscripten) Remove an unnecessary `unsafe` block. * fix(emscripten) Remove duplicate definition of `SO_NOSIGPIPE`. The `SO_NOSIGPIPE` constant is defined in `syscalls/mod.rs` and `syscalls/unix.rs`. It's never used in the first case. We can safely remove it in this file, and keep it in `unix.rs`. * fix(emscripten) `read_string_from_wasm` is used only on Windows. Mark `read_string_from_wasm` as possible deadcode, since it's used only on Windows. * fix(emscripten) Remove `DYNAMICTOP_PTR_DIFF`, `stacktop`, `stack_max`, `dynamic_base` and `dynamic_ptr`. Four functions and one constant are used together but never used inside or outside this file. They are deadcode. * fix(emscripten) Remove `infinity` and `nan` fields of `EmscriptenGlobalsData`. Those fields are never used. * fix(emscripten) Allow non snake case in `emscripten_target.rs`. Many functions in this file don't follow the snake case style for Rust function names. The reason is that we want the names to match the emscripten symbol names; even if a mapping is done in `lib.rs`, it's easier to get the same names. * fix(emscripten) Rename `STATIC_TOP` to `static_top`. This variable is not a constant.
2019-03-12 22:00:33 +01:00
pub fn ___syscall340(ctx: &mut Ctx, _which: c_int, mut varargs: VarArgs) -> c_int {
debug!("emscripten::___syscall340 (prlimit64), {}", _which);
// NOTE: Doesn't really matter. Wasm modules cannot exceed WASM_PAGE_SIZE anyway.
let _pid: i32 = varargs.get(ctx);
2019-06-06 11:55:05 -07:00
let resource: i32 = varargs.get(ctx);
let _new_limit: u32 = varargs.get(ctx);
let old_limit: u32 = varargs.get(ctx);
2019-06-06 11:55:05 -07:00
let val = match resource {
// RLIMIT_NOFILE
7 => 1024,
_ => -1, // RLIM_INFINITY
};
if old_limit != 0 {
// just report no limits
let buf_ptr = emscripten_memory_pointer!(ctx.memory(0), old_limit) as *mut u8;
let buf = unsafe { slice::from_raw_parts_mut(buf_ptr, 16) };
2019-06-06 11:55:05 -07:00
LittleEndian::write_i64(&mut buf[..], val);
LittleEndian::write_i64(&mut buf[8..], val);
}
0
}
pub fn ___syscall345(_ctx: &mut Ctx, _one: i32, _two: i32) -> i32 {
debug!("emscripten::___syscall345");
-1
}