How to read group descriptor?

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

 



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.



#include<linux/ext3_fs.h>
#include<sys/types.h>
#include<sys/stat.h>
#include<stdio.h>
#include<unistd.h>
#include<fcntl.h>
#include<stdlib.h>
#include<string.h>

#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
bytes)here
	
	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.

	close(fd);	
	return 0;
}



_______________________________________________
Ext3-users mailing list
Ext3-users@xxxxxxxxxx
https://www.redhat.com/mailman/listinfo/ext3-users

[Index of Archives]         [Linux RAID]     [Kernel Development]     [Red Hat Install]     [Video 4 Linux]     [Postgresql]     [Fedora]     [Gimp]     [Yosemite News]

  Powered by Linux