[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]

How to read group descriptor?

Hi All,
I am trying to read group descriptor from disk.
I am able to read the superblock structure successfully.
But I am not getting successful to get the group descriptor. Here is my
code. Please check out what is missing.


#define block_size 4096
#define boot_block_size 1024

int main()
	char *buff = (char *)malloc(block_size);
	struct ext3_super_block * sblock = (struct ext3_super_block
*)malloc(sizeof(struct ext3_super_block));
	struct ext3_group_desc * gdesc = (struct ext3_group_desc
*)malloc(sizeof(struct ext3_group_desc));
	int fd = open("/dev/hda3",O_RDONLY);
	lseek(fd,boot_block_size,SEEK_CUR); //skip the boot block
	read(fd,buff,block_size); //read superblock,we read one block(4096
	memcpy((void *)sblock,(void *)buff,sizeof(struct
ext3_super_block));//here I can fill sblock successfully..
	//read the next block..assuming this will contain group dsc for this
block..i.e. first group descriptor for first block group
	read(fd,buff,block_size); //read first block. It should contain
group description structure.
	memcpy((void *)gdesc,(void *)buff,sizeof(struct ext3_group_desc));
	//try to print some field inside structure..
	printf("\nbg_inode_table:%u",gdesc->bg_inode_table); //Bang....It
gives me zero.

	return 0;

[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]