add dmesg-y lines
This commit is contained in:
parent
4df0b611b1
commit
f35a923dee
|
@ -74,6 +74,8 @@ fn init() -> Result<()> {
|
||||||
|
|
||||||
init_console()?;
|
init_console()?;
|
||||||
|
|
||||||
|
system::dmesg("EnclaveOS Booted");
|
||||||
|
|
||||||
std::thread::sleep(std::time::Duration::from_secs(500));
|
std::thread::sleep(std::time::Duration::from_secs(500));
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
@ -110,11 +112,13 @@ fn init() -> Result<()> {
|
||||||
}
|
}
|
||||||
|
|
||||||
fn init_console() -> Result<(), result::CtxError> {
|
fn init_console() -> Result<(), result::CtxError> {
|
||||||
Ok(for (filename, mode, fd) in [
|
for (filename, mode, fd) in [
|
||||||
("/dev/console", "r", 0),
|
("/dev/console", "r", 0),
|
||||||
("/dev/console", "w", 1),
|
("/dev/console", "w", 1),
|
||||||
("/dev/console", "w", 2),
|
("/dev/console", "w", 2),
|
||||||
] {
|
] {
|
||||||
system::syscall::freopen(filename, mode, &fd)?;
|
system::syscall::freopen(filename, mode, &fd)?;
|
||||||
})
|
}
|
||||||
|
|
||||||
|
Ok(())
|
||||||
}
|
}
|
||||||
|
|
|
@ -4,6 +4,11 @@ use std::path::{Path, PathBuf};
|
||||||
|
|
||||||
pub mod syscall;
|
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);
|
||||||
|
}
|
||||||
|
|
||||||
pub enum MountType {
|
pub enum MountType {
|
||||||
DevTmpFs,
|
DevTmpFs,
|
||||||
DevPts,
|
DevPts,
|
||||||
|
@ -62,6 +67,11 @@ impl Mount {
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn mount_self(&self) -> Result<()> {
|
pub fn mount_self(&self) -> Result<()> {
|
||||||
|
dmesg(format!(
|
||||||
|
"Mounting {source} to {target}",
|
||||||
|
source = self.source.display(),
|
||||||
|
target = self.target.display()
|
||||||
|
));
|
||||||
syscall::mount(
|
syscall::mount(
|
||||||
&self.source,
|
&self.source,
|
||||||
&self.target,
|
&self.target,
|
||||||
|
|
|
@ -15,6 +15,27 @@ use std::{
|
||||||
path::Path,
|
path::Path,
|
||||||
};
|
};
|
||||||
|
|
||||||
|
pub fn clock_gettime(clock_id: libc::clockid_t) -> Result<libc::timespec> {
|
||||||
|
let mut t = libc::timespec {
|
||||||
|
tv_sec: 0,
|
||||||
|
tv_nsec: 0,
|
||||||
|
};
|
||||||
|
|
||||||
|
match unsafe { libc::clock_gettime(clock_id, std::ptr::from_mut(&mut t)) } {
|
||||||
|
0 => Ok(t),
|
||||||
|
-1 => {
|
||||||
|
// at this point, Err(ctx_os_error()) is starting to seem appealing
|
||||||
|
ctx_os_error(format_args!("error calling clock_gettime({clock_id}, ...)")).map(|()| {
|
||||||
|
libc::timespec {
|
||||||
|
tv_sec: 0,
|
||||||
|
tv_nsec: 0,
|
||||||
|
}
|
||||||
|
})
|
||||||
|
}
|
||||||
|
n => unreachable!("clock_gettime() syscall returned bad value: {n}"),
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
pub fn mount(
|
pub fn mount(
|
||||||
src: impl AsRef<Path>,
|
src: impl AsRef<Path>,
|
||||||
target: impl AsRef<Path>,
|
target: impl AsRef<Path>,
|
||||||
|
|
Loading…
Reference in New Issue