Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

os: add zephyr virtual filesystem (zvfs) api #72894

Open
cfriedt opened this issue May 16, 2024 · 0 comments
Open

os: add zephyr virtual filesystem (zvfs) api #72894

cfriedt opened this issue May 16, 2024 · 0 comments
Assignees
Labels
area: File System area: Networking area: POSIX POSIX API Library area: Sockets Networking sockets Enhancement Changes/Updates/Additions to existing features
Milestone

Comments

@cfriedt
Copy link
Member

cfriedt commented May 16, 2024

Is your enhancement proposal related to a problem? Please describe.

As part of the POSIX Roadmap for LTSv3, we should implement a common abstraction for FILE * and int file descriptors that can be used throughout Zephyr applications.

Describe the solution you'd like

The abstraction serves to support

  • ISO C (FILE * operations)
  • POSIX (FILE * operations and int operations on files, devices, sockets, etc)

and should call into existing Zephyr subsystems such as Networking and Filesystem, which are part of Zephyr.

Other APIs such as POSIX, and C should call into ZVFS and not the opposite in order to eliminate API-level dependency cycles and to provide a more fully-featured and standard-conformant API.

Describe alternatives you've considered

Additional context

Details to be worked-out:

  • struct fd_entry could be typedefed as typedef struct zvfs_entry FILE
  • fdtable[] could server as a LUT mapping int to FILE *
  • Zephyr needs to define a struct zvfs_mode, which could be typedefed to mode_t
  • struct fd_entry requires a struct zvfs_mode to differentiate between block, char special files, links, directories, sockets, pipes, etc
  • All of those identifiers should also have a unique ZVFS_ mode prefix
  • we need to account for most FILE * or int file descriptor operations (i.e. duplicate all functions, macros enabled with POSIX_DEVICE_IO, POSIX_FILE_SYSTEM, POSIX_NETWORKING, POSIX_MAPPED_FILES, POSIX_FD_MGMT) but prefix them with zvfs_.
  • all of the other functionality will need to be "squeezed in" to struct fd_op_vtable. However, keep in mind, that Zephyr overloads ioctl() to achieve a lot of optional POSIX file descriptor functionality. E.g. lseek() -> ZFD_IOCTL_FSYNC.
  • refer to e.g. /usr/include/linux/sockios.h in Linux
  • Functionality may need to move down the stack (into the Zephyr kernel or middleware layers) from net, fs, posix. Do this very sparingly.
  • for polll, select, etc, we will want to rename the zsock equivalent sets and structures (struct zvfs_fdset -> fdset, struct zsock_poll -> struct zvfs_poll, FD_ISSET() -> ZVFS_FD_ISSET()).
@cfriedt cfriedt added Enhancement Changes/Updates/Additions to existing features area: Networking area: File System area: POSIX POSIX API Library area: Sockets Networking sockets labels May 16, 2024
@cfriedt cfriedt added this to the v3.7.0 milestone May 16, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area: File System area: Networking area: POSIX POSIX API Library area: Sockets Networking sockets Enhancement Changes/Updates/Additions to existing features
Projects
None yet
Development

No branches or pull requests

2 participants