add syscalls for sqlite3

This commit is contained in:
Mark McCaskey 2019-03-25 11:12:34 -07:00
parent 18a6c8a611
commit 1ce29e788f
4 changed files with 55 additions and 1 deletions

3
Cargo.lock generated
View File

@ -1333,6 +1333,7 @@ dependencies = [
"structopt 0.2.15 (registry+https://github.com/rust-lang/crates.io-index)", "structopt 0.2.15 (registry+https://github.com/rust-lang/crates.io-index)",
"wabt 0.7.4 (registry+https://github.com/rust-lang/crates.io-index)", "wabt 0.7.4 (registry+https://github.com/rust-lang/crates.io-index)",
"wasmer-clif-backend 0.2.0", "wasmer-clif-backend 0.2.0",
"wasmer-dynasm-backend 0.1.0",
"wasmer-emscripten 0.2.1", "wasmer-emscripten 0.2.1",
"wasmer-llvm-backend 0.1.0", "wasmer-llvm-backend 0.1.0",
"wasmer-runtime 0.2.1", "wasmer-runtime 0.2.1",
@ -1371,6 +1372,8 @@ dependencies = [
"dynasm 0.3.1 (registry+https://github.com/rust-lang/crates.io-index)", "dynasm 0.3.1 (registry+https://github.com/rust-lang/crates.io-index)",
"dynasmrt 0.3.1 (registry+https://github.com/rust-lang/crates.io-index)", "dynasmrt 0.3.1 (registry+https://github.com/rust-lang/crates.io-index)",
"lazy_static 1.3.0 (registry+https://github.com/rust-lang/crates.io-index)", "lazy_static 1.3.0 (registry+https://github.com/rust-lang/crates.io-index)",
"libc 0.2.50 (registry+https://github.com/rust-lang/crates.io-index)",
"nix 0.13.0 (registry+https://github.com/rust-lang/crates.io-index)",
"wasmer-runtime-core 0.2.1", "wasmer-runtime-core 0.2.1",
"wasmparser 0.28.0 (registry+https://github.com/rust-lang/crates.io-index)", "wasmparser 0.28.0 (registry+https://github.com/rust-lang/crates.io-index)",
] ]

View File

@ -474,10 +474,12 @@ pub fn generate_emscripten_env(globals: &mut EmscriptenGlobals) -> ImportObject
"___syscall75" => func!(crate::syscalls::___syscall75), "___syscall75" => func!(crate::syscalls::___syscall75),
"___syscall85" => func!(crate::syscalls::___syscall85), "___syscall85" => func!(crate::syscalls::___syscall85),
"___syscall91" => func!(crate::syscalls::___syscall191), "___syscall91" => func!(crate::syscalls::___syscall191),
"___syscall94" => func!(crate::syscalls::___syscall194),
"___syscall97" => func!(crate::syscalls::___syscall97), "___syscall97" => func!(crate::syscalls::___syscall97),
"___syscall102" => func!(crate::syscalls::___syscall102), "___syscall102" => func!(crate::syscalls::___syscall102),
"___syscall110" => func!(crate::syscalls::___syscall110), "___syscall110" => func!(crate::syscalls::___syscall110),
"___syscall114" => func!(crate::syscalls::___syscall114), "___syscall114" => func!(crate::syscalls::___syscall114),
"___syscall118" => func!(crate::syscalls::___syscall118),
"___syscall122" => func!(crate::syscalls::___syscall122), "___syscall122" => func!(crate::syscalls::___syscall122),
"___syscall140" => func!(crate::syscalls::___syscall140), "___syscall140" => func!(crate::syscalls::___syscall140),
"___syscall142" => func!(crate::syscalls::___syscall142), "___syscall142" => func!(crate::syscalls::___syscall142),
@ -496,6 +498,7 @@ pub fn generate_emscripten_env(globals: &mut EmscriptenGlobals) -> ImportObject
"___syscall199" => func!(crate::syscalls::___syscall199), "___syscall199" => func!(crate::syscalls::___syscall199),
"___syscall201" => func!(crate::syscalls::___syscall201), "___syscall201" => func!(crate::syscalls::___syscall201),
"___syscall202" => func!(crate::syscalls::___syscall202), "___syscall202" => func!(crate::syscalls::___syscall202),
"___syscall207" => func!(crate::syscalls::___syscall207),
"___syscall212" => func!(crate::syscalls::___syscall212), "___syscall212" => func!(crate::syscalls::___syscall212),
"___syscall220" => func!(crate::syscalls::___syscall220), "___syscall220" => func!(crate::syscalls::___syscall220),
"___syscall221" => func!(crate::syscalls::___syscall221), "___syscall221" => func!(crate::syscalls::___syscall221),

View File

