Hi,
I am getting a wierd error of BUS ERROR I found that it is during this call
Code:
init_bitmap(imap->bitmap,num_of_inodes);
the same function is working just an instruction before for a different bitmap. here is the code for the program
Code:
int main(int argc, char *argv[])
{
FILE *stream;
b_map *bmap;
i_map *imap;
sb_t *sb = (sb_t *)malloc(sizeof(sb_t));
inode_t *ino = (inode_t *)malloc(sizeof(inode_t));
if((stream = fopen("disk0","r+")) == NULL)
printf("Can not open [disk0] for formatting ... \n");
else
printf("[disk0] open for formatting ... \n\n");
init_bitmap(bmap->bitmap,num_of_blocks);
init_bitmap(imap->bitmap,num_of_inodes); <===== this line
printf("Block Bitmap\n");
for (i = 0; i < num_of_blocks; i++)
printf("[%d]",bmap->bitmap[i]);
printf("\n\n");
printf("[%d] - Block bitmap structure size in bytes.\n",sizeof(*bmap));
printf("[%d] - Inode bitmap structure size in bytes.\n",sizeof(*imap));
sb->s_inode_count = num_of_inodes;
sb->s_block_count = num_of_blocks;
sb->s_first_data_block = 2;
n = allocate_bit(bmap->bitmap,sizeof(bmap->bitmap)/sizeof(int));
printf("\n[%d] offset into the bitmap\n",n);
for (i = 0; i < num_of_blocks; i++)
printf("[%d]",bmap->bitmap[i]);
printf("\n");
n = sizeof(*sb)+sizeof(*bmap)+sizeof(*imap);
printf("[%d] total bytes to be written to disk\n",n);
printf("[%d,%d] - [Total inodes,Total blocks] on disk\n",sb->s_inode_count,sb->s_block_count);
printf("[%d] - size of super block structure\n",sizeof(*sb));
printf("[%d] - size of inode data structure\n",sizeof(*ino));
fwrite(sb,sizeof(*sb),1,stream);
fwrite(ino,sizeof(*ino),1,stream);
fwrite(bmap,sizeof(*bmap),1,stream);
if(!(close(stream)))
printf("Error closing disk0\n");
else
printf("\n[disk0] formatted successfully ...\n");
return 0;
}