--- On Tue, 5/2/08, Peter Teoh <htmldeveloper@xxxxxxxxx> wrote: > From: Peter Teoh <htmldeveloper@xxxxxxxxx> > Subject: Re: How to read group descriptor? > To: "ashish mahamuni" <ashitpro@xxxxxxxxxxx> > Date: Tuesday, 5 February, 2008, 4:41 AM > How about the using the command: > > Using this to check for ext2/ext3 filesystem: > file -s /dev/sdb1 > and > /sbin/dumpe2fs /dev/sdb1? > > to dump the group descriptor? > > On Feb 1, 2008 7:21 PM, ashish mahamuni > <ashitpro@xxxxxxxxxxx> wrote: > > 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 > > > > > > -- > Peter Teoh > HP: 96809281 Thats fine. But I need it in my source code for some calculations. Bring your gang together - do your thing. Go to http://in.promos.yahoo.com/groups _______________________________________________ Ext3-users mailing list Ext3-users@xxxxxxxxxx https://www.redhat.com/mailman/listinfo/ext3-users