MCPcopy Create free account
hub / github.com/chyyuu/os_kernel_lab / new

Method new

easy-fs/src/block_cache.rs:18–28  ·  view source on GitHub ↗

Load a new BlockCache from disk.

(block_id: usize, block_device: Arc<dyn BlockDevice>)

Source from the content-addressed store, hash-verified

16impl BlockCache {
17 /// Load a new BlockCache from disk.
18 pub fn new(block_id: usize, block_device: Arc<dyn BlockDevice>) -> Self {
19 // for alignment and move effciency
20 let mut cache = vec![0u8; BLOCK_SZ];
21 block_device.read_block(block_id, &mut cache);
22 Self {
23 cache,
24 block_id,
25 block_device,
26 modified: false,
27 }
28 }
29
30 fn addr_of_offset(&self, offset: usize) -> usize {
31 &self.cache[offset] as *const _ as usize

Callers

nothing calls this directly

Calls 1

read_blockMethod · 0.45

Tested by

no test coverage detected