Files
RedBear-OS/src/scheme/sys/syscall.rs
T
jD91mZM2 fe705d9b63 Switch to 2018 edition
Most of this was generated by the absolutely extraordinary `cargo fix`
subcommand. There were still 2 errors and a few warnings to patch up,
but compared to the normal 600+ errors, I'd say the fixer did a damn
good job! I'm also amazed that I could still start the VM after this,
I half expected some kinds of runtime failure...
2019-06-21 12:12:01 +02:00

37 lines
966 B
Rust

use alloc::string::String;
use alloc::vec::Vec;
use core::fmt::Write;
use core::str;
use crate::context;
use crate::syscall;
use crate::syscall::error::Result;
pub fn resource() -> Result<Vec<u8>> {
let mut string = String::new();
{
let mut rows = Vec::new();
{
let contexts = context::contexts();
for (id, context_lock) in contexts.iter() {
let context = context_lock.read();
rows.push((*id, context.name.lock().clone(), context.syscall.clone()));
}
}
for row in rows.iter() {
let id: usize = row.0.into();
let name = str::from_utf8(&row.1).unwrap_or(".");
let _ = writeln!(string, "{}: {}", id, name);
if let Some((a, b, c, d, e, f)) = row.2 {
let _ = writeln!(string, " {}", syscall::debug::format_call(a, b, c, d, e, f));
}
}
}
Ok(string.into_bytes())
}