Commit Graph
317 Commits
Author SHA1 Message Date
xXPBSXxandClaude Sonnet 5.5 cb6cd768ef fix(libkernel): fail open, stat, lstat, access and unlink through a regular file with ENOTDIR on Windows
A path whose directory part is a regular file, such as file/child, failed
with ENOENT in open, stat, lstat, access and unlink on Windows, where
FreeBSD 11.4 lookup fails it with ENOTDIR (vfs_cache_lookup, sys/kern/vfs_cache.c).
mkdir and rmdir already did. A not-found error of these calls now asks whether the
nearest existing ancestor is not a directory and reports ENOTDIR then.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
2026-10-20 06:00:15 +02:00
Dean 525e299fc0 Merge pull request #8184 from xXPBSXx/fix/fsync-pipe-fb
fix(libkernel): fail fsync and fdatasync on a pipe with EINVAL
2026-10-20 16:24:09 +13:00
Dean 28a9be72a4 Merge pull request #8182 from xXPBSXx/fix/flock-bad-descriptor-fb
fix(libkernel): fail flock on an invalid descriptor with EBADF and on a pipe with EOPNOTSUPP
2026-10-20 16:23:47 +13:00
Dean 1ae92bb7c9 Merge pull request #8174 from xXPBSXx/fix/rename-dot-component-fb
fix(libc): fail a rename of a path that ends in a dot component with EINVAL
2026-10-20 16:23:33 +13:00
Dean 0db8299723 Merge pull request #8178 from xXPBSXx/feat/fdopendir-position-fb
fix(libSceLibcInternal): start fdopendir at the descriptor position and set FD_CLOEXEC
2026-10-20 16:23:03 +13:00
Dean b96e1f29ff Merge pull request #8171 from xXPBSXx/fix/libkernel-truncate-utimes-argument-order
fix(libkernel): check truncate length and utimes times before the path
2026-10-20 15:22:16 +13:00
xXPBSXxandClaude Sonnet 5.5 da6b8561c3 fix(libkernel): fail fsync and fdatasync on a pipe with EINVAL
On Windows fsync and fdatasync of a pipe descriptor answered EBADF for the
read end and 0 for the write end. FreeBSD 11.4 kern_fsync reaches the
descriptor through getvnode, which fails a descriptor that is not a vnode
with EINVAL. NativeSync now refuses a pipe handle with EINVAL before it
commits.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
2026-10-20 03:32:02 +02:00
xXPBSXxandClaude Sonnet 5.5 a11756851e fix(libkernel): fail flock on an invalid descriptor with EBADF and on a pipe with EOPNOTSUPP
flock on a descriptor that is not open threw a runtime_error from the failed
Windows lock call, ending the title. FreeBSD 11.4 sys_flock fails it with
EBADF (fget) and a descriptor that is not a vnode, such as a pipe, with
EOPNOTSUPP. The guest flock now checks the descriptor first, on Windows
through the OS handle and elsewhere through fstat.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
2026-10-20 03:29:01 +02:00
xXPBSXxandClaude Sonnet 5.5 7535eb45fc fix(libSceLibcInternal): start fdopendir at the descriptor position and set FD_CLOEXEC
fdopendir listed the directory from its first entry whatever position the
descriptor had, and left FD_CLOEXEC unchanged. FreeBSD 11.4 fdopendir sets
FD_CLOEXEC on the descriptor and preserves the initial seek position (lib/libc/gen/opendir.c).
The Windows directory handle now skips the entries the descriptor already
consumed, the Linux handle duplicates the descriptor, and the test requires both.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
2026-10-20 03:11:14 +02:00
xXPBSXxandClaude Sonnet 5.5 dd945495e3 fix(libkernel): check truncate length and utimes times before the path
FreeBSD 11.4 kern_truncate returns EINVAL for a negative length before it
looks up the path, and getutimes rejects an out-of-range tv_usec before
namei in utimes and lutimes. The guest calls checked a NULL or empty path
first, so truncate(NULL, -1) and utimes("", {usec -1}) returned EFAULT or
ENOENT where FreeBSD returns EINVAL.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
2026-10-20 03:07:47 +02:00
xXPBSXxandClaude Sonnet 5.5 9899ba0fa2 fix(libc): fail a rename of a path that ends in a dot component with EINVAL
rename and sceKernelRename resolved "dir/." to "dir" and renamed the directory. FreeBSD 11.4's lookup fails a last component of "." for DELETE and RENAME with EINVAL, for the source and the destination alike. Check the guest string before it is resolved: a last component of "." (also under trailing slashes) fails with EINVAL when its parent exists, ENOENT when it does not and ENOTDIR when it is not a directory.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
2026-10-20 02:57:14 +02:00
xXPBSXxandClaude Sonnet 5.5 1ccbbc2faa fix(libkernel): fail chflags on an oversized path name with ENAMETOOLONG instead of throwing
Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
2026-10-20 02:46:54 +02:00
Adrià 67e5c8a48f Merge pull request #7403 from milescoviello/fix/fcntl-host-socket
fix(libkernel): handle fcntl and FIONREAD on a host socket descriptor
2026-10-19 21:30:50 +02:00
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
milescovielloandClaude Opus 5.5 bdead6944b fix(libkernel): handle fcntl and FIONREAD on a host socket descriptor
On Linux and macOS, fcntl and ioctl threw "descriptor N is neither a
file, a directory, a pipe nor a character device" for a host socket that
is not a guest socket. That is what a standard descriptor is when a
service manager connects it to its journal, or when a test runner starts
the process with a socket as stdin; guest_kernel_fcntl's standard input
check aborts then.

A socket is now its own descriptor kind. Its status and close-on-exec
flags go through the host as for a pipe end, FIONREAD asks the host,
record locks and read-ahead hints fail with EBADF as FreeBSD's
kern_fcntl fails them on a descriptor without a vnode, and O_ASYNC
throws as on a pipe.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-10-18 04:44:36 +00: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