(path: &Path, vfs: VFS)
| 14 | |
| 15 | |
| 16 | fn exec_path(path: &Path, vfs: VFS) -> Result<(), SyscallError> { |
| 17 | // Read binary from file |
| 18 | let bin = { |
| 19 | let mut bin: Vec<u8> = Vec::new(); |
| 20 | let mut file = File::open(path)?; |
| 21 | file.read_to_end(&mut bin)?; |
| 22 | bin |
| 23 | }; |
| 24 | |
| 25 | // Create a communication handle for the input |
| 26 | let (exe_input, exe_input2) = syscalls::new_rendezvous()?; |
| 27 | |
| 28 | syscalls::exec( |
| 29 | &bin, |
| 30 | 0, // Permission flags |
| 31 | exe_input2, |
| 32 | syscalls::STDOUT.clone(), |
| 33 | vfs, |
| 34 | Vec::new(), |
| 35 | "")?; |
| 36 | |
| 37 | loop { |
| 38 | // Wait for keyboard input |
| 39 | match syscalls::receive(&syscalls::STDIN) { |
| 40 | Ok(syscalls::Message::Short( |
| 41 | message::CHAR, ch, _)) => { |
| 42 | // Received a character |
| 43 | if let Err((err, _)) = syscalls::send(&exe_input, |
| 44 | syscalls::Message::Short( |
| 45 | message::CHAR, ch, 0)) { |
| 46 | println!("Received error: {}", err); |
| 47 | return Ok(()); |
| 48 | } |
| 49 | }, |
| 50 | _ => { |
| 51 | // Ignore |
| 52 | } |
| 53 | } |
| 54 | } |
| 55 | } |
| 56 | |
| 57 | #[no_mangle] |
| 58 | fn main() { |
no test coverage detected