From: Theodore Ts'o <tytso@mit.edu>
To: Felipe Monteiro de Carvalho <felipemonteiro.carvalho@gmail.com>
Cc: linux-ext4@vger.kernel.org
Subject: Re: Beginner questions about ext4
Date: Mon, 15 Jul 2013 12:37:20 -0400 [thread overview]
Message-ID: <20130715163720.GC26359@thunk.org> (raw)
In-Reply-To: <CACyNnZPnzEbcFj69+fGjm1rkLay51WTXFMqr25AOzY3vtvegpw@mail.gmail.com>
On Mon, Jul 15, 2013 at 06:09:03PM +0200, Felipe Monteiro de Carvalho wrote:
> Hello,
>
> Thanks. Now I think that I am getting closer to something more concrete.
>
> My superblock says:
>
> superblock^.s_blocks_per_group = 32768
> superblock^.s_inodes_per_group = 8080
> superblock^.s_log_block_size = 2 -> so each block has 4k bytes
>
> And when reading the root "/" I obtain the following information for
> the directory /bin/ : inode=8081
>
> So I calculate that it should have:
> groupnr=1 (because it is above 8080 inodes per group)
> offset for groupnr 1 --> 4k * 32768 = 0x8000000
>
> But I have utilized a hex editor (oh boy, it was hard to find one that
> would read files over 4GB....) And the directory listing of /bin/ is
> located in aprox. near 0x21B0000
>
> As if each block group would have a size of 0x2000000 .... but this
> size would be valid I would expect if
> superblock^.s_blocks_per_group=8192 ...
>
> Any idea what I missed here that the calculations went wrong?
You're forgetting to read the inode structure. So take the inode
number, determine that it's in the inode table fragment which belongs
to block group #1, then look up in the block group descriptors the
starting block of the inode table for bg #1, then look up the inode
size in the superblock, to determine the block number and offset to
read the inode structure.
Then you need to look at the inode structure to map logical block #0,
to the physical block number where the directory entries are located.
I suggest you RTFS in libext2fs....
- Ted
next prev parent reply other threads:[~2013-07-15 16:37 UTC|newest]
Thread overview: 18+ messages / expand[flat|nested] mbox.gz Atom feed top
2013-06-12 12:20 Beginner questions about ext4 Felipe Monteiro de Carvalho
2013-06-23 6:29 ` Felipe Monteiro de Carvalho
2013-06-23 11:59 ` Theodore Ts'o
2013-07-01 15:23 ` Felipe Monteiro de Carvalho
2013-07-01 16:55 ` Theodore Ts'o
2013-07-10 16:13 ` Felipe Monteiro de Carvalho
2013-07-10 17:24 ` Theodore Ts'o
2013-07-11 7:37 ` Felipe Monteiro de Carvalho
2013-07-11 15:23 ` Theodore Ts'o
2013-07-15 10:20 ` Felipe Monteiro de Carvalho
2013-07-15 13:43 ` Theodore Ts'o
2013-07-15 16:09 ` Felipe Monteiro de Carvalho
2013-07-15 16:37 ` Theodore Ts'o [this message]
2013-07-15 17:55 ` Felipe Monteiro de Carvalho
2013-07-15 18:10 ` Theodore Ts'o
2013-07-15 18:18 ` Felipe Monteiro de Carvalho
2013-07-15 18:59 ` Theodore Ts'o
2013-07-16 6:14 ` Felipe Monteiro de Carvalho
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20130715163720.GC26359@thunk.org \
--to=tytso@mit.edu \
--cc=felipemonteiro.carvalho@gmail.com \
--cc=linux-ext4@vger.kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).