Skip to content

Conversation

cfriedt
Copy link
Member

@cfriedt cfriedt commented May 31, 2025

No description provided.

@cfriedt cfriedt force-pushed the zvfs-improve-libc-file-and-int-fd-abstraction-v2 branch from 529fc4d to 7f0c674 Compare May 31, 2025 21:49
Copy link

Copy link

This pull request has been marked as stale because it has been open (more than) 60 days with no activity. Remove the stale label or add a comment saying that you would like to have the label removed otherwise this pull request will automatically be closed in 14 days. Note, that you can always re-open a closed pull request at any time.

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 <[email protected]>
Add a testsuite for the POSIX_DEVICE_IO Option Group.

Signed-off-by: Chris Friedt <[email protected]>
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 <[email protected]>
@cfriedt cfriedt force-pushed the zvfs-improve-libc-file-and-int-fd-abstraction-v2 branch from 7f0c674 to ed23b5c Compare August 28, 2025 23:16
Copy link

@cfriedt
Copy link
Member Author

cfriedt commented Oct 5, 2025

Closing in favour of #96278

@cfriedt cfriedt closed this Oct 5, 2025
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.

1 participant