WIP: Schemes

This commit is contained in:
Jeremy Soller 2016-08-14 21:38:32 -06:00
parent 8a6d9b8c9d
commit 19077d69db
5 changed files with 77 additions and 12 deletions

33
kernel/scheme/debug.rs Normal file
View file

@ -0,0 +1,33 @@
use core::str;
use syscall::Result;
use super::Scheme;
pub struct DebugScheme;
impl Scheme for DebugScheme {
fn open(&mut self, path: &[u8], flags: usize) -> Result<usize> {
println!("DebugScheme::open: {}", unsafe { str::from_utf8_unchecked(path) });
Ok(0)
}
/// Read the file `number` into the `buffer`
///
/// Returns the number of bytes read
fn read(&mut self, file: usize, buffer: &mut [u8]) -> Result<usize> {
Ok(0)
}
/// Write the `buffer` to the `file`
///
/// Returns the number of bytes written
fn write(&mut self, file: usize, buffer: &[u8]) -> Result<usize> {
//TODO: Write bytes, do not convert to str
print!("{}", unsafe { str::from_utf8_unchecked(buffer) });
Ok(buffer.len())
}
/// Close the file `number`
fn close(&mut self, file: usize) -> Result<()> {
Ok(())
}
}