This commit is contained in:
Able 2022-02-07 21:14:47 -06:00
parent 80ac635ceb
commit 5ea5172cae
4 changed files with 103 additions and 0 deletions

93
ableos/src/ext2fs/mod.rs Normal file
View file

@ -0,0 +1,93 @@
use alloc::string::{String, ToString};
pub enum FileSystemStates {
Null = 0,
Clean = 1,
Error = 2,
}
pub enum ErrorHandleMethod {
Null = 0,
Ignore = 1,
RemountFileSystem = 2,
Panic = 3,
}
/// Used by ableOS to identify the creator of the file system
#[repr(C)]
pub enum CreatorOperatingSystemID {
Linux = 0,
GNU_HURD = 1,
// 2 MASIX (an operating system developed by Rémy Card, one of the developers of ext2)
MASIX = 2,
// 3 FreeBSD
FreeBsd = 3,
// 4 Other "Lites" (BSD4.4-Lite derivatives such as NetBSD, OpenBSD, XNU/Darwin, etc.)
LITES = 4,
AbleOS = 5,
Unknown = 6,
}
impl CreatorOperatingSystemID {
pub fn to_string(&self) -> String {
match self {
&CreatorOperatingSystemID::Linux => "Linux".to_string(),
&CreatorOperatingSystemID::GNU_HURD => "GNU_HURD".to_string(),
&CreatorOperatingSystemID::MASIX => "MASIX".to_string(),
&CreatorOperatingSystemID::FreeBsd => "FREE_BSD".to_string(),
&CreatorOperatingSystemID::LITES => "LITES".to_string(),
&CreatorOperatingSystemID::AbleOS => "ABLEOS".to_string(),
&CreatorOperatingSystemID::Unknown => "Unknown".to_string(),
}
}
pub fn match_to_int(id: CreatorOperatingSystemID) -> u8 {
match id {
Self::Linux => 0,
Self::GNU_HURD => 1,
Self::MASIX => 2,
Self::FreeBsd => 3,
Self::LITES => 4,
Self::AbleOS => 5,
_ => 6,
}
}
pub fn match_to_enum(id: u8) -> CreatorOperatingSystemID {
match id {
0 => Self::Linux,
1 => Self::GNU_HURD,
2 => Self::MASIX,
3 => Self::FreeBsd,
4 => Self::LITES,
5 => Self::AbleOS,
_ => Self::Unknown,
}
}
}
/*
0x001 00001 Otherexecute permission
0x002 00002 Otherwrite permission
0x004 00004 Otherread permission
0x008 00010 Groupexecute permission
0x010 00020 Groupwrite permission
0x020 00040 Groupread permission
0x040 00100 Userexecute permission
0x080 00200 Userwrite permission
0x100 00400 Userread permission
0x200 01000 Sticky Bit
0x400 02000 Set group ID
0x800 04000 Set user ID*/
pub struct FilePermissions(pub u16);
/*
0x1000 FIFO
0x2000 Character device
0x4000 Directory
0x6000 Block device
0x8000 Regular file
0xA000 Symbolic link
0xC000 Unix socket
*/
pub struct InodeType(pub u16);

View file

@ -31,6 +31,7 @@ use {
};
lazy_static! {
// TODO: Change this structure to allow for multiple cores loaded
pub static ref TICK: AtomicU64 = AtomicU64::new(0);
pub static ref BOOT_CONF: BootConfig = boot_conf::BootConfig::new();
}

View file

@ -32,6 +32,7 @@ pub mod arch;
#[macro_use]
pub mod print;
pub mod ext2fs;
#[macro_use]
pub extern crate log;

View file

@ -8,10 +8,18 @@ pub struct PathRep {
pub file_name: String,
}
#[derive(Debug)]
pub struct FilePermissions {
pub read: bool,
pub write: bool,
pub execute: bool,
}
#[derive(Debug)]
pub struct FileMetadata {
pub file_type: String,
pub size: usize,
// pub permissions: FilePermissions,
}
#[derive(Debug, Clone, PartialEq)]