FAQ Search Today's Posts Mark Forums Read
» Video Reviews

» Linux Archive

Linux-archive is a website aiming to archive linux email lists and to make them easily accessible for linux users/developers.


» Sponsor

» Partners

» Sponsor

Go Back   Linux Archive > Redhat > EXT3 Users

 
 
LinkBack Thread Tools
 
Old 02-01-2008, 10:21 AM
"ashish mahamuni"
 
Default 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.



#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("
bg_inode_table:%u",gdesc->bg_inode_table); //Bang....It
gives me zero.

close(fd);
return 0;
}



_______________________________________________
Ext3-users mailing list
Ext3-users@redhat.com
https://www.redhat.com/mailman/listinfo/ext3-users
 
Old 02-02-2008, 06:06 AM
Andreas Dilger
 
Default How to read group descriptor?

On Feb 01, 2008 16:51 +0530, ashish mahamuni wrote:
> 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.

Why not just use libext2fs?

Cheers, Andreas
--
Andreas Dilger
Sr. Staff Engineer, Lustre Group
Sun Microsystems of Canada, Inc.

_______________________________________________
Ext3-users mailing list
Ext3-users@redhat.com
https://www.redhat.com/mailman/listinfo/ext3-users
 
Old 02-04-2008, 05:13 AM
ashish mahamuni
 
Default How to read group descriptor?

--- On Sat, 2/2/08, Andreas Dilger <adilger@sun.com> wrote:

> From: Andreas Dilger <adilger@sun.com>
> Subject: Re: How to read group descriptor?
> To: "ashish mahamuni" <ashitpro@yahoo.co.in>
> Cc: ext3-users@redhat.com
> Date: Saturday, 2 February, 2008, 12:36 PM
> On Feb 01, 2008 16:51 +0530, ashish mahamuni wrote:
> > 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.
>
> Why not just use libext2fs?
>
> Cheers, Andreas
> --
> Andreas Dilger
> Sr. Staff Engineer, Lustre Group
> Sun Microsystems of Canada, Inc.

I don't know how to use libext2fs.
Where can I get any documentation for this library?


Get the freedom to save as many mails as you wish. To know how, go to http://help.yahoo.com/l/in/yahoo/mail/yahoomail/tools/tools-08.html

_______________________________________________
Ext3-users mailing list
Ext3-users@redhat.com
https://www.redhat.com/mailman/listinfo/ext3-users
 
Old 02-04-2008, 05:26 AM
ashish mahamuni
 
Default How to read group descriptor?

--- On Mon, 4/2/08, ashish mahamuni <ashitpro@yahoo.co.in> wrote:

> From: ashish mahamuni <ashitpro@yahoo.co.in>
> Subject: Re: How to read group descriptor?
> To: "Andreas Dilger" <adilger@sun.com>
> Cc: ext3-users@redhat.com
> Date: Monday, 4 February, 2008, 11:43 AM
> --- On Sat, 2/2/08, Andreas Dilger <adilger@sun.com>
> wrote:
>
> > From: Andreas Dilger <adilger@sun.com>
> > Subject: Re: How to read group descriptor?
> > To: "ashish mahamuni"
> <ashitpro@yahoo.co.in>
> > Cc: ext3-users@redhat.com
> > Date: Saturday, 2 February, 2008, 12:36 PM
> > On Feb 01, 2008 16:51 +0530, ashish mahamuni wrote:
> > > 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.
> >
> > Why not just use libext2fs?
> >
> > Cheers, Andreas
> > --
> > Andreas Dilger
> > Sr. Staff Engineer, Lustre Group
> > Sun Microsystems of Canada, Inc.
>
> I don't know how to use libext2fs.
> Where can I get any documentation for this library?
>
>
> Get the freedom to save as many mails as you wish. To
> know how, go to
> http://help.yahoo.com/l/in/yahoo/mail/yahoomail/tools/tools-08.html
>
> _______________________________________________
> Ext3-users mailing list
> Ext3-users@redhat.com
> https://www.redhat.com/mailman/listinfo/ext3-users


Well.
I found out the documentation for libext2fs..
Sorry for being early bird.
But I don't find any function which will return me group discriptor structure.


5, 50, 500, 5000 - Store N number of mails in your inbox. Go to http://help.yahoo.com/l/in/yahoo/mail/yahoomail/tools/tools-08.html

_______________________________________________
Ext3-users mailing list
Ext3-users@redhat.com
https://www.redhat.com/mailman/listinfo/ext3-users
 
Old 02-05-2008, 05:57 AM
ashish mahamuni
 
Default How to read group descriptor?

--- On Tue, 5/2/08, Peter Teoh <htmldeveloper@gmail.com> wrote:

> From: Peter Teoh <htmldeveloper@gmail.com>
> Subject: Re: How to read group descriptor?
> To: "ashish mahamuni" <ashitpro@yahoo.co.in>
> 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@yahoo.co.in> 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("
bg_inode_table:%u",gdesc->bg_inode_table);
> //Bang....It
> > gives me zero.
> >
> > close(fd);
> > return 0;
> > }
> >
> >
> >
> > _______________________________________________
> > Ext3-users mailing list
> > Ext3-users@redhat.com
> > 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@redhat.com
https://www.redhat.com/mailman/listinfo/ext3-users
 
Old 02-05-2008, 12:29 PM
Theodore Tso
 
Default How to read group descriptor?

On Mon, Feb 04, 2008 at 11:56:45AM +0530, ashish mahamuni wrote:
>
> I found out the documentation for libext2fs..
> Sorry for being early bird.
> But I don't find any function which will return me group discriptor structure.
>

After you open the filesystem, the superblock structure is available
in fs->super. See the sources for misc/dumpe2fs.c and lib/e2p/ls.c
for more information.

And yes, the documentation could be better; patches and other
improvements are welcome. :-)

- Ted

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

Thread Tools




All times are GMT. The time now is 09:00 AM.

VBulletin, Copyright ©2000 - 2014, Jelsoft Enterprises Ltd.
Content Relevant URLs by vBSEO ©2007, Crawlability, Inc.
Copyright 2007 - 2008, www.linux-archive.org