Commit Graph
279 Commits
Author SHA1 Message Date
Adrià 79d7d26b6d Merge pull request #6484 from Ondra97/codex/team-20261015-worker-2
fix(libkernel): share guest rename semantics with sceKernelRename
2026-10-19 03:35:57 +02:00
Ondra97 a64d038154 fix(libs): flush pending GPU results before file writes 2026-10-19 00:53:25 +02:00
Adrià 38a848a1b7 Merge pull request #6287 from ahmad3a4/fix/libc-append-streams-windows
fix(libc): append stream writes atomically on Windows
2026-10-19 00:16:59 +02:00
Ondra97 f7aeed2eb0 fix(libkernel): serialize Windows ftruncate with file transfers 2026-10-18 23:36:25 +02:00
Adrià ccf0f58785 Merge pull request #6228 from Ondra97/codex/fix-windows-directory-renames
fix(libkernel): preserve directory identity across Windows renames
2026-10-18 22:20:22 +02:00
Dean cd20b7f6f8 Merge pull request #6132 from MarcZX10/codex/open-resolved-path-diagnostics
fix(libkernel): log resolved paths for failed opens
2026-10-19 07:22:43 +13:00
Adrià bb86ca38b8 Merge pull request #5992 from Get-fix/ps4/libkernel-underscore-io
fix(libkernel): export _readv, _writev, _fcntl, _fstat, __sys_socketex
2026-10-18 16:45:19 +02:00
Ahmad 0b24f92a6c fix(libc): append stream writes atomically on Windows
fopen and freopen in an append mode gave the C runtime a descriptor with
_O_APPEND, which seeks to the end of the file and then writes. Streams on
separate descriptors overwrote each other's data. FreeBSD opens these
streams with O_APPEND, so every flush lands at the end of the file.

Open append streams with FILE_APPEND_DATA but without FILE_WRITE_DATA,
so Windows writes each flush at the end of the file. ftruncate and
flock reopen the file to get the access such a handle lacks.
2026-10-18 14:49:55 +03:00
Maz bd0caa451b Merge upstream/main into fix/windows-junction
Keep the drive-absolute junction note and the updated setitimer debt from main.
2026-10-18 12:57:10 +04:00
Maz 7212dae71a fix(libkernel): reject Windows volume mount points in junction reads
A mounted folder uses the junction reparse tag and would otherwise be returned as a relative Volume GUID path. Only a drive path is reported, through the absolute-link text helpers.
2026-10-18 12:53:48 +04:00
Maz e964264d23 Merge branch fix/windows-absolute-symlink into fix/windows-junction
Keep the junction reader and try the absolute symbolic-link reader first.
2026-10-18 12:50:08 +04:00
Dean Galvin 67e7043332 Merge main into feat/poll-files 2026-10-18 16:04:36 +13:00
Dean 7cdfbd2e9d Merge pull request #7152 from Bonjourcestmatt/fix/getdents-not-directory
fix(libkernel): report EINVAL for getdirentries on a non-directory
2026-10-18 14:50:26 +13:00
Ondra97 739e451332 fix(libkernel): preserve directory identity across Windows renames 2026-10-17 23:17:39 +02:00
Dean af7972ce91 Merge pull request #7229 from nicolasfalesy/feat/libkernel-export-nmount
feat(libkernel): export nmount
2026-10-18 10:10:15 +13:00
Maz 01f3938fe1 fix(libkernel): report Windows directory junctions from lstat and readlink 2026-10-18 01:05:40 +04:00
Dean f3f622f65f Merge pull request #7196 from MarcZX100/codex/stat-long-path-7195
fix(libkernel): stat files under long Windows paths
2026-10-18 10:01:49 +13:00
Dean 084bd39a08 Merge pull request #7133 from pushkarreddyy/fix/libkernel-write-throttling-null-efault
fix(libkernel): return EFAULT from sceKernelWriteThrottlingStatus for a null status
2026-10-18 09:45:24 +13:00
Dean ee14990418 Merge pull request #7073 from AlexOfTheForest/fix/getlk-unlock
fix(libkernel): answer F_GETLK with F_UNLCK on Linux and macOS
2026-10-18 09:39:47 +13:00
Nicolas FalesyandClaude Opus 5.5 1ffffc318d feat(libkernel): export nmount
Prospero Themes (PPSA90210) imports nmount (3YnXspQNyw8) from libkernel
and fails to load without it:
"./app.elf: symbol lookup error: ./app.elf: undefined symbol: 3YnXspQNyw8".

