From 960da433836945a8b235029287ccf25caf1f0e07 Mon Sep 17 00:00:00 2001 From: TheOddGarlic Date: Sat, 6 Aug 2022 22:27:25 +0300 Subject: [PATCH] NOT ONE, but TWO deadlocks fixed! --- ableos/src/filesystem/mod.rs | 9 ++++++--- ableos/src/scratchpad.rs | 3 +-- 2 files changed, 7 insertions(+), 5 deletions(-) diff --git a/ableos/src/filesystem/mod.rs b/ableos/src/filesystem/mod.rs index 8f25dd0..76a529f 100644 --- a/ableos/src/filesystem/mod.rs +++ b/ableos/src/filesystem/mod.rs @@ -39,8 +39,8 @@ where pub fn init() -> Result<()> { let mut state = KERNEL_STATE.lock(); - let mut vfs = VFS.lock(); let fs = load_fs()?; + let mut vfs = VFS.lock(); vfs.init(fs.root_node()); state.add_storage_device(fs); Ok(()) @@ -56,9 +56,12 @@ fn load_fs() -> Result>> { pub fn walk>(dir: Arc, path: S) { let path = path.into(); if let Some(dir) = dir.directory() { - let mut vfs = VFS.lock(); for entry in dir { - let fs_node = vfs.fs_node(entry.node()).unwrap(); + let fs_node = { + let mut vfs = VFS.lock(); + vfs.fs_node(entry.node()).unwrap() + }; + println!("{}/{} => {}", path, entry.name(), fs_node.inode()); trace!("{entry:#?}"); if entry.name() != "." && entry.name() != ".." { diff --git a/ableos/src/scratchpad.rs b/ableos/src/scratchpad.rs index 8cbf600..3d87231 100644 --- a/ableos/src/scratchpad.rs +++ b/ableos/src/scratchpad.rs @@ -10,14 +10,13 @@ use crate::devices::pci::brute_force_scan; use crate::filesystem::vfs::VFS; use crate::systeminfo::{KERNEL_VERSION, RELEASE_TYPE}; use crate::time::fetch_time; -use crate::KERNEL_STATE; +use crate::{filesystem, KERNEL_STATE}; use crate::{ arch::shutdown, rhai_shell::KEYBUFF, vterm::VTerm, // wasm_jumploader::run_program, }; -use crate::{filesystem, KERNEL_STATE}; use acpi::{AcpiTables, PlatformInfo}; use cpuio::{inb, outb};