diff options
Diffstat (limited to 'src/main.rs')
-rw-r--r-- | src/main.rs | 22 |
1 files changed, 20 insertions, 2 deletions
diff --git a/src/main.rs b/src/main.rs index 5d460fc..78f338a 100644 --- a/src/main.rs +++ b/src/main.rs @@ -7,12 +7,17 @@ mod utils; use clap::Parser; use fuser::MountOption; +use indexmap::IndexMap; use log::debug; +use lru::LruCache; +use std::collections::HashMap; +use std::ffi::OsString; +use std::num::NonZeroUsize; +use std::sync::atomic::AtomicU64; use std::sync::Arc; use std::time::Duration; -use crate::disk::block::InodeBlock; -use crate::disk::inode::InodeMode; +use crate::disk::block::{DirectoryEntry, InodeBlock}; use crate::memory::cached_block::BlockCache; use block_device::{memory_disk::MemoryDisk, BlockDevice, BLOCK_SIZE}; use disk::bitmap::Bitmap; @@ -61,6 +66,13 @@ struct AyaFS { inode_start_block: usize, data_start_block: usize, + next_file_handle: AtomicU64, + // file descriptor -> (inode index, read, write) + file_handle_map: HashMap<u64, (usize, bool, bool)>, + + // inode index -> (index aware) hashmap that maps dir entry name to inode index + dir_entry_map: LruCache<usize, IndexMap<OsString, DirectoryEntry>>, + cached_inodes: BlockCache<InodeBlock>, cached_blocks: BlockCache<DataBlock>, } @@ -111,6 +123,12 @@ impl AyaFS { + inode_bitmap_block_number + inode_block_number + 1, + + next_file_handle: AtomicU64::new(3), // 0,1,2 are stdin, stdout and stderr + file_handle_map: HashMap::new(), + + dir_entry_map: LruCache::new(NonZeroUsize::new(1024).unwrap()), + cached_inodes: BlockCache::new(device.clone(), 1024), cached_blocks: BlockCache::new(device.clone(), 8192), }; |