fix(libkernel): fail lseek on a pipe with ESPIPE on Windows #4672
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/4672"
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 milescoviello on 2026-10-12T18:27:00Z.
What
Fixes #4670. Carries @DavidSamir's fix branch from that issue (
DavidSamir:fix/libkernel-lseek-pipe-windows,32f49a97), keeping the commit and its authorship; it is cherry-picked onto currentmain, with the declaration conflict #4536 left inGuestFilesystem.cppresolved by keeping both.On Windows,
lseekandsceKernelLseeksucceeded on a pipe and returned a position, and withSEEK_ENDthe number of bytes waiting in it, becauseNativeLseekcalls_lseeki64and Windows accepts a position on a pipe handle. FreeBSD'slseek(2)fails withESPIPEwhen the descriptor "is associated with a pipe, socket, or FIFO", and the Linux build already does. WindowsNativeLseeknow makes the same_lseeki64call, so a closed or invalid descriptor fails as before, and then returnsESPIPEwhen the handle's type isFILE_TYPE_PIPE. Linux is unchanged.guest_filesystemchecks both ends of a pipe:lseekfails with errno 29 andsceKernelLseekreturns0x8002001DforSEEK_SET,SEEK_CURandSEEK_END, the bytes written before are read back unchanged, and aftercloselseekfails with errno 9.Tested
main'sOpen.cppthe new checks fail and with the fixguest_filesystempasses 5/5; a 97-operation file probe differs in one line,lseekon a pipe; eleven catalog titles end the same way with both sets of libraries; fullctest973/973. About 0.1 µs is added to each seek by theGetFileTypecall.main9df77462after #4536 (which added a declaration next to this one inGuestFilesystem.cpp; both are kept).guest_filesystem,guest_kernel_fcntl,guest_dupandguest_pollpass, and all 310guest_*tests pass. The new checks also pass withmain'sOpen.cpp, as expected since only the Windows path changes. I could not run Windows myself.tools/check_conventions.py --base upstream/mainpasses.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)🤖 Generated with Claude Code
Imported from boykopovar/AnyPS5. Originally posted by adriadam10 on 2026-10-13T14:56:17Z.
Checked on the PR merged onto current main: scoped build and ctest (147 tests,
guest_filesystemincluded) pass; no conflicts with #4973 or #4992. The change is Windows-only, so Linux is unchanged.ESPIPE(29) matches the guest value used inStdio.cpp. Windows behaviour is covered by the full Build; merging once it is green.