Commit Graph
303 Commits
Author SHA1 Message Date
Dean 0b6486704b Merge pull request #7915 from root-over/fix/libkernel-open-flags-before-path-v2
fix(libkernel): check open flags before the path in open, _open and openat
2026-10-20 05:52:06 +13:00
Adrià 32004dfa55 Merge pull request #6992 from MarcZX10/codex/fix-stat-symlink-6983
fix(libkernel): return ELOOP when stat follows a symlink loop
2026-10-19 18:00:27 +02:00
Adrià cded26c687 Merge pull request #7007 from MarcZX10/codex/filter-host-ca-pem
fix(libkernel): filter host CA bundle to certificate blocks
2026-10-19 17:25:03 +02:00
Adrià 863486cc32 Merge pull request #6836 from DavidSamir/fix/libkernel-open-file-limit-macos
fix(libkernel): set the open file limit at load on macOS
2026-10-19 16:38:18 +02:00
Giuseppe Magliano ff688b2146 fix(libkernel): check open flags before the path in open, _open and openat
FreeBSD 11.4 rejects access mode 3 in kern_openat and
O_CREAT|O_EXCL|O_DIRECTORY in vn_open_cred before namei reads the path
or resolves the directory descriptor. open, _open and openat checked a
NULL or empty path first and returned EFAULT or ENOENT for those flags.
InvalidOpenFlags moves to FileFlags.hpp and runs first in all three.
2026-10-19 15:34:43 +02:00
Adrià 15047c6a8e Merge pull request #6897 from tv7/fix/fstat-closed-descriptor
fix(libkernel): return EBADF from fstat on a descriptor that is not open on Windows
2026-10-19 15:14:34 +02:00
Adrià f3bb6a4f8d Merge pull request #6878 from Dragost/fix/libkernel-directory-descriptor-seek-end
fix(libkernel): support SEEK_END on directory descriptors
2026-10-19 14:48:26 +02:00
MarcZX100 7c7a590caa fix(libkernel): map Linux stat symlink loops 2026-10-19 14:44:53 +02:00
MarcZX100 41483e7a21 fix(libkernel): return ELOOP when stat follows a symlink loop 2026-10-19 14:44:32 +02:00
Dean b106f6f8c0 Merge pull request #7672 from valenciana-nc/fix/getdirentries-guest-validation
fix(libkernel): refuse read-only guest mappings for getdirentries on Windows
2026-10-20 01:22:24 +13:00
David 0cb9d92b56 fix(libkernel): set the open file limit at load on macOS
getrlimit(RLIMIT_NOFILE) reports the host's limits, and libkernel
raised the soft limit to the hard one at load only on Linux. On macOS
the soft limit stayed below an unlimited hard limit (1048576 and
infinity in a shell here, 256 and infinity by default), so the two
differed. XPSemu (PPSA97358) then raises the soft limit to the hard one
in QEMU's os_setup_limits, and setrlimit refuses the change.

macOS fails with EMFILE at kern.maxfilesperproc (10240 here) whatever
the soft limit, even an unlimited one. At load, libkernel now sets both
limits to the smaller of the hard limit and kern.maxfilesperproc, so
getrlimit reports the descriptor count after which opening fails. The
Linux path still raises the soft limit to the hard one.
2026-10-19 13:34:29 +02:00
Dean cd32b54c56 Merge pull request #7806 from fogydes/fix/libkernel-pipe-buffer-size
fix(libkernel): increase pipe buffer size to match FreeBSD BIG_PIPE_SIZE
2026-10-19 23:53:54 +13:00
Dean 7f6ef06348 Merge pull request #7813 from whamre/fix/windows-stdio-stream-limit
fix(libkernel): raise the Windows stdio stream limit to RLIMIT_NOFILE
2026-10-19 23:52:59 +13:00
LexroidandClaude Opus 5.5 4fe32a457c fix(libkernel): return EBADF from fstat on a descriptor that is not open on Windows
sceKernelFstat and fstat passed any descriptor to the UCRT's _fstat64, which
raises the invalid-parameter handler for one that is not open. The crash
report installs that handler as fatal, so the calling thread died where the
console returns EBADF. Dying Light 2 (PPSA02262) hits it on a loading thread
right after sign-in.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-10-19 12:42:34 +02:00
Adrià Franch 7d57845016 fix(libkernel): pass the descriptor to Load in directory SEEK_END 2026-10-19 12:33:33 +02:00
Dragost f40205c8f5 fix(libkernel): support SEEK_END on directory descriptors 2026-10-19 12:33:20 +02:00
Adrià b95ca1b87d Merge pull request #6648 from NevesHenry/fix/libkernel-open-errno-mapping
fix(libkernel): report ENAMETOOLONG and ELOOP from open, unlink and stat
2026-10-19 10:15:06 +02:00
fogydes 9f0485c4cc fix(libkernel): increase pipe buffer size to match FreeBSD BIG_PIPE_SIZE
On Windows, pipe_nid_postfix configured the anonymous pipe with a 4096-byte buffer. When guest executables redirect standard error to a pipe via dup2 and host logging writes to standard error, the pipe buffer fills during startup before or between guest reader drains, blocking writer threads in ZwWriteFile and deadlocking the title. Increase the Windows pipe buffer capacity to 65536 bytes to match FreeBSD BIG_PIPE_SIZE used by the PS5 kernel, and cover multi-page single-shot pipe writes in guest posix scalar IO tests.
2026-10-19 13:44:41 +05:30
Werner 4e5eb1c3be fix(libkernel): raise the Windows stdio stream limit to RLIMIT_NOFILE
The C runtime allows 512 stdio streams by default, so after about 509
guest fopen/fdopen streams every further stream failed with EMFILE,
including the std::ifstream APR opens for each read, while getrlimit
reports 8192 open files. Raise the limit to 8192 when libkernel loads,
as the Linux build raises RLIMIT_NOFILE.
2026-10-19 08:00:07 +00:00
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
valenciana-nc 950eeb847d fix(libkernel): keep the getdirentries base guard open through its write and check the descriptor first 2026-10-18 19:00:40 -06:00
NevesHenryandClaude Opus 5.5 3fe7ba01c3 fix(libkernel): report ENAMETOOLONG and ELOOP from open, unlink and stat
Open.cpp passed host errno values 1 to 34 through and turned every
other one into EIO. On Linux, ENAMETOOLONG (36) and ELOOP (40) are above
that range, so sceKernelOpen and sceKernelUnlink returned EIO for a name
longer than 255 bytes or a symbolic link loop, where FreeBSD returns
ENAMETOOLONG (63) and ELOOP (62). sceKernelStat returned ENOENT for
both. sceKernelMkdir already reported them through the mapping in
Stdio.cpp.

Values above 34 now go through FilesystemError, the std::errc mapping
that path resolution already uses. sceKernelStat returns ENAMETOOLONG
and ELOOP when the status query fails with them. The POSIX open, unlink
and stat wrappers set the same errno values.

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
2026-10-18 21:35:18 -03:00
valenciana-nc 5d9a6483b5 fix(libkernel): validate getdirentries output buffers in the guest arena
sceKernelGetdirentries/sceKernelGetdents wrote up to nbytes into buf
and 8 bytes into *basep with only null checks, unlike sceKernelRead,
pread and readv which all gate on GuestArena::HostWrite. Validate both
buffers the same way so a forged pointer fails with EFAULT instead of
writing to an arbitrary host address.
2026-10-19 00:18:25 +00: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