summaryrefslogtreecommitdiff
path: root/src/disk/bitmap.rs
diff options
context:
space:
mode:
Diffstat (limited to 'src/disk/bitmap.rs')
-rw-r--r--src/disk/bitmap.rs28
1 files changed, 14 insertions, 14 deletions
diff --git a/src/disk/bitmap.rs b/src/disk/bitmap.rs
index d5a8fe9..64389c2 100644
--- a/src/disk/bitmap.rs
+++ b/src/disk/bitmap.rs
@@ -1,4 +1,5 @@
use crate::block_device::{BlockDevice, BLOCK_SIZE};
+use std::cell::RefCell;
use std::sync::Arc;
pub struct Bitmap {
@@ -6,7 +7,6 @@ pub struct Bitmap {
pub length: usize,
pub device: Arc<dyn BlockDevice>,
pub data: Vec<u8>,
- pub dirty_blocks: Vec<usize>,
}
impl Bitmap {
@@ -16,15 +16,14 @@ impl Bitmap {
length,
device,
data: vec![0u8; length * BLOCK_SIZE],
- dirty_blocks: Vec::new(),
}
}
pub fn allocate(&mut self) -> Option<usize> {
+ // let mut data = self.data.borrow_mut();
for (i, byte) in self.data.iter_mut().enumerate() {
let leading_ones = byte.leading_ones();
if leading_ones != 8 {
*byte |= (1 << (7 - leading_ones)) as u8;
- self.dirty_blocks.push(i / BLOCK_SIZE);
return Some(i * 8 + leading_ones as usize);
}
}
@@ -33,6 +32,7 @@ impl Bitmap {
}
pub fn query(&self, index: usize) -> bool {
+ // let data = self.data.borrow();
if index == 0 {
false
} else {
@@ -40,15 +40,15 @@ impl Bitmap {
}
}
- fn write_back(&mut self) {
- for block_index_offset in self.dirty_blocks.iter() {
- let buffer_front_index = BLOCK_SIZE * block_index_offset;
- let buffer_back_index = BLOCK_SIZE * (block_index_offset + 1);
- self.device.write(
- self.starting_block + block_index_offset,
- &self.data[buffer_front_index..buffer_back_index],
- );
- }
- self.dirty_blocks = Vec::new();
- }
+ // fn write_back(&mut self) {
+ // for block_index_offset in self.dirty_blocks.iter() {
+ // let buffer_front_index = BLOCK_SIZE * block_index_offset;
+ // let buffer_back_index = BLOCK_SIZE * (block_index_offset + 1);
+ // self.device.write(
+ // self.starting_block + block_index_offset,
+ // &self.data[buffer_front_index..buffer_back_index],
+ // );
+ // }
+ // self.dirty_blocks = Vec::new();
+ // }
}