-
Notifications
You must be signed in to change notification settings - Fork 19
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Implements tmpfs root, mkdir and lookup (#733)
Co-authored-by: tompro <tomas.prochazka@apertia.cz>
- Loading branch information
1 parent
921969c
commit 5675e20
Showing
16 changed files
with
410 additions
and
129 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
use crate::fs::{Mount, Vnode}; | ||
use std::{ | ||
collections::HashMap, | ||
sync::{Arc, Mutex}, | ||
}; | ||
|
||
pub(super) static NULL_HASHTABLE: Mutex<NullHashTable> = Mutex::new(NullHashTable(None)); | ||
|
||
// Maps a hash to a pair of (lower vnode, null vnode). | ||
pub(super) struct NullHashTable(Option<HashMap<u32, (Arc<Vnode>, Arc<Vnode>)>>); | ||
|
||
impl NullHashTable { | ||
/// See `null_hashget` on the PS4 for a reference. | ||
pub(super) fn get(&mut self, mnt: &Arc<Mount>, lower: &Arc<Vnode>) -> Option<Arc<Vnode>> { | ||
let table = self.0.get_or_insert(HashMap::new()); | ||
|
||
let hash = lower.hash_index(); | ||
|
||
let (stored_lower, nullnode) = table.get(&hash)?; | ||
|
||
if Arc::ptr_eq(lower, stored_lower) && Arc::ptr_eq(nullnode.mount(), mnt) { | ||
return Some(nullnode.clone()); | ||
} | ||
|
||
None | ||
} | ||
|
||
/// See `null_hashins` on the PS4 for a reference. | ||
pub(super) fn insert(&mut self, mnt: &Arc<Mount>, lower: &Arc<Vnode>, nullnode: &Arc<Vnode>) { | ||
let table = self.0.get_or_insert(HashMap::new()); | ||
|
||
let hash_index = lower.hash_index(); | ||
|
||
table.insert(hash_index, (lower.clone(), nullnode.clone())); | ||
} | ||
} |
Oops, something went wrong.