slight fix to bitmap size calcs, and more info in superblock on num_inodes and num_data
This commit is contained in:
@@ -62,16 +62,22 @@ int main(int argc, char *argv[]) {
|
|||||||
// presumed: block 0 is the super block
|
// presumed: block 0 is the super block
|
||||||
super_t s;
|
super_t s;
|
||||||
|
|
||||||
|
// totals
|
||||||
|
s.num_inodes = num_inodes;
|
||||||
|
s.num_data = num_data;
|
||||||
|
|
||||||
// inode bitmap
|
// 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_addr = 1;
|
||||||
s.inode_bitmap_len = num_inodes / UFS_BLOCK_SIZE;
|
s.inode_bitmap_len = num_inodes / bits_per_block;
|
||||||
if (num_inodes % UFS_BLOCK_SIZE != 0)
|
if (num_inodes % bits_per_block != 0)
|
||||||
s.inode_bitmap_len++;
|
s.inode_bitmap_len++;
|
||||||
|
|
||||||
// data bitmap
|
// data bitmap
|
||||||
s.data_bitmap_addr = s.inode_bitmap_addr + s.inode_bitmap_len;
|
s.data_bitmap_addr = s.inode_bitmap_addr + s.inode_bitmap_len;
|
||||||
s.data_bitmap_len = num_data / UFS_BLOCK_SIZE;
|
s.data_bitmap_len = num_data / bits_per_block;
|
||||||
if (num_data % UFS_BLOCK_SIZE != 0)
|
if (num_data % bits_per_block != 0)
|
||||||
s.data_bitmap_len++;
|
s.data_bitmap_len++;
|
||||||
|
|
||||||
// inode table
|
// inode table
|
||||||
|
|||||||
@@ -29,6 +29,8 @@ typedef struct __super {
|
|||||||
int inode_region_len; // in blocks
|
int inode_region_len; // in blocks
|
||||||
int data_region_addr; // block address (in blocks)
|
int data_region_addr; // block address (in blocks)
|
||||||
int data_region_len; // in blocks
|
int data_region_len; // in blocks
|
||||||
|
int num_inodes; // just the number of inodes
|
||||||
|
int num_data; // and data blocks...
|
||||||
} super_t;
|
} super_t;
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user