2008-09-17 14:07:08

by Rohit Sharma

[permalink] [raw]
Subject: Reading inode..

I want to read ext2 inode.

Its just like i have a inode no. say 1900..
so from the block group we can read the group descriptor and from there we
can identify the first block no. of the inode table.
So we can read the required inode no.i.e. 1900 from this inode table.
I found that there are 8176 inodes per block group using tune2fs utility,
so if i am interested in reading 8177th inode then i have to move on
to next block groups inode table.

I just want to verify if i am correct on this.


2008-09-18 21:36:51

by Andreas Dilger

[permalink] [raw]
Subject: Re: Reading inode..

On Sep 17, 2008 19:37 +0530, Rohit Sharma wrote:
> I want to read ext2 inode.
>
> Its just like i have a inode no. say 1900..
> so from the block group we can read the group descriptor and from there we
> can identify the first block no. of the inode table.
> So we can read the required inode no.i.e. 1900 from this inode table.
> I found that there are 8176 inodes per block group using tune2fs utility,

That is true for your filesystem, it might be different for each ext*
filesystems, depending on many parameters.

> so if i am interested in reading 8177th inode then i have to move on
> to next block groups inode table.

Right, for this particular filesystem.

Note also that there is libext2fs for performing operations like this on
the filesystem in userspace.

If you are reading the inode from within the kernel you can just use
ext2_read_inode().

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