@ -4,7 +4,6 @@ use crate::varargs::VarArgs;
use libc::{ use libc::{
accept, accept,
bind, bind,
// ENOTTY,
c_char, c_char,
c_int, c_int,
c_void, c_void,
@ -12,17 +11,23 @@ use libc::{
// fcntl, setsockopt, getppid // fcntl, setsockopt, getppid
connect, connect,
dup2, dup2,
fchmod,
fchown,
fcntl, fcntl,
// ENOTTY,
fsync,
getgid, getgid,
getpeername, getpeername,
getsockname, getsockname,
getsockopt, getsockopt,
gid_t,
in_addr_t, in_addr_t,
in_port_t, in_port_t,
ioctl, ioctl,
// iovec, // iovec,
listen, listen,
mkdir, mkdir,
mode_t,
msghdr, msghdr,
open, open,
pid_t, pid_t,
@ -43,6 +48,7 @@ use libc::{
sockaddr, sockaddr,
socket, socket,
socklen_t, socklen_t,
uid_t,
uname, uname,
utsname, utsname,
EINVAL, EINVAL,
@ -134,6 +140,15 @@ pub fn ___syscall202(_ctx: &mut Ctx, _one: i32, _two: i32) -> i32 {
} }
} }
/// fchown
pub fn ___syscall207(ctx: &mut Ctx, _which: c_int, mut varargs: VarArgs) -> c_int {
debug!("emscripten::___syscall207 (fchown) {}", _which);
let fd: c_int = varargs.get(ctx);
let owner: uid_t = varargs.get(ctx);
let group: gid_t = varargs.get(ctx);
unsafe { fchown(fd, owner, group) }
}
/// dup3 /// dup3
pub fn ___syscall330(ctx: &mut Ctx, _which: c_int, mut varargs: VarArgs) -> pid_t { pub fn ___syscall330(ctx: &mut Ctx, _which: c_int, mut varargs: VarArgs) -> pid_t {
// Implementation based on description at https://linux.die.net/man/2/dup3 // Implementation based on description at https://linux.die.net/man/2/dup3
@ -499,6 +514,14 @@ pub fn ___syscall181(ctx: &mut Ctx, _which: c_int, mut varargs: VarArgs) -> c_in
status status
} }
/// fchmod
pub fn ___syscall94(ctx: &mut Ctx, _which: c_int, mut varargs: VarArgs) -> c_int {
debug!("emscripten::___syscall118 (fchmod) {}", _which);
let fd: c_int = varargs.get(ctx);
let mode: mode_t = varargs.get(ctx);
unsafe { fchmod(fd, mode) }
}
/// wait4 /// wait4
#[allow(clippy::cast_ptr_alignment)] #[allow(clippy::cast_ptr_alignment)]
pub fn ___syscall114(ctx: &mut Ctx, _which: c_int, mut varargs: VarArgs) -> pid_t { pub fn ___syscall114(ctx: &mut Ctx, _which: c_int, mut varargs: VarArgs) -> pid_t {
@ -517,6 +540,13 @@ pub fn ___syscall114(ctx: &mut Ctx, _which: c_int, mut varargs: VarArgs) -> pid_
res res
} }
/// fsync
pub fn ___syscall118(ctx: &mut Ctx, _which: c_int, mut varargs: VarArgs) -> c_int {
debug!("emscripten::___syscall118 (fsync) {}", _which);
let fd: c_int = varargs.get(ctx);
unsafe { fsync(fd) }
}
// select // select
#[allow(clippy::cast_ptr_alignment)] #[allow(clippy::cast_ptr_alignment)]
pub fn ___syscall142(ctx: &mut Ctx, _which: c_int, mut varargs: VarArgs) -> c_int { pub fn ___syscall142(ctx: &mut Ctx, _which: c_int, mut varargs: VarArgs) -> c_int {

View File

@ -103,6 +103,12 @@ pub fn ___syscall54(_ctx: &mut Ctx, which: c_int, mut _varargs: VarArgs) -> c_in
-1 -1
} }
/// fchmod
pub fn ___syscall94(_ctx: &mut Ctx, _which: c_int, _varargs: VarArgs) -> c_int {
debug!("emscripten::___syscall118 (fchmod) {}", _which);
unimplemented!()
}
// socketcall // socketcall
#[allow(clippy::cast_ptr_alignment)] #[allow(clippy::cast_ptr_alignment)]
pub fn ___syscall102(_ctx: &mut Ctx, which: c_int, mut _varargs: VarArgs) -> c_int { pub fn ___syscall102(_ctx: &mut Ctx, which: c_int, mut _varargs: VarArgs) -> c_int {
@ -112,6 +118,12 @@ pub fn ___syscall102(_ctx: &mut Ctx, which: c_int, mut _varargs: VarArgs) -> c_i
-1 -1
} }
/// fsync
pub fn ___syscall118(_ctx: &mut Ctx, _which: c_int, _varargs: VarArgs) -> c_int {
debug!("emscripten::___syscall118 (fsync) {}", _which);
unimplemented!()
}
// pread // pread
pub fn ___syscall180(_ctx: &mut Ctx, which: c_int, mut _varargs: VarArgs) -> c_int { pub fn ___syscall180(_ctx: &mut Ctx, which: c_int, mut _varargs: VarArgs) -> c_int {
debug!("emscripten::___syscall180 (pread) {}", which); debug!("emscripten::___syscall180 (pread) {}", which);
@ -160,3 +172,9 @@ pub fn ___syscall122(_ctx: &mut Ctx, which: c_int, mut _varargs: VarArgs) -> c_i
let _ = which; let _ = which;
-1 -1
} }
/// fchown
pub fn ___syscall207(_ctx: &mut Ctx, _which: c_int, _varargs: VarArgs) -> c_int {
debug!("emscripten::___syscall207 (fchown) {}", _which);
unimplemented!()
}