prelim VFS work

This commit is contained in:
Able 2023-05-09 01:07:52 -05:00
parent be96cb797a
commit ca80c17819
9 changed files with 60 additions and 9 deletions

4
Cargo.lock generated
View file

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

View file

@ -11,6 +11,8 @@ members = [
"drivers/graphics/novideo", "drivers/graphics/novideo",
"drivers/graphics/vgable", "drivers/graphics/vgable",
"drivers/vfs",
"drivers/keyboards/ps2_keyboard", "drivers/keyboards/ps2_keyboard",
"drivers/mice/ps2_mouse", "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 ok: T,
pub err: ExternErrors, pub err: ExternErrors,
} }
pub struct Path {
parts: String,
}

View file

@ -1,12 +1,3 @@
pub enum IOErrors { pub enum IOErrors {
UnknownError, 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; use versioning::Version;
pub mod path;
pub const VERSION: Version = Version::new(0, 1, 0); pub const VERSION: Version = Version::new(0, 1, 0);
// extern crate alloc; // 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 core::panic;
pub use versioning; pub use versioning;
extern crate alloc;
pub use alloc::vec::Vec;