diff --git a/src/config.rs b/src/config.rs index ad18f2f..83cd0b0 100644 --- a/src/config.rs +++ b/src/config.rs @@ -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>, pub mode: Mode, diff --git a/src/main.rs b/src/main.rs index d9ecaf1..f69c853 100644 --- a/src/main.rs +++ b/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}")); diff --git a/src/platform/aws.rs b/src/platform/aws.rs index 68f9960..326667d 100644 --- a/src/platform/aws.rs +++ b/src/platform/aws.rs @@ -3,6 +3,7 @@ use crate::{ system::dmesg, }; +#[derive(Debug)] pub struct Aws; #[derive(Debug)] diff --git a/src/platform/mod.rs b/src/platform/mod.rs index 9f0f113..fcdf913 100644 --- a/src/platform/mod.rs +++ b/src/platform/mod.rs @@ -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 diff --git a/src/system/mod.rs b/src/system/mod.rs index 726fa57..424496d 100644 --- a/src/system/mod.rs +++ b/src/system/mod.rs @@ -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 {