Mounting file systems is not supported, so it throws if called, like
execvp does for executable replacement. The title opens its theme
library without calling it.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01Sovthwyu4H63RMbRVha2Sy
2026-10-17 14:08:53 -04:00
MarcZX100 28eaa5bdad fix(libkernel): preserve extended paths in stat metadata 2026-10-17 16:15:54 +00:00
MarcZX100 ee5ff02e7a fix(libkernel): stat files under long Windows paths 2026-10-17 16:15:54 +00:00
Ondra97 de2e12148e fix(libkernel): share guest rename semantics with sceKernelRename 2026-10-17 18:08:19 +02:00
mattogepetoandClaude Opus 5.5 d915e5835a fix(libkernel): check for a directory with fstat before getdents on Linux
The Linux path mapped ENOTDIR from getdents64 to EINVAL, but a pipe or FIFO
still failed with ESPIPE from the lseek that reads the base offset first.
FreeBSD 11.4's kern_getdirentries returns EINVAL for any descriptor that is
not a directory vnode, pipes included, and EBADF for one that is not open.

Check the descriptor with fstat before the lseek: EBADF and other host
errors are passed through, and anything that is not a directory returns
EINVAL. The getdents64 error line is unchanged again, and the technical debt
entry is removed since no difference is left.

Written with AI assistance (Claude).

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-10-17 16:41:22 +02:00
pushkarreddyy 7bb76080c6 fix(libkernel): return EFAULT from truncate, utimes, mkdir, rmdir, and rename for a null path 2026-10-17 19:34:28 +05:30
mattogepetoandClaude Sonnet 5.5 9dc6542999 fix(libkernel): report EINVAL for getdirentries on a non-directory
sceKernelGetdirentries on a descriptor that is not a directory returned
ENOTDIR from the host getdents64 on Linux, and ENOTDIR for every descriptor
missing from the directory table on Windows, including invalid ones.
FreeBSD 11.4's kern_getdirentries returns EINVAL when the vnode is not a
directory.

Return EINVAL for a regular file on both hosts and EBADF for an invalid
descriptor on Windows. Test getdents and getdirentries on a regular file and
list the pipe case, which still fails with ESPIPE on Linux, in the library's
technical debt file.

