feat(libkernel): sceKernelReadv, Writev, Preadv and Pwritev #806
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/806"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Imported from boykopovar/AnyPS5. Originally posted by adriadam10 on 2026-10-06T05:34:15Z.
What
Adds the libkernel vectored I/O exports
sceKernelReadv,sceKernelWritev,sceKernelPreadvandsceKernelPwritev. Main does not declare them.SceKernelIovecis{ void* base; size_t length; }, laid out like the hoststruct iovecon Linux x86-64 (static_asserts). The array goes straight to the hostreadv/writev/preadv/pwritev. Layout from SharpProspero (KernelFile.cs,SceKernelIovec) and shadPS4 (OrbisKernelIovec).iovcntbelow 0 or aboveUIO_MAXIOV(1024) givesEINVAL(FreeBSDcopyinuio), a null array withiovcnt != 0givesEFAULT, and a negative offset inpreadv/pwritevgivesEINVAL. These checks run before the host call, as main'ssceKernelPreaddoes. Host errors use the same errno →0x8002xxxxmapping assceKernelPread/sceKernelPwrite.preadv/pwritevleave the file offset unchanged.GuestArena::HostWritelikesceKernelPread, andEFAULTis returned if any of them fails to open.file_system.cpp(sceKernelReadv/Writev= posix call +ErrnoToSceKernelError) and prosperhle_file.cpp(k_readv/k_writev/k_preadv/k_pwritev= posix call + SCE error). Both loop per iovec on their own file layer, and neither checksiovcntbefore looping. fpPS4sys_fd.pashascount > IOV_MAX→EINVAL. The host syscall gives the kernel's all-or-nothing semantics, which the per-iovec loops only approximate.readv). They are listed in TechnicalDebt (Functional).Tested
Linux (GCC Release + Clang dev build). New
guest_file_vectortest (registered in ctest, non-Windows likeguest_directory_entries):readvscatters into two buffers and advances the offset, then returns a short count at EOF and 0 past it.preadv/pwritevwork at an offset and leave the file offset unchanged.writevgathers at the current offset, and the file contents are checked.iovcnt == 0calls,EINVALforiovcnt-1/1025 and a negative offset,EFAULTfor a null array, andEBADFafter close.The test fails on
main, where the symbols don't exist and it doesn't link. Negative checks: dropping theIOV_MAXcheck, the null check or the errno mapping, truncatingiovcnt, or ignoring the offset each make the test fail. The explicitiovcnt < 0and negative-offset checks match what the Linux host returns anyway.Checklist
main; no other open PR implements the same functionsNotImplemented_nid_no_patch); silent stubs are listed in TechnicalDebt.mdfiles or images added to the repository (attach them to this PR)Imported from boykopovar/AnyPS5. Originally posted by github-actions[bot] on 2026-10-06T05:47:32Z.
Progress report (
f55a22e→ab98cd7)📈 System libraries: 82.33% (+0.02%, +4 implemented functions)
✅ 4 implemented
sceKernelPreadvsceKernelPwritevsceKernelReadvsceKernelWritev