Skip to content

Conversation

@cfriedt
Copy link
Member

@cfriedt cfriedt commented Jul 27, 2024

This is a resubmission of #73978

Implement the remaining functions in the POSIX_DEVICE_IO Option Group.

This Option Group is requried for the PSE51, PSE52, PSE53, and PSE54 subprofiles and likely others.

Doc Preview

Fixes #24966
Fixes #66932
Fixes #66938
Fixes #66946
Fixes #66947
Fixes #66948

@cfriedt cfriedt force-pushed the posix-device-io branch 3 times, most recently from f20bb26 to 49d972d Compare August 15, 2024 11:33
@cfriedt cfriedt force-pushed the posix-device-io branch 7 times, most recently from 2dd7407 to 67d92e9 Compare August 20, 2024 12:25
@cfriedt cfriedt force-pushed the posix-device-io branch 3 times, most recently from 28bacef to a7935e1 Compare August 30, 2024 22:12
@cfriedt cfriedt force-pushed the posix-device-io branch 4 times, most recently from 0223863 to fe801e3 Compare October 6, 2024 02:18
@cfriedt cfriedt marked this pull request as ready for review October 6, 2024 03:59
@zephyrbot zephyrbot added area: LWM2M area: Tracing Tracing area: POSIX POSIX API Library area: Sockets Networking sockets area: Base OS Base OS Library (lib/os) area: Networking labels Oct 6, 2024
@zephyrbot zephyrbot added area: Modem Drivers area: Samples Samples Release Notes To be mentioned in the release notes labels Oct 11, 2024
Only invoke vtable methods read, write, and close if they are
non-NULL.

The close() vtable method is optional, so that should not return
an error if zvfs_close() is called and that method is
unimplemented.

Otherwise, if zvfs_read() or zvfs_write() are called and the
corresponding vtable method is unimplemented, fail setting
errno to EIO.

Signed-off-by: Chris Friedt <[email protected]>
The POSIX_DEVICE_IO Option Group requires a number of c89
functions mainly from stdio.h .

Namely,

clearerr(), fclose(), feof(), ferror(), fflush(), fetc(),
fgets(), fprintf(), fputc(), fputs(), fread(), freopen(),
fscanf(), fwrite(), getc(), getchar(), gets(), perror(),
printf(), putc(), putchar(), puts(), scanf(), setbuf(),
setvbuf(), ungetc(), vfprintf(), vfscanf(), vfprintf(), and
vscanf().

Additionally, symbols stdin, stdout, and stderr should be
provided.

These should be provided by any conformant C library
(not by the POSIX API).

Signed-off-by: Chris Friedt <[email protected]>
Add pread() and pwrite() implementations, which are nearly
identical to read() and write() but differ in that they do not
update the file-descriptor offset and instead read from a
specific file offset.

Signed-off-by: Chris Friedt <[email protected]>
Move the implementation of zsock_poll to zvfs_poll. This allows
other types of file descriptors to also make use of poll()
functionality even when the network subsystem is not enabled.

Additionally, it partially removes a dependency cycle between
posix and networking by moving functionality into a mutual
dependency.

Signed-off-by: Chris Friedt <[email protected]>
Move the implementation of zsock_select() to zvfs_select(). This
allows other types of file descriptors to also make use of
select() functionality even when the network subsystem is not
enabled.

Additionally, it partially removes a dependency cycle between
posix and networking by moving functionality into a mutual
dependency.

Signed-off-by: Chris Friedt <[email protected]>
Implement pselect() as it's required by POSIX_DEVICE_IO

Signed-off-by: Chris Friedt <[email protected]>
Implement fdopen(), as required by the POSIX_DEVICE_IO Option
Group.

Signed-off-by: Chris Friedt <[email protected]>
Implement fileno() as required by the POSIX_DEVICE_IO Option
Group.

Signed-off-by: Chris Friedt <[email protected]>
Previously, we had only used the flags field and ignored mode
with the open() function.

Signed-off-by: Chris Friedt <[email protected]>
Mark the POSIX_DEVICE_IO Option Group as commplete. This Option
Group is required for PSE51, PSE52, PSE53, PSE54, and most of
the interesting applications involving file descriptors and
sockets.

Signed-off-by: Chris Friedt <[email protected]>
Several help prompts for non-user-selectable Kconfig options
included the phrase "select 'y' here", which does not make
any sense in this situation.

Adjust the help sections to use more appropriate language.

Signed-off-by: Chris Friedt <[email protected]>
Currently Zephyr depends on POSIX, which presents a
dependency cycle.

Newlib does not seem to like this dependency cycle so it
requires that we re-declare off_t and ssize_t.

We should really stop using off_t and ssize_t below the
POSIX API line in Zephyr.

Signed-off-by: Chris Friedt <[email protected]>
@cfriedt
Copy link
Member Author

cfriedt commented Oct 11, 2024

  • deprecated CONFIG_NET_SOCKETS_POLL_MAX in favour of CONFIG_ZVFS_POLL_MAX
  • rebased on main

CONFIG_ZVFS_POLL_MAX is now used to control the maximum number of poll()
entires. Thereby, CONFIG_NET_SOCKETS_POLL_MAX is redundant and shall
be deprecated.

Modify the defaults for NET_SOCKETS_POLL_MAX and ZVS_POLL_MAX so that
the deprecation actually makes sense instead of symbol removal. In case
the application still sets the old config, it will modify the
ZVS_POLL_MAX default.

Signed-off-by: Robert Lubos <[email protected]>
Signed-off-by: Chris Friedt <[email protected]>
@cfriedt
Copy link
Member Author

cfriedt commented Oct 11, 2024

  • fixed duplicate entry of CONFIG_ZVFS_POLL_MAX by adding CONFIG_ZVFS_OPEN_MAX

@cfriedt cfriedt requested review from a user, rlubos and ycsin October 11, 2024 23:22
@henrikbrixandersen henrikbrixandersen merged commit c480375 into zephyrproject-rtos:main Oct 14, 2024
27 checks passed
@cfriedt cfriedt deleted the posix-device-io branch November 21, 2024 00:41
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area: Base OS Base OS Library (lib/os) area: LWM2M area: Modem Drivers area: Networking area: POSIX POSIX API Library area: Samples Samples area: Sockets Networking sockets area: Tracing Tracing Release Notes To be mentioned in the release notes

Projects

None yet

6 participants