Written with AI assistance (Claude).

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
2026-10-17 15:37:23 +02:00
Alexej Szpevák 147d58cf9a feat(libkernel): poll regular files and directories as vop_stdpoll does
poll threw for any descriptor that is neither a socket nor a pipe, so a title polling a file it also reads stopped there. FreeBSD 11.4 hands a vnode to VOP_POLL, and both vop_stdpoll and vop_nopoll return POLLIN, POLLRDNORM and POLLOUT of the requested events for every event poll accepts and never POLLPRI, POLLRDBAND or POLLWRBAND. A file, a directory or a file read from app0.zar now answers that without a host call. File::IsVnode tells such a descriptor apart from the host file type without throwing, so a host socket lent by libSceNet still reaches its own path.
2026-10-17 15:18:34 +02:00
pushkarreddyy 274f092e70 fix(libkernel): return EFAULT from sceKernelStat and sceKernelUnlink for a null path 2026-10-17 18:41:29 +05:30
pushkarreddyy a295b771eb fix(libkernel): return EFAULT from sceKernelWriteThrottlingStatus for a null status 2026-10-17 18:31:54 +05:30
Maz 6ad392dad3 fix(libkernel): report absolute Windows symbolic links
lstat and readlink aborted on an absolute symbolic link because only a relative reparse point was accepted. Read the link text, and still refuse reparse points that are not symbolic links.
2026-10-17 16:03:12 +04:00
Dean df377440aa Merge pull request #7027 from milescoviello/fix/rw-count-einval
fix(libkernel): return EINVAL from read and write for a byte count above SSIZE_MAX
2026-10-18 00:23:29 +13:00
Dean de056cf06d Merge pull request #7025 from milescoviello/fix/kernel-read-write-null
fix(libkernel): return EFAULT from sceKernelRead and sceKernelWrite for a null buffer
2026-10-18 00:22:57 +13:00
Alexej Szpevák 41ec785705 fix(libkernel): answer F_GETLK with F_UNLCK on Linux and macOS
fcntl threw for F_GETLK with an F_UNLCK request on the hosts that use POSIX locks, as Linux's F_GETLK rejects that type. FreeBSD 11.4's kern_fcntl accepts it and lf_getlock reports the first overlapping lock that lf_blocks lets conflict: another owner's lock, one of the two being a write lock. For an F_UNLCK request that is exactly another owner's write lock, the same set an F_RDLCK request finds, so the host is asked with F_RDLCK and the reply is written back as for the other types.
2026-10-17 12:00:21 +02:00
milescovielloandClaude Opus 5.5 be17961e32 fix(libkernel): return EFAULT from fstat for a null stat buffer
FreeBSD's fstat looks the descriptor up before it copies the result
out, so a bad descriptor still fails with EBADF and an open one fails
with EFAULT when sb is null. fstat and sceKernelFstat threw
std::invalid_argument instead.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-10-17 06:19:41 +00:00
milescovielloandClaude Opus 5.5 28acd09977 fix(libkernel): return EINVAL from read and write for a byte count above SSIZE_MAX
FreeBSD's read, write, pread and pwrite reject a byte count above
IOSIZE_MAX with EINVAL before they look up the descriptor. write threw
std::invalid_argument for a negative count, and the others passed the
count on to the host, which reports EFAULT on Linux.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-10-17 06:01:09 +00:00
milescovielloandClaude Opus 5.5 b437dc5dba fix(libkernel): return EFAULT from sceKernelRead/sceKernelWrite for a null buffer
read and write already fail with EFAULT for a null buffer and a
non-zero length and treat a zero-length null buffer as empty. The
sceKernel entry points threw std::invalid_argument for both. They now
do the same as read and write.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-10-17 05:49:06 +00:00
Adrià 37f0253ce8 Merge pull request #5980 from Ondra97/codex/fix-ftruncate-invalid-descriptor
fix(libkernel): reject invalid ftruncate descriptors safely
2026-10-17 06:53:47 +02:00
Santhosh Kumar eb26fb97f8 fix(libkernel): filter sandbox TLS roots and preserve path overrides 2026-10-17 02:25:41 +00:00
screammandClaude Fable 5.1 9f4a8d6ec5 feat(libkernel): serve the console CA list from the host trust store
Titles that bundle OpenSSL load the console's CA file from the sandbox
directory and fail every HTTPS request without it. ProsperoRadio
(PPSA99001, libcurl 8.18.0 + OpenSSL 3.5.2) on main + #4796 + #4525:

  [ProsperoRadio][http] https://all.api.radio-browser.info/json/servers: Problem with the SSL CA cert (path? access rights?) (error adding trust anchors from file: /gkbHtXc3Wq/common/cert/CA_LIST.cer)

