All of lore.kernel.org
 help / color / mirror / Atom feed
From: Avi Deitcher <avi@deitcher.net>
To: "Theodore Ts'o" <tytso@mit.edu>
Cc: linux-ext4@vger.kernel.org
Subject: Re: algorithm for half-md4 used in htree directories
Date: Tue, 12 Oct 2021 19:20:26 -0700	[thread overview]
Message-ID: <CAF1vpkidOGm0OmRac+OqaXcnJptn1O22OLHXJZoPfEbhxb3Ttw@mail.gmail.com> (raw)
In-Reply-To: <YWXGRgfxJZMe9iut@mit.edu>

Yep, right here
https://git.kernel.org/pub/scm/fs/ext2/e2fsprogs.git/tree/lib/ext2fs/dirhash.c

Hey, that's your name on it, Ted!

I am close, must be messing it up somehow. I literally copied the
majority of that (actually, some slight variant, but basically the
same) into a standalone main.c, removed any library dependencies by
copying those in so I can get a standalone, and I still am not quite
getting it. Maybe I am messing up the seed?

dump2fs of the superblock shows:

Default directory hash:   half_md4
Directory Hash Seed:      d64563bc-ea93-4aaf-a943-4657711ed153

and debugfs of the hash tree shows:

Root node dump:
         Reserved zero: 0
         Hash Version: 1
         Info length: 8
         Indirect levels: 1
         Flags: 0
Number of entries (count): 2
Number of entries (limit): 123
Checksum: 0x49f0afdc
Entry #0: Hash 0x00000000, block 124
Entry #1: Hash 0x78b6e3b8, block 128

Entry #0: Hash 0x00000000, block 124
Number of entries (count): 113
Number of entries (limit): 126
Checksum: 0x78407270
Entry #0: Hash 0x00000000, block 1
Entry #1: Hash 0x00f48688, block 193
...

So it has the hash version correct (I also gdb-ed through my little
program. Maybe I am getting the u32 order wrong in the seed? Or the
endianness?

I should just create a gist with this, shouldn't I?

On Tue, Oct 12, 2021 at 10:30 AM Theodore Ts'o <tytso@mit.edu> wrote:
>
> On Mon, Oct 11, 2021 at 07:58:00PM -0700, Avi Deitcher wrote:
> > Aha. I missed that the seed is injected into buf before passing it
> > into half_md4_transform. I was looking at it as just the empty buffer
> > before the first iteration of the loop (or, in my case, since I was
> > testing with a 6 char filename, the only iteration).
> >
> > I will repeat my experiment with that and see if I can tease it out.
>
> BTW, if you are looking for a userspace implementation of the hash,
> it's available in libext2fs in e2fsprogs.
>
> Cheers,
>
>                                         - Ted



-- 
Avi Deitcher
avi@deitcher.net
Follow me http://twitter.com/avideitcher
Read me http://blog.atomicinc.com

  reply	other threads:[~2021-10-13  2:20 UTC|newest]

Thread overview: 15+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-10-01 11:49 algorithm for half-md4 used in htree directories Avi Deitcher
2021-10-03 12:47 ` Avi Deitcher
2021-10-03 16:43   ` Andreas Dilger
2021-10-04  7:57     ` Avi Deitcher
2021-10-11 15:30       ` Avi Deitcher
2021-10-11 20:20         ` Theodore Ts'o
2021-10-12  2:58           ` Avi Deitcher
2021-10-12 17:30             ` Theodore Ts'o
2021-10-13  2:20               ` Avi Deitcher [this message]
2021-10-15 18:43               ` Avi Deitcher
2021-10-15 19:10                 ` Theodore Ts'o
2021-10-15 19:43                   ` Avi Deitcher
2021-10-15 20:30                     ` Theodore Ts'o
2021-10-15 19:50                   ` Theodore Ts'o
2021-10-18 16:56                     ` Avi Deitcher

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=CAF1vpkidOGm0OmRac+OqaXcnJptn1O22OLHXJZoPfEbhxb3Ttw@mail.gmail.com \
    --to=avi@deitcher.net \
    --cc=linux-ext4@vger.kernel.org \
    --cc=tytso@mit.edu \
    /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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.