prelim VFS work

master
Able 2023-05-09 01:07:52 -05:00
parent f433484f2f
commit 0f55b5907c
9 changed files with 60 additions and 9 deletions

4
Cargo.lock generated
View File

@ -644,6 +644,10 @@ dependencies = [
"serde",
]
[[package]]
name = "vfs"
version = "0.1.0"
[[package]]
name = "vgable"
version = "0.1.0"

View File

@ -11,6 +11,8 @@ members = [
"drivers/graphics/novideo",
"drivers/graphics/vgable",
"drivers/vfs",
"drivers/keyboards/ps2_keyboard",
"drivers/mice/ps2_mouse",

9
drivers/vfs/Cargo.toml Normal file
View File

@ -0,0 +1,9 @@
[package]
name = "vfs"
version = "0.1.0"
edition = "2021"
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
[dependencies]
# std = { path = "../../libraries/std" }

18
drivers/vfs/src/main.rs Normal file
View File

@ -0,0 +1,18 @@
// #![no_std]
use std::path::Path;
// use std::prelude::rust_2021::alloc;
extern crate alloc;
use alloc::vec::Vec;
fn main() {}
pub type File = Vec<u8>;
// TODO: implement better VFS api
pub trait FileIO {
fn read(file: &mut File, file_address: u64, read_length: u64);
fn write(file: &mut File, file_address: u64, dest_ptr: u64, src_len: usize);
fn open(path: Path);
fn close(file: &mut File);
}
pub enum FileError {}

View File

@ -24,3 +24,7 @@ pub struct Result<T> {
pub ok: T,
pub err: ExternErrors,
}
pub struct Path {
parts: String,
}

View File

@ -1,12 +1,3 @@
pub enum IOErrors {
UnknownError,
}
// pub struct Port<T> {
// inner: T,
// }
// impl<T> Port<T> {
// pub fn read(&self) -> Result<T, IOErrors> {
// Ok(self.inner)
// }
// }

View File

@ -23,6 +23,8 @@ pub mod prelude;
use versioning::Version;
pub mod path;
pub const VERSION: Version = Version::new(0, 1, 0);
// extern crate alloc;

18
libraries/std/src/path.rs Normal file
View File

@ -0,0 +1,18 @@
use alloc::string::{String, ToString};
pub struct Path {
pub path: Vec<String>,
}
impl Path {
pub fn new(path: String) -> Self {
let mut path_vec_string = alloc::vec![];
for part in path.split(&['\\', '/'][..]) {
path_vec_string.push(part.to_string());
}
Path {
path: path_vec_string,
}
}
}

View File

@ -6,3 +6,6 @@ pub use crate::print_char;
pub use core::panic;
pub use versioning;
extern crate alloc;
pub use alloc::vec::Vec;