From 12cb090fcf6fcdee59c945e64df3a2066ac76f9f Mon Sep 17 00:00:00 2001 From: FactorialN Date: Mon, 27 Nov 2023 22:12:11 -0800 Subject: [PATCH] try to fix layer1 --- lib/fs/fs.cpp | 2 +- test/layer1_API.cpp | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/lib/fs/fs.cpp b/lib/fs/fs.cpp index c87ced9..d0caf08 100644 --- a/lib/fs/fs.cpp +++ b/lib/fs/fs.cpp @@ -4,7 +4,7 @@ Fs::Fs(RawDisk *disk) : disk(disk) { superblock = SuperBlock_Data(); inode_manager = new INode_Manager_Freelist(this, 1, 1 + NUM_INODE_BLOCKS); datablock_manager = - new DataBlock_Manager_Bitmap(this, 1 + NUM_INODE_BLOCKS, NUM_BLOCKS); + new DataBlock_Manager_Bitmap(this, 1 + NUM_INODE_BLOCKS, disk->diskSize/IO_BLOCK_SIZE); }; Fs::~Fs() { diff --git a/test/layer1_API.cpp b/test/layer1_API.cpp index b49f0b2..fadb68b 100644 --- a/test/layer1_API.cpp +++ b/test/layer1_API.cpp @@ -65,12 +65,12 @@ int main(int argc, char *argv[]) { 1); // the first 8 bytes of 4k I/O block will store // the next address(after 2048*4k I/O block) // test the end of the datablock - H->read_block(NUM_BLOCKS - DATABLOCKS_PER_BITMAP_BLOCK - 1, buffer); + H->read_block(fs->disk->diskSize/IO_BLOCK_SIZE - DATABLOCKS_PER_BITMAP_BLOCK - 1, buffer); t = 0; for (int j = 0; j < 8; j++) t |= ((u_int64_t)(unsigned char)buffer[j]) << (8 * j); - assert(t == NUM_BLOCKS - DATABLOCKS_PER_BITMAP_BLOCK - 1); + assert(t == fs->disk->diskSize/IO_BLOCK_SIZE - DATABLOCKS_PER_BITMAP_BLOCK - 1); /***************************test inode * de/allocation**********************************/