Commit Graph
339 Commits
Author SHA1 Message Date
Adrià 054852a76b Merge pull request #6942 from AlexOfTheForest/fix/path-errno
fix(libkernel): report ELOOP and ENAMETOOLONG from mkdir, rmdir and truncate
2026-10-20 17:05:43 +02:00
Adrià 5f7aa5570c Merge pull request #7563 from babyhuey/feat/libkernel_sys-fstatat
feat(libkernel_sys): implement fstatat
2026-10-20 16:08:26 +02:00
Dean cabd80f472 Merge pull request #8358 from xXPBSXx/fix/libc-rename-source-first
fix(libc): resolve the rename source before the destination argument
2026-10-21 02:30:34 +13:00
Dean 44e3389c88 Merge pull request #7807 from mazen320/fix/windows-stderr-dup2
fix(libkernel): keep host stderr off a guest dup2 onto descriptor 2
2026-10-21 01:45:30 +13:00
Alexej Szpevák 5057a9e54d fix(libkernel): report ELOOP and ENAMETOOLONG from truncate
sceKernelTruncate's status query fails with too_many_symbolic_link_levels for a link loop and filename_too_long for an over-long name, and the call answered ENOENT for both. It now returns ELOOP or ENAMETOOLONG through PathLookupFailure, and truncate sets the same errno.
2026-10-20 13:31:52 +02:00
Alexej Szpevák eead108c3b fix(libkernel): report ELOOP and ENAMETOOLONG from mkdir and rmdir
#6648 taught open, unlink and stat to report a symbolic link loop and an over-long name, but sceKernelMkdir and sceKernelRmdir still lost them: their std::filesystem queries fail with filename_too_long or too_many_symbolic_link_levels and the code went on to ENOENT, EIO or ENOTDIR. A PathLookupFailure check after those queries now returns the guest error (ELOOP 62, ENAMETOOLONG 63) as FreeBSD's namei does, and the POSIX wrappers set the same errno. guest_path_errors covers the open, unlink, stat, rename, mkdir and rmdir paths with a self-referencing link, a two-link cycle, a 300-byte name and each as a path prefix; it is UNIX-only because it creates symbolic links.
2026-10-20 13:31:44 +02:00
xXPBSXxandClaude Sonnet 5.5 308848e1a6 fix(libc): resolve the rename source before the destination argument
FreeBSD 11.4 kern_renameat looks up the source first (namei on fromnd),
so a missing or dot source fails with ENOENT or EINVAL before the new
name is touched. The guest call rejected a NULL, empty or dot destination
first, so rename(missing, NULL) returned EFAULT and rename(missing, ".")
returned EINVAL where FreeBSD returns ENOENT.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
2026-10-20 12:51:02 +02:00
Adrià a0e0985288 Merge pull request #7551 from mazen320/fix/open-nofollow-junction
fix(libkernel): stop O_NOFOLLOW from opening a Windows directory junction
2026-10-20 12:20:01 +02:00
mazen c03168fb47 fix(libc): keep guest stdio on a dup2 of descriptors 1 and 2
Host logging opens its own FILE on the saved descriptor. The guest FILE stays on the replaced descriptor, so guest printf, puts and fprintf still reach the pipe.
2026-10-20 13:38:07 +04:00
mazen 715fe9ca26 fix(libkernel): keep host stdout off a guest dup2 onto descriptor 1
The same guest dup2 that fills the stderr pipe also replaces descriptor 1, so host stdout was still writing into the guest pipe.
2026-10-20 13:38:07 +04:00
mazen 2d1c18410f fix(libkernel): keep host stderr off a guest dup2 onto descriptor 2
Guest dup2 onto 2 replaces the CRT descriptor fprintf(stderr) still uses, so host logs fill the 4 KiB guest pipe.
2026-10-20 13:38:06 +04:00
SebastianandClaude Opus 5.5 cfdaf2dbb8 feat(libkernel): implement fchflags
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01QnkpF2oEMofseVz9Z7WEAC
2026-10-20 07:28:54 +00:00
Dean 15da28937e Merge pull request #8149 from JJenkx/windows/libkernel-stat-symlink-loop
fix(libkernel): report ELOOP from sceKernelStat for Windows symbolic link loops
2026-10-20 19:32:01 +13:00
Dean b20839c6cd Merge pull request #8199 from xXPBSXx/fix/enotdir-through-file-2-fb
fix(libkernel): fail chmod, truncate, utimes and rename through a regular file with ENOTDIR on Windows
2026-10-20 18:31:35 +13:00
JJenkxandClaude Opus 5.5 afec282b0f fix(libkernel): report ELOOP from sceKernelStat for Windows symbolic link loops
On Windows std::filesystem::status reports a symbolic link that resolves
to itself as missing, because the CRT maps ERROR_CANT_RESOLVE_FILENAME to
ENOENT, so sceKernelStat returned 0x80020002 where the console and the
Linux build return SCE_KERNEL_ERROR_ELOOP. When the status says the path
does not exist, open it once following links and return ELOOP when Windows
fails with ERROR_CANT_RESOLVE_FILENAME.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-10-20 01:21:22 -04:00
Dean d0ac490cb0 Merge pull request #8195 from xXPBSXx/fix/enotdir-through-file-fb
fix(libkernel): fail open, stat, lstat, access and unlink through a regular file with ENOTDIR on Windows
2026-10-20 18:07:05 +13:00
Dean 564c75b289 Merge pull request #7956 from Lindamea1/fix/libkernel-ioctl-malformed-enotty
fix(libkernel): fail a malformed ioctl request with ENOTTY
2026-10-20 17:49:59 +13:00
xXPBSXxandClaude Sonnet 5.5 7f32f42627 fix(libkernel): fail chmod, truncate, utimes and rename 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 chmod, truncate, utimes and rename on Windows, where FreeBSD
11.4 fails it with ENOTDIR (vfs_cache_lookup, sys/kern/vfs_cache.c). The
not-found error of these calls now asks whether the nearest existing
ancestor is not a directory, as open, stat, lstat, access and unlink do.
For rename the source ancestor is checked first and the destination ancestor
only while the source exists. A test line that expected ENOENT for truncate
of a path below a regular file now expects ENOTDIR.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
2026-10-20 06:01:12 +02:00
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
xXPBSXxandClaude Sonnet 5.5 bcbcf55b5b fix(libkernel): extend a file with ftruncate without writing zero bytes on Windows
ftruncate, truncate and sceKernelFtruncate extended a file through _chsize_s,
which writes the whole new length as zero bytes. FreeBSD extends the file
without writing data (kern_ftruncate -> ffs_truncate) and fails a length the
file system cannot hold with EFBIG. NativeFtruncate now sets the end of file
with SetFileInformationByHandle and maps ERROR_DISK_FULL to ENOSPC and
ERROR_FILE_TOO_LARGE/ERROR_INVALID_PARAMETER to EFBIG.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
2026-10-20 05:58:22 +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
Hussein Kadhim baa6d4aeee fix(libkernel): fail a malformed ioctl request with ENOTTY before the descriptor is looked at
FreeBSD's sys_ioctl rejects a request with no direction bit, an output request with no length, or a void request whose length is not an int before it reads the argument or resolves the descriptor. ioctl threw on such a request for a file, pipe or directory, failed with EBADF for a closed descriptor and with EFAULT for a socket given no argument.

(cherry picked from commit 501518f321ac5d0b45ce1090af39c680927edf49)
(cherry picked from commit 3eb7edd9cf)
2026-10-19 16:25:42 +01: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