fix(libkernel): sync read-only and directory descriptors on Windows #3578
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/3578"
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 LeandroLP23 on 2026-10-11T13:38:41Z.
Carrying @DavidSamir's fix for #3317 (
DavidSamir:fix/libkernel-fsync-read-only-windows,d9bafbde; they can't open PRs yet). The change is theirs, cherry-picked onto currentmainwithout conflicts, authorship kept.What
On Windows,
fsync,fdatasync,sceKernelFsyncandsceKernelFdatasyncfail withEBADFon a descriptor opened read-only and on a directory descriptor, because_commitneeds a writable handle and a directory descriptor is a placeholder onNUL. FreeBSD and the Linux build return 0 for both. A new Windows-onlyNativeSync, which both functions call, does the following:FILE_FLAG_BACKUP_SEMANTICS;_commitfirst, then flushes an open disk file through a write handle fromReOpenFile;FlushPathalready does forsceKernelSync;EBADFfor a closed descriptor or one that is not a disk file.guest_filesystemgains the directory, read-only descriptor and read-only file cases. Details are in #3317.Tested
ctest770/770, title runs unchanged, andguest_filesystem3/3 on WSL2 Ubuntu 24.04. All in #3317.maina11c8f7f7, with #3518's one-line test change applied locally soguest_filesystemgets past line 286.guest_filesystempasses 3/3. Withmain'sStdio.cpp, it fails at the first new check,sceKernelFsyncon the directory descriptor (guest errno 9). Outside of the known failures listed below,ctest -E agc_andctest -R agc_matchmain.Fork CI: https://github.com/LeandroLP23/AnyPS5/actions/runs/38142442243
main:guest_filesystemat line 286 (fixed by #3518),guest_kernel_sysonsymlink(fixed by #3510), andwindows_exceptions(#3411).#ifdef _WIN32, so it isn't built on Linux. The failures aremain'sagc_driver_image_plane_address_on_line_implicit_lodandguest_kernel_stack_protect, the intermittentagc_driver_depth_fast_clear_submitsegfault, andagc_driver_emulated_color_compare.Fixes #3317
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-11T15:28:08Z.
Other open pull requests touch the same code. Merging one will break the other, or both implement the same thing. If this one builds on them, list them in Depends on.
main)core/libs/prx/libkernel/File/src/Stdio.cppL720Imported from boykopovar/AnyPS5. Originally posted by adriadam10 on 2026-10-11T21:37:21Z.
Checked the diff and the build:
NativeSynchandles directory descriptors (backup-semantics write handle), read-only descriptors (_commit, thenReOpenFile) and returns 0 onERROR_ACCESS_DENIED, likeFlushPath; closed or non-disk descriptors still giveEBADF, and errno is restored after the failed_commit.guest_filesystemand the 112 libkernel/libs tests pass on Linux, and DavidSamir's Windows run in #3317 covers the Windows path. The remainingguest_filesystemWindows failure at line 286 is independent (#3518). Merging.