So I'm making some kind of research on EXT4 checksums.
I found this page and tried to calculate checksum by myself. I've started with Superblock since it is sounds pretty simple: "The entire superblock up to the checksum field".
But it does not work: I can't get the same result as the superblock.
For this task I wrote superblock checksum calculator on Python. You may look at my program on GitHub. I tried a lot of things.
First of all, I tried to read the whole superblock up to checksum (1020 bytes) and put it in CRC32C (algorithm is independent library from pip). Although this was written in wiki, this does not work.
Then I simply reversed the whole superblock. It has not much sense, I think. And I failed again.
After this, I tried more complicated way. I tried to reverse all fields of the superblock separately. It gives another result as you can see:
Raw data: 1F DC 5E 4A 2-byte fields reversed: DC 1F 4A 5E Full data reverse: 4A 5E DC 1F And once again, I failed. Here all interpretations of phrase "The entire superblock up to the checksum field" ended.
I tried to add zero-filled checksum field to all algorithms and tried to reverse only little-endian fields (seemed like a good idea actually), without reversing char and u8 fields.
But there is no chance to get the same checksum as the original superblock.
My script makes output like this for superblock:
00c0390000cae600198a0b00c6aca40039a835000000000002000000020000000080000000800000002000001ee68c5c17e68c5c2000ffff53ef01000100000055936d5c000000000000000001000000000000000b000000000100003c000000c60200006b040000d6eb1a5613a44a8a91b66dbfe7cbbca9000000000000000000000000000000002f0061726765740000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000004000000000000000000000000000000000800000000000000f00c3000ca7d5363a49944fd9db16c0f95cfab15010140000c0000000000000055936d5c0af3020004000000000000000000000000800000008070000080000000800000000071000000000000000000000000000000000000000000000000000000000000000010000000000000000000000000200020000100000000000000000000000000000000000000040100000d63df0f00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000fe3731ed
ORIGINAL CHECKSUM (not calculated!): 0xfe3731ed
CALCULATED WHOLE SUPERBLOCK: 0xffffffffL - this always happens, some overflow error maybe.
CALCULATED SUPERBLOCK WITHOUT CHECKSUM: 0x12cec801L
CALCULATED FULLY-REVERSED SUPERBLOCK WITHOUT CHECKSUM: 0x7fe225e5L
CALCULATED FIELDS-REVERSED SUPERBLOCK: 0x8cce5045L
I can't find any documentation, and ext4 source code files are poorly commented (and really complicated), I can't make any sense of them.