slight fix to bitmap size calcs, and more info in superblock on num_inodes and num_data

This commit is contained in:
Remzi Arpaci-Dusseau
2022-12-07 17:32:27 -06:00
parent 6269639845
commit 435fd35685
2 changed files with 12 additions and 4 deletions

View File

@@ -62,16 +62,22 @@ int main(int argc, char *argv[]) {
// presumed: block 0 is the super block
super_t s;
// totals
s.num_inodes = num_inodes;
s.num_data = num_data;
// inode bitmap
int bits_per_block = (8 * UFS_BLOCK_SIZE); // remember, there are 8 bits per byte
s.inode_bitmap_addr = 1;
s.inode_bitmap_len = num_inodes / UFS_BLOCK_SIZE;
if (num_inodes % UFS_BLOCK_SIZE != 0)
s.inode_bitmap_len = num_inodes / bits_per_block;
if (num_inodes % bits_per_block != 0)
s.inode_bitmap_len++;
// data bitmap
s.data_bitmap_addr = s.inode_bitmap_addr + s.inode_bitmap_len;
s.data_bitmap_len = num_data / UFS_BLOCK_SIZE;
if (num_data % UFS_BLOCK_SIZE != 0)
s.data_bitmap_len = num_data / bits_per_block;
if (num_data % bits_per_block != 0)
s.data_bitmap_len++;
// inode table

View File

@@ -29,6 +29,8 @@ typedef struct __super {
int inode_region_len; // in blocks
int data_region_addr; // block address (in blocks)
int data_region_len; // in blocks
int num_inodes; // just the number of inodes
int num_data; // and data blocks...
} super_t;