Skip to content

Conversation

fkokosinski
Copy link
Member

@fkokosinski fkokosinski commented Sep 19, 2025

Follow-up to the work in #83386 and #90916.

cfriedt and others added 3 commits September 12, 2025 17:03
Previously, there was an implicit assumption that Zephyr's
internal struct fd_entry * was synonymous with FILE * from
the C library.

This is generally not the case and aliasing these two
distinct types was preventing a fair bit of functionality
from Just Working - namely stdio function calls like
fgets() and fopen(). The problem count be seen directly
when trying to use a function like zvfs_fdopen().

Instead of aliasing the two types, require that all Zephyr
C libraries provide

1. FILE *z_libc_file_alloc(int fd, const char *mode)
   Allocate and populate the required fields of a FILE object

2. int z_libc_file_get_fd(FILE *fp)
   Convert a FILE* object to an integer file descriptor.

For Picolibc and Newlib-based C libraries, these functions
set and get the integer file descriptor from a field of the
internal FILE object representation.

For the minimal C library, these functions convert between
array index and struct fd_entry pointers.

Signed-off-by: Chris Friedt <cfriedt@tenstorrent.com>
Add a testsuite for the POSIX_DEVICE_IO Option Group.

Signed-off-by: Chris Friedt <cfriedt@tenstorrent.com>
Get testsuite pseudo-working. Zephyr does not yet support doing
much with STDIN_FILENO, STDOUT_FILENO, and basically does not
support STDERR_FILENO at all.

Signed-off-by: Chris Friedt <cfriedt@tenstorrent.com>
Co-authored-by: Jakub Klimczak <jklimczak@internships.antmicro.com>
Jakub Klimczak added 5 commits September 19, 2025 13:48
This commit adds a common ZVFS-based implementation of fclose().

Signed-off-by: Jakub Klimczak <jklimczak@internships.antmicro.com>
Signed-off-by: Filip Kokosinski <fkokosinski@antmicro.com>
Return a proper FILE pointer for standard streams.

Signed-off-by: Jakub Klimczak <jklimczak@internships.antmicro.com>
Signed-off-by: Filip Kokosinski <fkokosinski@antmicro.com>
This commit fixes stdin handling when picolibc is used.

Signed-off-by: Jakub Klimczak <jklimczak@internships.antmicro.com>
Signed-off-by: Filip Kokosinski <fkokosinski@antmicro.com>
Add a test to the POSIX filesystem API suite that checks whether fdopen()
returns a valid value.

Signed-off-by: Jakub Klimczak <jklimczak@internships.antmicro.com>
Signed-off-by: Filip Kokosinski <fkokosinski@antmicro.com>
Expand the test to cover every libc that Zephyr currently integrates.

Signed-off-by: Jakub Klimczak <jklimczak@internships.antmicro.com>
Signed-off-by: Filip Kokosinski <fkokosinski@antmicro.com>
Copy link

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants