From 12a153466bece6700c05f8e209bd7ada2620f52e Mon Sep 17 00:00:00 2001 From: FantasyPvP <80643031+FantasyPvP@users.noreply.github.com> Date: Sat, 21 Oct 2023 01:51:18 +0100 Subject: [PATCH] idk idk --- src/system/kernel/fs/mod.rs | 160 ------------------------------------ src/system/kernel/mod.rs | 4 +- 2 files changed, 2 insertions(+), 162 deletions(-) delete mode 100644 src/system/kernel/fs/mod.rs diff --git a/src/system/kernel/fs/mod.rs b/src/system/kernel/fs/mod.rs deleted file mode 100644 index 1811993..0000000 --- a/src/system/kernel/fs/mod.rs +++ /dev/null @@ -1,160 +0,0 @@ -use lazy_static::lazy_static; -use async_trait::async_trait; -use spin::Mutex; -use alloc::{vec::Vec, string::String, boxed::Box}; -use crate::std::{self, application::{Error, Application}}; - - -lazy_static! { - pub static ref FILESYSTEM: Mutex> = Mutex::new(Box::new(File::new( - String::from(""), // root - FileType::Dir(Directory::new()), - ))); -} - -pub type Directory = Vec>; - -#[derive(Debug)] -pub struct File { - pub name: String, - pub data: FileType, -} -impl File { - pub fn new(name: String, data: FileType) -> Self { - Self { name, data } - } -} - -#[derive(Debug)] -pub enum FileType { - Dir(Directory), - Txt(String), - Exe(Apppp), -} - - - - -pub fn mkfs() { - let mut fs = FILESYSTEM.lock(); - - match fs.data { - FileType::Dir(ref mut dir) => { - dir.push(Box::new( - File::new( - String::from("hello there"), - FileType::Txt(String::from("this is a basic text file")), - ) - )); - dir.push(Box::new( - File::new( - String::from("function that prints out an integer"), - FileType::Exe(Apppp::new()), - ) - )); - } - _ => { - () - } - } -} - - -#[derive(Debug)] -pub struct Apppp {} - -#[async_trait] -impl std::application::Application for Apppp { - fn new() -> Self { - Self {} - } - async fn run(&mut self, _: Vec) -> Result<(), Error> { - Ok(()) - } -} - -/* -lazy_static! { - pub static ref FILESYSTEM: Mutex = Mutex::new(Filesystem::new()); -} - -enum FsError { - FileNotFound, - AlreadyExists, - InvalidPath, -} - -pub type Path = String; - -impl Path { - pub fn new(path: &str) -> Result { - if path.is_empty() { - return Err(FsError::FileNotFound); - } - Ok(path.to_string()) - } - pub fn dirs(&self) -> Vec { - self.split('/').map(|s| s.to_string()).collect() - } -} - - -pub struct Filesystem { - pub root: Vec -} - - - -pub type Directory = Vec; - -impl Directory { - pub fn new(name: String, files: Vec) -> Self { - Self { name, files } - } - pub fn size(&self) -> usize { - self.files.len() - } - pub fn mkdir(&mut self, name: &str, location: Path) -> Result<(), FsError> { - if self.exists(location.as_str()) { - return Err(FsError::AlreadyExists); - } - self.files.push(File::new(name, FileType::Directory(Box::new(Directory::new())))) - } -} - - -pub enum FileType { - Directory(Box), - TextFile(Box), - BinaryFile(Box), - Executable(fn()), -} - - -pub struct File { - pub name: String, - pub file_type: FileType, -} -impl File { - pub fn new(name: String, file_type: FileType) -> Self { - Self { name, file_type } - } -} - - - -pub struct TextFile { - pub name: String, - pub data: String, -} -impl TextFile { - pub fn new(name: String, data: String) -> Self { - Self { name, data } - } - pub fn size(&self) -> usize { - self.data.len() - } -} - - -*/ \ No newline at end of file diff --git a/src/system/kernel/mod.rs b/src/system/kernel/mod.rs index 2bf27d1..9e699f4 100644 --- a/src/system/kernel/mod.rs +++ b/src/system/kernel/mod.rs @@ -1,5 +1,4 @@ pub mod allocator; -pub mod fs; pub mod gdt; pub mod interrupts; pub mod memory; @@ -7,4 +6,5 @@ pub mod serial; pub mod tasks; pub mod sysinit; pub mod authenticator; -pub mod render; \ No newline at end of file +pub mod render; +mod fs; \ No newline at end of file