forked from AbleOS/ableos
various QOL updates
This commit is contained in:
parent
5b4ee4f986
commit
59aaa9622b
|
@ -15,6 +15,7 @@ pub struct BinaryData {
|
|||
pub enum HandleResource {
|
||||
Channel(Channel),
|
||||
// Device
|
||||
/// Used for things like files or images or the like
|
||||
BinaryData(BinaryData),
|
||||
}
|
||||
|
||||
|
|
|
@ -1,8 +1,8 @@
|
|||
use core::fmt::Error;
|
||||
|
||||
// use crate::aalloc::aalloc;
|
||||
use crate::arch::generate_process_pass;
|
||||
use crate::arch::interrupts::{reset_pit_for_cpu, set_pit_2};
|
||||
use crate::arch::{generate_process_pass, shutdown};
|
||||
use crate::channels::{Channel, ChannelPermission};
|
||||
use crate::devices::pci;
|
||||
use crate::filesystem::FILE_SYSTEM;
|
||||
|
@ -15,8 +15,12 @@ use acpi::{AcpiTables, PlatformInfo};
|
|||
use alloc::collections::{vec_deque, VecDeque};
|
||||
use cpuio::inb;
|
||||
use cpuio::outb;
|
||||
use genfs::Fs;
|
||||
use ext2::fs::sync::{DirectoryEntry, Synced};
|
||||
use ext2::fs::Ext2;
|
||||
use ext2::sector::Size1024;
|
||||
use ext2::sys::inode;
|
||||
use genfs::OpenOptions;
|
||||
use genfs::{DirEntry, Fs};
|
||||
use kernel::proccess::PID;
|
||||
use vga::writers::GraphicsWriter;
|
||||
|
||||
|
@ -68,13 +72,13 @@ pub fn scratchpad() {
|
|||
}";
|
||||
let axel = axel::parse(axel_raw.to_string());
|
||||
|
||||
let xyz = pci::brute_force_scan();
|
||||
for dev in xyz {
|
||||
trace!("{:?}", dev);
|
||||
dev.bars.iter().for_each(|bar| {
|
||||
trace!("{:?}", bar);
|
||||
});
|
||||
}
|
||||
// let xyz = pci::brute_force_scan();
|
||||
// for dev in xyz {
|
||||
// trace!("{:?}", dev);
|
||||
// dev.bars.iter().for_each(|bar| {
|
||||
// trace!("{:?}", bar);
|
||||
// });
|
||||
// }
|
||||
|
||||
for node in axel {
|
||||
info!("{:?}", node);
|
||||
|
@ -97,16 +101,6 @@ pub fn scratchpad() {
|
|||
|
||||
*/
|
||||
|
||||
let home_path = Path::new("/home/able".to_string());
|
||||
|
||||
let mut chan = Channel::new();
|
||||
|
||||
let ret = chan.read();
|
||||
|
||||
let chan_handle = Handle::from_channel(chan);
|
||||
|
||||
println!("{}", chan_handle);
|
||||
|
||||
real_shell();
|
||||
}
|
||||
use crate::graphics::VgaBuffer;
|
||||
|
@ -174,21 +168,35 @@ pub fn command_parser(user: String, command: String) {
|
|||
let fs = &*FILE_SYSTEM.lock();
|
||||
let mut iter = command.split_whitespace();
|
||||
|
||||
// TODO: update the open() function to take either a ableOS path or a b"/" type path
|
||||
let current_path = Path::new("/home/able".to_string());
|
||||
trace!("Current path: {:?}", current_path);
|
||||
let current_path = b"/home/able/";
|
||||
|
||||
let bin_name = iter.next().unwrap();
|
||||
|
||||
if bin_name == "rhai" {
|
||||
match bin_name {
|
||||
"rhai" => {
|
||||
drop(fs);
|
||||
shell();
|
||||
return;
|
||||
}
|
||||
"list" | "ls" => {
|
||||
for dir_entry in list_files_in_dir(fs, current_path) {
|
||||
println!("{}", dir_entry.file_name_string());
|
||||
}
|
||||
}
|
||||
"quit" => shutdown(),
|
||||
|
||||
_ => {
|
||||
let home_exec_path = format!("/home/{}/bins/{}.wasm", user, bin_name);
|
||||
let shared_exec_path = format!("/shared/bins/{}.wasm", bin_name);
|
||||
let system_exec_path = format!("/system/bins/{}.wasm", bin_name);
|
||||
|
||||
let home_exec_file = fs.open(&home_exec_path.as_bytes(), OpenOptions::new().read(true));
|
||||
let shared_exec_file = fs.open(&shared_exec_path.as_bytes(), OpenOptions::new().read(true));
|
||||
let system_exec_file = fs.open(&system_exec_path.as_bytes(), OpenOptions::new().read(true));
|
||||
let shared_exec_file =
|
||||
fs.open(&shared_exec_path.as_bytes(), OpenOptions::new().read(true));
|
||||
let system_exec_file =
|
||||
fs.open(&system_exec_path.as_bytes(), OpenOptions::new().read(true));
|
||||
|
||||
let mut in_home = false;
|
||||
let mut in_shared = false;
|
||||
|
@ -237,6 +245,8 @@ pub fn command_parser(user: String, command: String) {
|
|||
println!("No such binary: {}", bin_name);
|
||||
error!("No such binary: {}", bin_name);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
pub fn sound(n_frequency: u32) {
|
||||
|
@ -264,3 +274,14 @@ pub fn sound_off() {
|
|||
};
|
||||
reset_pit_for_cpu();
|
||||
}
|
||||
|
||||
pub fn list_files_in_dir(fs: &Synced<Ext2<Size1024, Vec<u8>>>, path: &[u8]) -> Vec<DirectoryEntry> {
|
||||
let mut entry_list = vec![];
|
||||
|
||||
let dirr = fs.read_dir(b"/").unwrap();
|
||||
for dir_entry in dirr {
|
||||
entry_list.push(dir_entry.unwrap());
|
||||
}
|
||||
|
||||
entry_list
|
||||
}
|
||||
|
|
|
@ -710,6 +710,17 @@ impl DirEntry for DirectoryEntry {
|
|||
}
|
||||
}
|
||||
|
||||
impl DirectoryEntry {
|
||||
/// Turns a filename into a string for display
|
||||
pub fn file_name_string(&self) -> String {
|
||||
let mut filename = String::new();
|
||||
for ch in &self.name {
|
||||
filename.push(*ch as char);
|
||||
}
|
||||
filename
|
||||
}
|
||||
}
|
||||
|
||||
#[cfg(test)]
|
||||
mod tests {
|
||||
use std::cell::RefCell;
|
||||
|
|
Loading…
Reference in a new issue