prelim VFS work
This commit is contained in:
parent
be96cb797a
commit
ca80c17819
4
Cargo.lock
generated
4
Cargo.lock
generated
|
@ -644,6 +644,10 @@ dependencies = [
|
|||
"serde",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "vfs"
|
||||
version = "0.1.0"
|
||||
|
||||
[[package]]
|
||||
name = "vgable"
|
||||
version = "0.1.0"
|
||||
|
|
|
@ -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
9
drivers/vfs/Cargo.toml
Normal 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
18
drivers/vfs/src/main.rs
Normal 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 {}
|
|
@ -24,3 +24,7 @@ pub struct Result<T> {
|
|||
pub ok: T,
|
||||
pub err: ExternErrors,
|
||||
}
|
||||
|
||||
pub struct Path {
|
||||
parts: String,
|
||||
}
|
||||
|
|
|
@ -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)
|
||||
// }
|
||||
// }
|
||||
|
|
|
@ -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
18
libraries/std/src/path.rs
Normal 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,
|
||||
}
|
||||
}
|
||||
}
|
|
@ -6,3 +6,6 @@ pub use crate::print_char;
|
|||
pub use core::panic;
|
||||
|
||||
pub use versioning;
|
||||
|
||||
extern crate alloc;
|
||||
pub use alloc::vec::Vec;
|
||||
|
|
Loading…
Reference in a new issue