SwanStation (PPSA98510) stops on the same file (#5001).

The guest path resolver now accepts exact-path providers, and libkernel
registers one for /<sceKernelGetFsSandboxRandomWord()>/common/cert/CA_LIST.cer.
On first use it writes a PEM bundle once per process to
cert_cache/CA_LIST.cer in the run directory, read-only: on Windows the
current user's ROOT and CA system stores, elsewhere SSL_CERT_FILE or the
first distro bundle that exists. Without a certificate the path keeps
resolving under the guest root and does not exist, as before. Every other
path under the sandbox word is unchanged. The console file's format and
the rest of its common/cert directory are unverified and recorded in
docs/dev/debt/libkernel.md.

With this change, #4796, #4525 and #5025 on Windows 11, 60 s each:

  [ProsperoRadio][http] 11846160 bytes in 1458 ms: 1161 passes, 803 waits (679 woken) for 1428 ms
  [ProsperoRadio][catalog] page offset=0 bytes=11846160 objects=10000 accepted=9549 total=9549
  ...
  [ProsperoRadio][catalog] page offset=60000 bytes=1712035 objects=1494 accepted=1436 total=59371

  [SwanStationPS5] update: latest 1.2.5, this 1.1.3, available
  [SwanStationPS5] gamedb: index written

Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
2026-10-17 02:24:02 +00:00
Adrià a067dc2418 Merge pull request #5938 from xXPBSXx/fix/libkernel-close-waits-positioned-transfer
fix(libkernel): make close wait for a positioned transfer on the same descriptor
2026-10-16 22:31:04 +02:00
MarcZX100 2b8e37ae0a fix(libkernel): log resolved paths for failed opens 2026-10-16 20:18:57 +00:00
Adrià 1391ea30b6 Merge pull request #5831 from ahmad3a4/fix/libkernel-append-atomic-windows
fix(libkernel): append O_APPEND writes atomically on Windows
2026-10-16 21:23:47 +02:00
Adrià FranchandClaude 5484500734 fix(libkernel): drop the second positioned lock in NativePositionedTransfer
Its callers (NativePositioned_nid_no_patch, the vectored transfer) already hold the
non-recursive per-descriptor lock, so locking again deadlocked every positioned transfer.

Co-Authored-By: Claude <noreply@anthropic.com>
2026-10-16 20:52:19 +02:00
xXPBSXxandClaude Sonnet 5.5 f2649c3301 fix(libkernel): make close wait for a positioned transfer on the same descriptor
Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
2026-10-16 20:52:15 +02:00
Ahmad e8c97bf926 fix(libkernel): append O_APPEND writes atomically on Windows
On Windows the C runtime appends by seeking to the end and then writing,
so concurrent appends through different descriptors overwrite each other
and lose data. Write and writev on an O_APPEND descriptor now go through
WriteFile at the end-of-file offset, which Windows appends atomically,
and writev gathers its buffers into one append as FreeBSD writes the
whole vector at the end.
2026-10-16 20:25:29 +02:00
Alexej Szpevák d97d6efb1b fix(libkernel): refuse descriptor calls on app0.zar files
flock, fstatfs, ftruncate, fsync, fdatasync, getdirentries, fchmod, futimes and mmap on an archived descriptor acted on its null device and succeeded or failed with an unrelated errno. They now throw NotImplemented, each covered by the kernel archive test; mmap is noexcept, so its refusal is checked through the terminate handler.
2026-10-16 20:03:32 +02:00
Alexej Szpevák 9b911ed510 feat(libkernel): serve app0.zar files through the file calls
sceKernelOpen and open give an archived file a read-only null-device descriptor. Reads, positioned, vectored and AIO reads, seeks, fstat and FIONREAD are served from the archive; dup, dup2 and F_DUPFD share the position. sceKernelStat and sceKernelCheckReachability see archived paths.

Writing opens fail with EROFS, O_CREAT|O_EXCL with EEXIST and O_DIRECTORY on a file with ENOTDIR. Opening an archived directory or one merged with the disk throws until getdents can list it.
2026-10-16 20:03:32 +02:00
Ondra97 65e95f7139 fix(libkernel): serialize Windows vectored file transfers 2026-10-15 15:48:10 +02:00
Dean Galvin eac8bfcfc0 fix(libc): list the directory once for a missing path that may be a relinked module
A read-only open, stat or reachability check of a missing path listed its
directory twice: once for a case-insensitive match of the name and again for
a case-insensitive match of the relinked <name>.guest.prx (#5434). Both
names are now matched in the same listing. Precedence and the ambiguous-name
errors are unchanged.
2026-10-15 13:59:12 +13:00
Adrià e27ff7c545 Merge pull request #5819 from GitamarT045T3R/fix/windows-lstat-symbolic-links
feat(libkernel): report relative symbolic links in lstat on Windows
2026-10-14 20:44:09 +02:00