Nevermind - someone figured it out: https://blog.cugu.eu/post/apfs/#checksum

My code was missing the extra (optional) "check bytes" after the sums
calculation.

I've updated my code accordingly:
http://files.tempel.org/tmp/apfs-fletcher-test.zip

It now also contains versions for fletcher-16 and -32, as well as an
optimized form that avoids the use of the modulo operator (though, with
modern desktop CPUs, I wonder if that even still makes a difference or if
the MOD instruction is just as fast as an AND and a SHIFT instruction
together).

(As Quinn says) Enjoy,
  Thomas



On Sun, Apr 30, 2017 at 1:47 AM, Toby Thain <t...@telegraphics.com.au>
wrote:

> On 2017-04-29 7:42 PM, Thomas Tempelmann wrote:
>
>> On Sun, Apr 30, 2017 at 1:37 AM, Toby Thain <t...@telegraphics.com.au
>> <mailto:t...@telegraphics.com.au>> wrote:
>>
>>     Seems you have % instead of & ? And watch out for sign extension on
>>     those literal 0xFFFFFFFF's. You probably want an unsigned and long
>>     long suffix on them.
>>
>>
>> Nope, both are correct, at least for standard fletcher algorithm. It's
>> always modulo (%) MAXINT-1.
>>
>
> Ah, OK. Thanks for clarifying!
>
>
> > And 0xFFFFFFFF's gets properly expanded to
>
>> unsigned 64 bit, as it should. I double checked using uint64_t variable
>> all the way, and it didn't change the outcome.
>>
>> --
>> Thomas Tempelmann, http://www.tempel.org/
>> Follow me on Twitter: https://twitter.com/tempelorg
>> Read my programming blog: http://blog.tempel.org/
>>
>
>


-- 
Thomas Tempelmann, http://www.tempel.org/
Follow me on Twitter: https://twitter.com/tempelorg
Read my programming blog: http://blog.tempel.org/
 _______________________________________________
Do not post admin requests to the list. They will be ignored.
Filesystem-dev mailing list      (Filesystem-dev@lists.apple.com)
Help/Unsubscribe/Update your Subscription:
https://lists.apple.com/mailman/options/filesystem-dev/archive%40mail-archive.com

This email sent to arch...@mail-archive.com

Reply via email to