print out config
This commit is contained in:
parent
1641e7b793
commit
6aafe87deb
|
@ -1,11 +1,13 @@
|
|||
use crate::platform::{self, Platform};
|
||||
use crate::result::{Context, Result};
|
||||
|
||||
#[derive(Debug)]
|
||||
pub enum Mode {
|
||||
Spawn,
|
||||
Exec,
|
||||
}
|
||||
|
||||
#[derive(Debug)]
|
||||
pub struct Config {
|
||||
pub platform: Option<Box<dyn Platform>>,
|
||||
pub mode: Mode,
|
||||
|
|
35
src/main.rs
35
src/main.rs
|
@ -25,41 +25,10 @@ extern "C" fn handle_sigchld(_sig: i32) {
|
|||
}
|
||||
}
|
||||
|
||||
fn init_rootfs() {
|
||||
use libc::{MS_NOSUID, MS_NOEXEC, MS_NODEV };
|
||||
let no_dse = MS_NODEV | MS_NOSUID | MS_NOEXEC;
|
||||
let no_se = MS_NOSUID | MS_NOEXEC;
|
||||
let args = [
|
||||
("devtmpfs", "/dev", "devtmpfs", no_se, "mode=0755"),
|
||||
/*
|
||||
("devpts", "/dev/pts", "devpts", no_se, ""),
|
||||
("shm", "/dev/shm", "tmpfs", no_dse, "mode=0755"),
|
||||
*/
|
||||
("proc", "/proc", "proc", no_dse, "hidepid=2"),
|
||||
("tmpfs", "/run", "tmpfs", no_dse, "mode=0755"),
|
||||
("tmpfs", "/tmp", "tmpfs", no_dse, ""),
|
||||
("sysfs", "/sys", "sysfs", no_dse, ""),
|
||||
("cgroup_root", "/sys/fs/cgroup", "tmpfs", no_dse, "mode=0755"),
|
||||
];
|
||||
for (src, target, fstype, flags, data) in args {
|
||||
match system::syscall::mount(src, target, fstype, flags, Some(data)) {
|
||||
Ok(())=> dmesg(format!("Mounted {target}")),
|
||||
Err(e)=> {
|
||||
dmesg(format!("Error: {e}"));
|
||||
let mut opt = Some(&e as &dyn std::error::Error);
|
||||
while let Some(current_source) = opt {
|
||||
dmesg(format!("Caused by: {current_source}"));
|
||||
opt = current_source.source();
|
||||
}
|
||||
},
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
fn init() -> Result<()> {
|
||||
// let config = config::get_config()?;
|
||||
let config = config::get_config()?;
|
||||
dmesg(format!("{config:?}"));
|
||||
|
||||
// init_rootfs();
|
||||
if let Err(errors) = system::mount_default_targets() {
|
||||
for error in errors {
|
||||
dmesg(format!("Error while mounting: {error}"));
|
||||
|
|
|
@ -3,6 +3,7 @@ use crate::{
|
|||
system::dmesg,
|
||||
};
|
||||
|
||||
#[derive(Debug)]
|
||||
pub struct Aws;
|
||||
|
||||
#[derive(Debug)]
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
use crate::{system::{self, Mount, MountType}, result::Result};
|
||||
|
||||
pub trait Platform {
|
||||
pub trait Platform: std::fmt::Debug {
|
||||
/// Whether the current Platform is the `Self` platform.
|
||||
///
|
||||
/// This method should check for the existence of hardware devices that irrefutably defines
|
||||
|
|
|
@ -6,7 +6,9 @@ pub mod syscall;
|
|||
|
||||
pub fn dmesg(value: impl std::fmt::Display) {
|
||||
let timespec = syscall::clock_gettime(libc::CLOCK_BOOTTIME).unwrap();
|
||||
eprintln!("[{: >5}.{}] {value}", timespec.tv_sec, timespec.tv_nsec / 1000);
|
||||
for line in value.to_string().lines() {
|
||||
eprintln!("[{: >5}.{}] {line}", timespec.tv_sec, timespec.tv_nsec / 1000);
|
||||
}
|
||||
}
|
||||
|
||||
pub enum MountType {
|
||||
|
|
Loading…
Reference in New Issue