jingfei195887 opened a new pull request, #4056:
URL: https://github.com/apache/nuttx-apps/pull/4056
## Summary
- **fs_gpt:fix alternate GPT also invalid issue 2/2.**
`mkgpt write` builds the secondary GPT by reusing the primary header and
only swapping `header_lba` and `backup_lba`. `entries_lba` stays at 2, so
the backup header at the end of the disk points at the primary partition
entries instead of its own copy at `sz - 33`. A reader that falls back to
the backup header (for example NuttX `fs/partition/fs_gpt.c` when the
primary header is damaged) then reads the wrong entries. Set
`entries_lba` to `sz - 33` for the secondary header.
## Impact
- New feature / API change: NO.
- Behavior: only the secondary GPT header written by `mkgpt write` 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` with `CONFIG_FSUTILS_MKGPT` and `CONFIG_FS_TMPFS`. A 256-sector
image is written with `mkgpt`, then a small test program reads the backup
header in the last sector and prints its `entries_lba` (offset 72) next to
the expected `sz - 33`:
```
truncate -s 131072 /tmpx/disk
mkgpt write /tmpx/disk a:16k b:16k
```
Testing logs before change:
```
gptbak: sig=EFI PART entries_lba=2 expected=223
```
Testing logs after change:
```
gptbak: sig=EFI PART entries_lba=223 expected=223
```
- `./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]