You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: easy-fs/src/bitmap.rs
+11-7Lines changed: 11 additions & 7 deletions
Original file line number
Diff line number
Diff line change
@@ -1,30 +1,34 @@
1
+
//! Disk layout & data structure layer: about bitmaps
2
+
//!
3
+
//! There are two different types of [`Bitmap`] in the easy-fs layout that manage inodes and blocks, respectively. Each bitmap consists of several blocks, each of which is 512 bytes, or 4096 bits. Each bit represents the allocation status of an inode/data block, 0 means unallocated, and 1 means allocated. What the bitmap does is allocate and de-allocate inodes/data blocks via bit-based allocation (looking for a bit of 0 and setting it to 1) and de-allocation (clearing the bit).
1
4
usesuper::{get_block_cache,BlockDevice,BLOCK_SZ};
2
5
use alloc::sync::Arc;
3
-
6
+
/// A bitmap block
4
7
typeBitmapBlock = [u64;64];
5
-
8
+
/// Number of bits in a block
6
9
constBLOCK_BITS:usize = BLOCK_SZ*8;
7
-
10
+
/// bitmap struct for disk block management
8
11
pubstructBitmap{
9
12
start_block_id:usize,
10
13
blocks:usize,
11
14
}
12
15
13
-
/// Return (block_pos, bits64_pos, inner_pos)
16
+
/// Decompose bits into (block_pos, bits64_pos, inner_pos)
0 commit comments