Skip to content

[SUBISSUE #1] Implement Vectored and Positional I/O (readv, pread64, pwrite64, preadv, pwritev, preadv2, pwritev2) #289

Todo

Description

@marcobuschini

Parent Issue / Epic

#281 (Epic #265)

Prerequisite Sub-Issue

None

Atomic Deliverable & Implementation Details

Implement Linux AArch64 positional and scatter-gather I/O syscalls:

  • kernel/fs/Vfs.hpp & kernel/fs/Vfs.cpp: Add offset-explicit read/write helpers (vfs_pread / vfs_pwrite) that operate on a caller-supplied offset without mutating File::m_offset, rejecting pipes/sockets/non-seekable streams with kEspipe.
  • kernel/syscalls/FileSyscalls.cpp, SyscallInternal.hpp, SyscallDispatcher.cpp:
    • Implement sys_readv (65), sys_pread64 (67), sys_pwrite64 (68), sys_preadv (69), sys_pwritev (70), sys_preadv2 (286), and sys_pwritev2 (287).
    • Support RWF_NOWAIT / RWF_DSYNC / RWF_SYNC / RWF_APPEND flag validation (returning -EOPNOTSUPP on unknown preadv2/pwritev2 flags, and supporting offset == -1 in preadv2/pwritev2 to use current file offset).
  • tests/host/: Add Snitch ASan/UBSan tests covering partial reads/writes, UIO_MAXIOV validation, negative offset -EINVAL, pipe -ESPIPE, and File::m_offset invariance.

Out of scope: statx/statfs/symlinkat/linkat/mknodat ([SUBISSUE #2]), sendfile/splice/flock ([SUBISSUE #3]).

Acceptance Criteria & Edge Cases

  • pread64/pwrite64/preadv/pwritev never modify the open file description's current lseek offset
  • Negative offsets return -EINVAL (except offset == -1 in preadv2/pwritev2 which falls back to current file offset)
  • Pipes, AF_UNIX sockets, eventfd, and timerfd return -ESPIPE for positional I/O; readv works on pipes, sockets, and regular files
  • Invalid iov pointers or iovcnt > UIO_MAXIOV return -EFAULT / -EINVAL with zero kernel leaks
  • make format && make clean-tests && make -j"$(nproc)" all && make -j"$(nproc)" quality passes with zero warnings

Metadata

Metadata

Assignees

Labels

subissue

Type

No type

Projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions