Skip to content

Commit

Permalink
add some syscall skeletons; context switching
Browse files Browse the repository at this point in the history
  • Loading branch information
Mark McCaskey committed Mar 30, 2019
1 parent 42e8523 commit 5cee576
Showing 1 changed file with 25 additions and 2 deletions.
27 changes: 25 additions & 2 deletions lib/wasi/src/syscalls/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -240,16 +240,39 @@ pub fn fd_prestat_get(
fd: __wasi_fd_t,
buf: WasmPtr<__wasi_prestat_t>,
) -> __wasi_errno_t {
unimplemented!()
let memory = ctx.memory(0);

if let Some(prestat_ptr) = buf.deref(memory) {
// open fd
// write info to prestat_ptr
__WASI_ESUCCESS
} else {
__WASI_EFAULT
}
}

pub fn fd_prestat_dir_name(
ctx: &mut Ctx,
fd: __wasi_fd_t,
path: WasmPtr<u8, Array>,
path_len: u32,
) -> __wasi_errno_t {
unimplemented!()
let memory = ctx.memory(0);

if let Some(path_chars) = path.deref(memory, 0, path_len) {
if true /* check if dir */ {
// get name
// write name
// if overflow __WASI_EOVERFLOW
__WASI_ESUCCESS
} else {
__WASI_ENOTDIR
}
} else {
__WASI_EFAULT
}
}

pub fn fd_pwrite(
ctx: &mut Ctx,
fd: __wasi_fd_t,
Expand Down

0 comments on commit 5cee576

Please sign in to comment.