sysutils: add dummy chroot program
This commit is contained in:
@@ -6,10 +6,12 @@ use libk_util::OneTimeInit;
|
||||
pub mod bus;
|
||||
pub mod clock;
|
||||
pub mod display;
|
||||
pub mod gpio;
|
||||
pub mod power;
|
||||
pub mod serial;
|
||||
// pub mod timer;
|
||||
|
||||
#[cfg(any(rust_analyzer, not(target_arch = "x86_64")))]
|
||||
pub mod gpio;
|
||||
|
||||
/// Generic machine description string
|
||||
pub static MACHINE_NAME: OneTimeInit<String> = OneTimeInit::new();
|
||||
|
||||
@@ -47,6 +47,8 @@ struct SpawnOptions<'a> {
|
||||
pub environment: &'a [&'a str],
|
||||
/// Working directory
|
||||
pub directory: Option<&'a str>,
|
||||
/// Root path
|
||||
pub root: Option<&'a str>,
|
||||
/// Optional arguments to specify details of the creation
|
||||
pub optional: &'a [SpawnOption],
|
||||
/// Extra flags controlling the new process behavior
|
||||
|
||||
@@ -41,6 +41,10 @@ path = "src/lib.rs"
|
||||
name = "mount"
|
||||
path = "src/mount.rs"
|
||||
|
||||
[[bin]]
|
||||
name = "chroot"
|
||||
path = "src/chroot.rs"
|
||||
|
||||
[[bin]]
|
||||
name = "login"
|
||||
path = "src/login.rs"
|
||||
|
||||
@@ -0,0 +1,23 @@
|
||||
use std::process::ExitCode;
|
||||
|
||||
fn usage(cmd: &str) {
|
||||
eprintln!("Usage: {cmd} PATH PROGRAM [ARGS...]");
|
||||
}
|
||||
|
||||
fn main() -> ExitCode {
|
||||
let mut args = std::env::args();
|
||||
let cmd = args.next().unwrap();
|
||||
let Some(path) = args.next() else {
|
||||
usage(&cmd);
|
||||
return ExitCode::FAILURE;
|
||||
};
|
||||
let Some(program) = args.next() else {
|
||||
usage(&cmd);
|
||||
return ExitCode::FAILURE;
|
||||
};
|
||||
let cmd_args = args.collect::<Vec<_>>();
|
||||
|
||||
println!("Run {program:?} at {path:?} with args {cmd_args:?}");
|
||||
|
||||
ExitCode::SUCCESS
|
||||
}
|
||||
@@ -31,6 +31,7 @@ const PROGRAMS: &[(&str, &str)] = &[
|
||||
// sysutils
|
||||
("echo", "bin/echo"),
|
||||
("mount", "sbin/mount"),
|
||||
("chroot", "sbin/chroot"),
|
||||
("login", "sbin/login"),
|
||||
("strace", "bin/strace"),
|
||||
("ls", "bin/ls"),
|
||||
|
||||
Reference in New Issue
Block a user