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

Function exec_path

shell/src/main.rs:16–61  ·  view source on GitHub ↗
(current_directory: &Path, path: &Path, args: Vec<&str>)

Source from the content-addressed store, hash-verified

14 syscalls::{self, SyscallError, VFS}};
15
16fn exec_path(current_directory: &Path, path: &Path, args: Vec<&str>) -> 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 // Make an environment with the working directory
29 let mut env_string = String::from("PWD=");
30 env_string.push_str(current_directory
31 .as_os_str().to_str().unwrap());
32
33 syscalls::exec(
34 &bin,
35 0, // Permission flags
36 exe_input2,
37 syscalls::STDOUT.clone(),
38 VFS::shared(),
39 args,
40 &env_string
41 )?;
42
43 loop {
44 // Wait for keyboard input
45 match syscalls::receive(&syscalls::STDIN) {
46 Ok(syscalls::Message::Short(
47 message::CHAR, ch, _)) => {
48 // Received a character
49 if let Err((err, _)) = syscalls::send(&exe_input,
50 syscalls::Message::Short(
51 message::CHAR, ch, 0)) {
52 println!("Received error: {}", err);
53 return Ok(());
54 }
55 },
56 _ => {
57 // Ignore
58 }
59 }
60 }
61}
62
63fn help() {
64 println!(

Callers 1

mainFunction · 0.70

Calls 9

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

Tested by

no test coverage detected