Received: by 2002:a05:6a10:d5a5:0:0:0:0 with SMTP id gn37csp2787102pxb; Sun, 3 Oct 2021 05:48:20 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxHKPrB0YxLDdCePjZCSXW7o8tz6gAFK76/SZX/AHu6CerJmow77PfYUTUnsOo17IhBUbVo X-Received: by 2002:a63:f241:: with SMTP id d1mr6363965pgk.74.1633265299854; Sun, 03 Oct 2021 05:48:19 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1633265299; cv=none; d=google.com; s=arc-20160816; b=rl+b+2G4DL6Pe/GmWOM4S3evMnmIaPU25tdh0MgptdMQ/0wd5tcCz34tgmtEfCwp3F FZFR1+jF5wVNJ/Pn6jTZqU4PXelo1xk/kDo4KEOgj+GIKro7hFRX3fc1aRWrvd0b3H09 tjEh7wvcZfoITtwMBWcq8eAzLWkHQpfQEGDQafw+0rvmPJCFkU8b1fJoDRGdJ9d+FmxX kyfpEehQqXJ/2p4p8PsXhXGgddY8qgkgS50krIwmudiEVdQfVkNAjg6r6qdON2+HBYRZ UNn41sFAoONWHpz10U29i5NrAXlo28l8MgzezWMHIe1e/OnDj46TkDW+UWzVCzBj6zhc NkbA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:to:subject:message-id:date:from:in-reply-to :references:mime-version:dkim-signature; bh=X3xTNBqrAPeWetQyX0mgGNU9IhIdQFU8X083g79QyIg=; b=YhvMiOwxgiItk4BcefDyyhQ5c9qoJWcCJQDu0yRkzm63sh8nrMg16WfZb0+IpQiXkp k9UDDouj2bT+chpsJP3bT0nkkmhb6GdxQKIv6KTmaNVuL/ryyDQdVnpk97BxU2eGsy+V ZQDSG9N6U1D6U/nUWMfNVv4Q4+QTNzAX+U1HkeWUY/xDTiKlms6LrPzqxl34H+rWKs3H pKcP0CV8pxyKlwJPaeODcN6s6Q2q1cPVNAU7X/29no8xv+QCxnfaYyvAY63g2aS7dVJa 20FKB/nIOayiVP6ga7t8z0Akv7aTP5wAQL+r6s9WQylT2KTbsJqhordNdFffVz9eD+p0 mrww== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@deitcher-net.20210112.gappssmtp.com header.s=20210112 header.b=gAOd7B9X; spf=pass (google.com: domain of linux-ext4-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-ext4-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id y6si14517626pfr.110.2021.10.03.05.47.53; Sun, 03 Oct 2021 05:48:19 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-ext4-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@deitcher-net.20210112.gappssmtp.com header.s=20210112 header.b=gAOd7B9X; spf=pass (google.com: domain of linux-ext4-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-ext4-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230260AbhJCMtC (ORCPT + 99 others); Sun, 3 Oct 2021 08:49:02 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:45458 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230207AbhJCMtC (ORCPT ); Sun, 3 Oct 2021 08:49:02 -0400 Received: from mail-ed1-x52d.google.com (mail-ed1-x52d.google.com [IPv6:2a00:1450:4864:20::52d]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 933F1C0613EC for ; Sun, 3 Oct 2021 05:47:14 -0700 (PDT) Received: by mail-ed1-x52d.google.com with SMTP id p11so453322edy.10 for ; Sun, 03 Oct 2021 05:47:14 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=deitcher-net.20210112.gappssmtp.com; s=20210112; h=mime-version:references:in-reply-to:from:date:message-id:subject:to; bh=X3xTNBqrAPeWetQyX0mgGNU9IhIdQFU8X083g79QyIg=; b=gAOd7B9Xm6Y3wMNcIY0UE9JB8JKBFNZFTc8vvkVHyVKeFrMHGYERtLNQRAVbgT0tP4 01t1wxbBis4uKuc3DP43CZ2TT52juGPu4VBQwZW3Twj/vTQCydqVHEOl9SRwn0Bezh3w 2+K8raBnGaI1CnOFNp6swVVkFar/jbpsAS4V9Tw2fKpY7z36K6hZcizvgaMNH8HsTCHs oqnxECGS1T2KiTITKuCvSa2yUYNgqridvAX4TiYewTC4NxrcZ9Ys0RqCU2L+OaNW1H+F oKQQNJ5sBDMDr7zCsfWNzsWavfZnUg+DwEHvlqseXR2Gb/1Ne7qHywfpevsMjhw7mciY XZlQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to; bh=X3xTNBqrAPeWetQyX0mgGNU9IhIdQFU8X083g79QyIg=; b=Hd5rM/Zf0yC9KD57I/iWnuBv9M8hGwiCu2tu/VyCcV/5U62RQ0ZGIlY6dBfT4v3Ps9 ZPzVthUkp1+T7ZtH2N0O6oyOtcSAvniXXA+poY4XrAtQ64fe8FAP9HVQVHuF9W0R1WVu fwxhws+5+qI7iXBDucJEW3QQCiX3dqqaDDseYIrFaX8grX7m4mTbI4f7RQvb4TT+ZMft 8buiAoyDQJ3qd4jsFWJwSgM8//i5KtcD5xhxaqseHxV2oJR8sTopYLrsNQ+n4YONh55u ildMoK0+mV4IzSA/cf5XESi/GiKPmVDMSTuIPEoRNHropVrDNqd/nO08lPOJa4OPCN7d 5aLA== X-Gm-Message-State: AOAM533tbjEv3EAEHM3btTVef/wxdzt//eGLp9JGSDEkSMMhCIZLUviK ncB62CyYqNHJ7U8lua99T2EvLINn+YZE7VeUVV8kFWVUoaEuVg== X-Received: by 2002:a17:906:b1d5:: with SMTP id bv21mr10388075ejb.346.1633265232688; Sun, 03 Oct 2021 05:47:12 -0700 (PDT) MIME-Version: 1.0 References: In-Reply-To: From: Avi Deitcher Date: Sun, 3 Oct 2021 15:47:01 +0300 Message-ID: Subject: Re: algorithm for half-md4 used in htree directories To: linux-ext4@vger.kernel.org Content-Type: text/plain; charset="UTF-8" Precedence: bulk List-ID: X-Mailing-List: linux-ext4@vger.kernel.org I can narrow down the question further. In my live sample, one of the entries in the tree is for a directory named "dir155". If I run "dx_hash dir155", I get: # debugfs -R "dx_hash dir155" /var/lib/file.img debugfs 1.46.2 (28-Feb-2021) Hash of dir155 is 0x16279534 (minor 0x0) If I look in the tree with "htree_dump", I get: # debugfs -R "htree_dump /testdir" /var/lib/file.img debugfs 1.46.2 (28-Feb-2021) .... Entry #0: Hash 0x00000000, block 1 Reading directory block 1, phys 6459 168 0x00d11d98-b9b6b16b (16) dir155 332 0x009edafe-77de7d72 (16) dir319 That hash for dir155 does not match what dx_hash gave. If I try to take the code from fs/ext4/hash.c and build a small program to calculate the hash, I get: $ ./md4 dir155 MD4: d90278a1 25182ac7 a02e56be c3f30f04 hash: 0x25182ac6 minor: 0xa02e56be Clearly that isn't what is in the tree. What basic am I missing? On Fri, Oct 1, 2021 at 2:49 PM Avi Deitcher wrote: > > Hi, > > I have been trying to understand the algorithm used for the "half-md4" > in htree-structured directories. Going through the code (and trying > not to get into reverse engineering), it looks like it is part of md4 > but not entirely? Yet any subset I take doesn't quite line up with > what I see in an actual sample. > > What is the algorithm it is using to turn an entry of, e.g., "file125" > into the appropriate hash. I did run a live sample, and try to get > some form of correlation between the actual md4 hash (16 bytes) of the > above to the actual entry (4 bytes) shown by debugfs, without much > luck. > > What basic thing am I missing? > > Separately, how does the seed play into it? > > Thanks > Avi -- Avi Deitcher avi@deitcher.net Follow me http://twitter.com/avideitcher Read me http://blog.atomicinc.com