tools/nolibc: fix fopen() errno and "rb+" modes
Get series with b4
b4 am [email protected]Versions newest first
- v1 Latest3 patches 4 repliesIn review
Patches in v1 No applies recorded yet
| # | Subject and files | Size | Replies | Applied |
|---|---|---|---|---|
| 1/3 | tools/nolibc: fix fopen() errno when open() failstools/ | +3 | 2 replies | |
| 2/3 | tools/nolibc: fix fopen() with the "rb+", "wb+" and "ab+" modestools/ | +1 | 1 reply | |
| 3/3 | selftests/nolibc: test fopen() errors and update modestools/ | +24 | 1 reply |
Reviews trailers per patch
1 of 3 patches has a Reviewed-by or Acked-by.
| Patch | Thomas Weißschuh |
|---|---|
| 1/3 | R-b |
| 2/3 | |
| 3/3 |
Trailers given in replies are filled; those carried in the patches from earlier versions are outlined with dashes.
Cover letter [PATCH 0/3] tools/nolibc: fix fopen() errno and "rb+" modes
fopen() has two bugs:
- When open() fails, fopen() overwrites its errno with EBADF, so a missing file is reported as EBADF instead of ENOENT.
- "rb+", "wb+" and "ab+" are not recognised as update modes, so the stream is opened read-only or write-only.
Patches 1 and 2 fix them. Patch 3 adds nolibc-test cases for both.
Tested on top of nolibc/for-next 700ce4da6f6f, on x86_64 (GCC and clang) and i386, and on arm, arm64 and sparc64 under qemu-user:
- nolibc-test, all tests: no failures with the series. The only difference from before is the three new tests, which pass. They also pass against glibc (make libc-test).
- Without patches 1 and 2, all three new tests fail on every build.
- On x86_64, a separate program opening a file with each of the twelve C mode strings now gets the same access mode from nolibc as from glibc, and the same errno for ENOENT and EACCES failures.
An LLM was used to help with this series.
Danish Khateeb (3):
tools/nolibc: fix fopen() errno when open() fails tools/nolibc: fix fopen() with the "rb+", "wb+" and "ab+" modes selftests/nolibc: test fopen() errors and update modes
tools/include/nolibc/stdio.h | 5 +++- tools/testing/selftests/nolibc/nolibc-test.c | 24 ++++++++++++++++++++ 2 files changed, 28 insertions(+), 1 deletion(-)
base-commit: 700ce4da6f6f172435349b687d2d916e791c6330
Signature · 1 line
2.56.0