ext2fs
This commit is contained in:
parent
80ac635ceb
commit
5ea5172cae
93
ableos/src/ext2fs/mod.rs
Normal file
93
ableos/src/ext2fs/mod.rs
Normal 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 Other—execute permission
|
||||||
|
0x002 00002 Other—write permission
|
||||||
|
0x004 00004 Other—read permission
|
||||||
|
0x008 00010 Group—execute permission
|
||||||
|
0x010 00020 Group—write permission
|
||||||
|
0x020 00040 Group—read permission
|
||||||
|
0x040 00100 User—execute permission
|
||||||
|
0x080 00200 User—write permission
|
||||||
|
0x100 00400 User—read 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);
|
|
@ -31,6 +31,7 @@ use {
|
||||||
};
|
};
|
||||||
|
|
||||||
lazy_static! {
|
lazy_static! {
|
||||||
|
// TODO: Change this structure to allow for multiple cores loaded
|
||||||
pub static ref TICK: AtomicU64 = AtomicU64::new(0);
|
pub static ref TICK: AtomicU64 = AtomicU64::new(0);
|
||||||
pub static ref BOOT_CONF: BootConfig = boot_conf::BootConfig::new();
|
pub static ref BOOT_CONF: BootConfig = boot_conf::BootConfig::new();
|
||||||
}
|
}
|
||||||
|
|
|
@ -32,6 +32,7 @@ pub mod arch;
|
||||||
|
|
||||||
#[macro_use]
|
#[macro_use]
|
||||||
pub mod print;
|
pub mod print;
|
||||||
|
pub mod ext2fs;
|
||||||
|
|
||||||
#[macro_use]
|
#[macro_use]
|
||||||
pub extern crate log;
|
pub extern crate log;
|
||||||
|
|
|
@ -8,10 +8,18 @@ pub struct PathRep {
|
||||||
pub file_name: String,
|
pub file_name: String,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[derive(Debug)]
|
||||||
|
pub struct FilePermissions {
|
||||||
|
pub read: bool,
|
||||||
|
pub write: bool,
|
||||||
|
pub execute: bool,
|
||||||
|
}
|
||||||
|
|
||||||
#[derive(Debug)]
|
#[derive(Debug)]
|
||||||
pub struct FileMetadata {
|
pub struct FileMetadata {
|
||||||
pub file_type: String,
|
pub file_type: String,
|
||||||
pub size: usize,
|
pub size: usize,
|
||||||
|
// pub permissions: FilePermissions,
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Debug, Clone, PartialEq)]
|
#[derive(Debug, Clone, PartialEq)]
|
||||||
|
|
Loading…
Reference in a new issue