Fix 64-bit superblock updates and add stress test#2
Conversation
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
| def _build_crc32c_table() -> list[int]: | ||
| poly = 0x1EDC6F41 | ||
| table = [] | ||
| for i in range(256): | ||
| crc = i | ||
| for _ in range(8): | ||
| if crc & 1: | ||
| crc = (crc >> 1) ^ poly | ||
| else: | ||
| crc >>= 1 | ||
| crc &= 0xFFFFFFFF | ||
| table.append(crc) | ||
| return table | ||
|
|
||
|
|
||
| CRC32C_TABLE = _build_crc32c_table() | ||
|
|
||
|
|
||
| def crc32c(data: bytes, crc: int = 0xFFFFFFFF) -> int: | ||
| """Compute the CRC32C checksum using the kernel's convention.""" | ||
| for b in data: | ||
| crc = CRC32C_TABLE[(crc ^ b) & 0xFF] ^ (crc >> 8) | ||
| crc &= 0xFFFFFFFF |
There was a problem hiding this comment.
Generate CRC32C table with wrong polynomial orientation
The stress test builds its CRC table by shifting the CRC right and XORing with 0x1EDC6F41. That polynomial value is the non‑reflected CRC32C polynomial, so using it with a right‑shift algorithm produces an incorrect checksum. As written the script always writes an invalid superblock checksum even after repairing the block counters, causing e2fsck to continue failing. Use the reflected constant 0x82F63B78 (or a standard CRC32C implementation) when generating the table.
Useful? React with 👍 / 👎.
Summary
EXT2_VCBso the superblock high words are always restored before savingTesting
https://chatgpt.com/codex/tasks/task_e_68fcc3dd26608333972ecf9f81e02f82