jingfei195887 opened a new pull request, #21770:
URL: https://github.com/apache/nuttx/pull/21770
## Summary
- **fs/shm: round the shm buffer up to a page for mmap().**
Without an MMU, `shmfs_mmap()` hands out the object buffer directly and
rejects a mapping longer than the object, because it would run into the
neighbouring heap memory. That also rejects the common POSIX sequence
`ftruncate(fd, size)` followed by `mmap()` of a whole page
(`sysconf(_SC_PAGESIZE)`) whenever `size` is not a page multiple:
`mmap()` fails with `EINVAL`. The buffer of a FLAT or PROTECTED build is
now allocated in whole pages, and a mapping up to the page-rounded size is
accepted.
- **fs/shm: fix nxstyle error.** A pre-existing missing blank line in
`shmfs_free_object()` that `checkpatch.sh` reports on the touched file.
## Impact
FLAT and PROTECTED builds with `CONFIG_FS_SHMFS`: an shm object costs up to
one page minus one byte of extra heap, and page-sized mappings of small
objects now succeed. A mapping beyond the rounded size is still rejected.
KERNEL builds already allocate whole pages and are unchanged.
## Testing
Host: Ubuntu x86_64, gcc (Ubuntu 13.1.0-8ubuntu1~22.04) 13.1.0, master
dc9481383e, `sim:nsh` with
`CONFIG_FS_SHMFS`. A test program creates a 100-byte shm object with
`shm_open()` + `ftruncate()` and maps it:
| step | master | this PR |
|---|---|---|
| `mmap(pagesize)` (pagesize = 256 on sim) | EINVAL | ok |
| `mmap(pagesize + 1)` | EINVAL | EINVAL |
- `./tools/checkpatch.sh -g master..HEAD`: all checks pass.
- Make and CMake builds pass with no new warnings; `ostest` exits with
status 0.
--
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]