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

fdtable: fix longstanding layering violations #75348

Open
wants to merge 3 commits into
base: main
Choose a base branch
from

Commits on Jul 12, 2024

  1. kernel: types: add k_off_t and k_ssize_t types

    Define k_off_t to have native support for measuring file offsets
    within any kind of file that is supportable in Zephyr.
    
    CONFIG_OFFSET_64BIT is added to allow 32-bit users to force
    64-bit offsets, when trading space and speed for flexibility
    makes sense for the application.
    
    Define k_ssize_t to have native support for reporting file I/O
    sizes along with negative error codes.
    
    Signed-off-by: Chris Friedt <cfriedt@tenstorrent.com>
    Chris Friedt committed Jul 12, 2024
    Configuration menu
    Copy the full SHA
    4e5c2b9 View commit details
    Browse the repository at this point in the history
  2. manifest: optional: update sof to use k_ssize_t

    Update sof to use k_ssize_t instead of the POSIX ssize_t, thus
    avoiding layering violations in core parts of Zephyr.
    
    Signed-off-by: Chris Friedt <cfriedt@tenstorrent.com>
    Chris Friedt committed Jul 12, 2024
    Configuration menu
    Copy the full SHA
    1dfe21a View commit details
    Browse the repository at this point in the history
  3. fdtable: remove inappropriate use of POSIX off_t and ssize_t

    A shortcut was taken many years ago by "cherry-picking" the
    POSIX off_t and ssize_t types for use throughout Zephyr.
    
    Additionally, the POSIX header fcntl.h, as well as constants
    defined in that header, were being used inappropriately
    throughout Zephyr.
    
    Doing so created a dependency cycle: below POSIX's position
    in the stack, code depended on POSIX; above POSIX's position
    in the stack, code depends on the lower parts.
    
    Such dependency cycles usually result in fragility and
    instability of the software stack.
    
    Use the newly defined k_off_t and k_ssize_t types throughout
    Zephyr's stack, where off_t and ssize_t were previously used
    inappropriately.
    
    Additionally, use ZVFS-prefixed constants instead of their
    POSIX counterparts.
    
    Additionally, where appropriate, ensure the POSIX fcntl.h
    header is prefixed with <zephyr/posix/fcntl.h>.
    
    We effectively create a mutual dependency to resolve the
    cyclic dependency, as described in GitHub issue zephyrproject-rtos#51211.
    
    For clarification, it is inappropriate to use POSIX types or
    functions within the kernel, core OS, OS services, or really
    anywhere that is not equal to or above POSIX's position in the
    software stack.
    
    In other words, if a library uses POSIX, Zephyr's POSIX
    implementation cannot depend on that library.
    
    Similarly, if a system service uses POSIX, Zephyr's POSIX
    implementation cannot depend on that system service.
    
    Signed-off-by: Chris Friedt <cfriedt@tenstorrent.com>
    Chris Friedt committed Jul 12, 2024
    Configuration menu
    Copy the full SHA
    641a504 View commit details
    Browse the repository at this point in the history