jingfei195887 opened a new pull request, #4055:
URL: https://github.com/apache/nuttx-apps/pull/4055

   ## Summary
   
   - **fsutils/mkgpt: fix GPT header CRC check on 64-bit targets.**
     The header and entries CRC were computed with `~0l` as the seed and final
     XOR. `long` is 64-bit on LP64 targets, so `crc32part(...) ^ ~0l` becomes a
     64-bit value. `verify_gpt_pratition()` compares the 32-bit `orgcrc`
     against it, and the comparison always fails: `mkgpt read` reports
     `GPT: Header CRC is wrong` for every table, including one `mkgpt write`
     just created. Use `~0u` so the CRC is computed and compared in 32 bits.
   
   ## Impact
   
   - New feature / API change: NO.
   - Behavior: `mkgpt read` now accepts valid tables on 64-bit targets. On
     32-bit targets `~0l` and `~0u` are the same value, so nothing changes.
   - Build, hardware, documentation, security, compatibility: NO.
   
   ## Testing
   
   Host: Ubuntu x86_64, gcc (Ubuntu 13.1.0-8ubuntu1~22.04) 13.1.0, nuttx
   master a72faaf0fa, nuttx-apps master 41840d466f.
   
   `sim:nsh` (x86_64, LP64) with `CONFIG_FSUTILS_MKGPT` and `CONFIG_FS_TMPFS`:
   
   ```
   truncate -s 131072 /tmpx/disk
   mkgpt write /tmpx/disk a:16k b:16k
   mkgpt read /tmpx/disk
   ```
   
   Testing logs before change (`mkgpt read`):
   
   ```
   GPT: Header CRC is wrong
   Dump GPT partition: ...
   ```
   
   Testing logs after change (`mkgpt read`):
   
   ```
   ptn  start block   end block     name
   ---- ------------- ------------- --------------------
   #001            34            65 a
   #002            66            97 b
   ```
   
   - `./tools/checkpatch.sh -g master..HEAD`: all checks pass.
   - `sim:nsh` Make and CMake builds pass with no new warnings; `ostest` exits
     with status 0.
   - Verified on sim only.
   
   ## PR verification Self-Check
   
   * [x] This PR introduces only one functional change.
   * [x] I have updated all required description fields above.
   * [x] My PR adheres to Contributing Guidelines and Documentation (git commit 
title and message, coding standard, etc).
   * [ ] My PR is still work in progress (not ready for review).
   * [x] My PR is ready for review and can be safely merged into a codebase.
   


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to