MCPcopy Create free account
hub / github.com/bendudson/EuraliOS / exec_path

Function exec_path

login/src/main.rs:16–55  ·  view source on GitHub ↗
(path: &Path, vfs: VFS)

Source from the content-addressed store, hash-verified

14
15
16fn 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]
58fn main() {

Callers 1

mainFunction · 0.70

Calls 7

execFunction · 0.85
receiveFunction · 0.85
sendFunction · 0.85
read_to_endMethod · 0.80
cloneMethod · 0.80
openFunction · 0.50
new_rendezvousFunction · 0.50

Tested by

no test coverage detected