Fix #79.
This commit is contained in:
parent
fc19596945
commit
10e1c57b7d
1 changed files with 5 additions and 2 deletions
|
@ -1,11 +1,13 @@
|
||||||
use super::{BlockDevice, BLOCK_SZ};
|
use super::{BlockDevice, BLOCK_SZ};
|
||||||
use alloc::collections::VecDeque;
|
use alloc::collections::VecDeque;
|
||||||
use alloc::sync::Arc;
|
use alloc::sync::Arc;
|
||||||
|
use alloc::vec;
|
||||||
|
use alloc::vec::Vec;
|
||||||
use lazy_static::*;
|
use lazy_static::*;
|
||||||
use spin::Mutex;
|
use spin::Mutex;
|
||||||
|
|
||||||
pub struct BlockCache {
|
pub struct BlockCache {
|
||||||
cache: [u8; BLOCK_SZ],
|
cache: Vec<u8>,
|
||||||
block_id: usize,
|
block_id: usize,
|
||||||
block_device: Arc<dyn BlockDevice>,
|
block_device: Arc<dyn BlockDevice>,
|
||||||
modified: bool,
|
modified: bool,
|
||||||
|
@ -14,7 +16,8 @@ pub struct BlockCache {
|
||||||
impl BlockCache {
|
impl BlockCache {
|
||||||
/// Load a new BlockCache from disk.
|
/// Load a new BlockCache from disk.
|
||||||
pub fn new(block_id: usize, block_device: Arc<dyn BlockDevice>) -> Self {
|
pub fn new(block_id: usize, block_device: Arc<dyn BlockDevice>) -> Self {
|
||||||
let mut cache = [0u8; BLOCK_SZ];
|
// for alignment and move effciency
|
||||||
|
let mut cache = vec![0u8; BLOCK_SZ];
|
||||||
block_device.read_block(block_id, &mut cache);
|
block_device.read_block(block_id, &mut cache);
|
||||||
Self {
|
Self {
|
||||||
cache,
|
cache,
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue