Commit Graph

83 Commits

Author SHA1 Message Date
Dean 4fe3123627
Merge pull request #4640 from MarcZX100/codex/win-host-standard-handles-4631
fix(libc): preserve host standard handles on Windows redirects
2026-10-13 17:49:02 +13:00
David c22654102b fix(libc): keep the host standard handles when a guest replaces descriptor 0, 1 or 2 on Windows 2026-10-12 21:23:00 +00:00
Eli Yarson f80a2f5535 fix(libkernel): resolve original .prx names to relinked .guest.prx in stat, open and reachability
Titles check for a plugin with sceKernelStat before loading it through the engine path. The relinker emits only X.prx.guest.prx, so the check failed and PSNCore started with the raw (0, NULL) arguments. Share the dlopen mapping with sceKernelStat, read-only sceKernelOpen and sceKernelCheckReachability when the original name is absent.
2026-10-12 16:02:14 -03:00
Dean 21c27e60a4
Merge pull request #4536 from orishamir/fix/debugout-host-stderr
fix(libkernel): keep sceKernelDebugOutText off a redirected guest stderr
2026-10-13 07:31:53 +13:00
Dean f7b238e43b
Merge pull request #4513 from winstrex/fix/libkernel-open-directory-trailing-separator
fix(libkernel): open directories whose host path ends in a separator on Windows
2026-10-13 07:30:26 +13:00
Dean a7614930a4
Merge pull request #4349 from milescoviello/fix/open-nofollow
fix(libkernel): fail open with O_NOFOLLOW on a symbolic link
2026-10-13 04:53:25 +13:00
Dean 3881117feb
Merge pull request #4348 from milescoviello/fix/rmdir-symlink
fix(libkernel): fail rmdir on a symbolic link instead of removing it
2026-10-13 04:53:02 +13:00
Scott Schuster 2585eeb7ee fix(libkernel): keep sceKernelDebugOutText off a redirected guest stderr
Guest descriptors are host descriptors, so a guest that moves standard
error with dup2 also moves the stream sceKernelDebugOutText writes to. A
title that forwards its standard error to the kernel log through a pipe
then reads its own debug output back and logs it again without end. Before
the guest's first dup2 onto descriptor 2, the host's standard error is kept,
and sceKernelDebugOutText writes there.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-10-12 17:53:41 +03:00
winstrex a47178b86f fix(libkernel): open directories whose host path ends in a separator on Windows
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-10-12 10:06:44 -03:00
Santhosh Kumar 6b38cdda8c fix(libkernel): report the target size of symbolic links on Windows
_wstat64, the FindFirstFileExW listing and std::filesystem::file_size
report the size of a file symbolic link itself (0). stat therefore gave
0 for linked files, and APR resolved them as empty, so Unity treated a
linked globalgamemanagers as empty and never read it.

stat takes the size from the handle it already opens, which follows the
link. The APR listing skips reparse points, and names missing from it
are sized through stat.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-10-12 13:48:56 +05:30
Adrià d2fa71b706
Merge pull request #3682 from zmeizy/claude/kernel-fsync-error-codes
fix(libkernel): return SCE error codes from sceKernelFsync
2026-10-12 00:23:21 +02:00
Adrià 4a49ed06f7
Merge pull request #3712 from MarcZX100/codex/test-creat-errors-3303
test(libkernel): cover creat error cases
2026-10-11 23:54:51 +02:00
Claude db49377bef fix(libkernel): return SCE error codes from sceKernelFsync
sceKernelFsync returned the host fsync or _commit result, so a failure
returned -1 instead of an SCE error code, and a guest socket descriptor
reached the host call. fsync then set the guest errno from the host
errno rather than from that result.

Handle sockets and return SCE error codes as sceKernelFdatasync does
(EINVAL for an open socket, EBADF for a closed one or an unknown
descriptor), and have fsync take the errno from sceKernelFsync's result
like the other POSIX wrappers.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01Ha6Tsy62AFUyp9a5Mf7vjA
2026-10-11 23:53:00 +02:00
Adrià 4658391b1f
Merge pull request #3681 from zmeizy/claude/kernel-file-errno-translation
fix(libkernel): translate host errno in the file functions' SCE errors
2026-10-11 23:51:05 +02:00
Adrià 6c6c5552dc
Merge pull request #3677 from MarcZX100/carry/libkernel-delete-sharing-3316
fix(libkernel): allow delete sharing for open Windows files
2026-10-11 23:49:25 +02:00
Adrià 011c26cd5e
Merge pull request #3578 from LeandroLP23/fix/libkernel-fsync-read-only-windows
fix(libkernel): sync read-only and directory descriptors on Windows
2026-10-11 23:37:24 +02:00
milescoviello 9421484572 fix(libkernel): fail open with O_NOFOLLOW on a symbolic link
sceKernelOpen built the host flags from the bits it knows and dropped
O_NOFOLLOW (0x100), so open and sceKernelOpen with O_NOFOLLOW followed
a symbolic link and opened its target, and with O_CREAT created the
missing target of a dangling link.

FreeBSD looks up the last component without following it when
O_NOFOLLOW is set (sys/kern/vfs_vnops.c, vn_open_cred:
"((fmode & O_NOFOLLOW) ? NOFOLLOW : FOLLOW) | LOCKLEAF", and with
O_CREAT "if ((fmode & O_EXCL) == 0 && (fmode & O_NOFOLLOW) == 0)
ndp->ni_cnd.cn_flags |= FOLLOW;"), and then refuses the link itself in
vn_open_vnode: "if (vp->v_type == VLNK) return (EMLINK);".

open now fails with EMLINK when O_NOFOLLOW is set and the path names a
symbolic link. O_CREAT | O_EXCL keeps failing with EEXIST, and a
trailing slash still resolves through the link.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-10-11 21:30:23 +00:00
milescoviello e8cb97e6e2 fix(libkernel): fail rmdir on a symbolic link instead of removing it
sceKernelRmdir, and rmdir through it, checked the path with
std::filesystem::is_directory and is_empty, which follow a symbolic
link, and then removed the path itself. So rmdir on a link to an empty
directory returned 0 and deleted the link, while the target stayed.

FreeBSD looks up the last component of rmdir's path without following
it (sys/kern/vfs_syscalls.c, kern_rmdirat: NDINIT_ATRIGHTS with
LOCKPARENT | LOCKLEAF and no FOLLOW) and then fails with ENOTDIR for
anything that is not a directory: "if (vp->v_type != VDIR) { error =
ENOTDIR; goto out; }". A link, whether it points to a directory or
nowhere, is a VLNK there.

rmdir now returns ENOTDIR for a symbolic link and leaves it alone, as
unlink already looks at the link itself through symlink_status. A
trailing slash still resolves through the link, as before.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-10-11 21:30:23 +00:00
Santhosh Kumar 17827dd9ab fix(filesystem): reject invalid parent traversal on Windows 2026-10-12 01:25:02 +05:30
milescoviello ad14190c13 fix(libc): resolve ".." in guest paths against the directory before it
Guest paths were normalized lexically before they reached the host, so
"missing/../file" and "file/../x" dropped the component before "..":
stat and open succeeded on the file, unlink deleted it and rmdir removed
a directory, where FreeBSD's lookup() resolves ".." with VOP_LOOKUP in
the directory reached so far and fails with ENOENT for a missing
component and ENOTDIR for a file. POSIX path resolution (XBD 4.13) says
the same.

".." is still collapsed lexically when the path before it is an existing
directory, so case-insensitive matching and aliases behave as before.
When it is not, the rest of the path is passed to the host unchanged and
the host resolves it. Linux then reports ENOENT or ENOTDIR as FreeBSD
does; Windows collapses ".." itself, so its results are unchanged.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01XYhZu5HokHMo9mfi8QU83m
2026-10-12 01:24:53 +05:30
Tharun Balaji a0a7155964 test(libkernel): cover creat error cases
Carry the additional GuestFilesystem checks from issue #3303 after its implementation landed on main. The declaration already exists on main, so keep one prototype.
2026-10-11 15:43:40 +00:00
David dc022d8418 fix(libkernel): let a guest unlink and rename files it has open on Windows
FreeBSD removes or renames a file that is still open; the descriptor stays usable. _wopen opens without FILE_SHARE_DELETE, so sceKernelUnlink returned EACCES and rename failed while the guest held a descriptor. sceKernelOpen now opens through CreateFileW with delete sharing and keeps the flag, mode and error mapping of _wopen.

(cherry picked from commit 2f5ada5c86a427505804f22def209e054b3571e4)
2026-10-11 15:11:38 +00:00
Claude d7f1a6d3d5
fix(libkernel): translate host errno in the file functions' SCE errors
SceErrorFromErrno in the libkernel file functions passed host errno
values 1-34 through and turned every other value into EIO. Linux numbers
EAGAIN 11, which is FreeBSD's EDEADLK, so a read from an empty
non-blocking pipe returned SCE_KERNEL_ERROR_EDEADLK, and ENAMETOOLONG,
ELOOP, ENOTEMPTY, EDQUOT and EOVERFLOW, whose host values differ from
FreeBSD's, all became EIO.

Map those host values to the guest's FreeBSD numbers, as
SceIoErrorFromErrno in Open.cpp already does for EAGAIN, EDEADLK,
EDQUOT and EOVERFLOW. The guest constants the callers pass are all at
most 34 and never 11, or GUEST_ENOTEMPTY, so they are unchanged.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01Ha6Tsy62AFUyp9a5Mf7vjA
2026-10-11 14:32:44 +00:00
David 6db0a4df7c fix(libkernel): sync read-only and directory descriptors on Windows
FreeBSD's fsync and fdatasync succeed on a descriptor opened read-only and on a directory. _commit needs write access, so both returned EBADF there. A read-only descriptor is now flushed through a write handle from ReOpenFile and a directory through a handle opened for it, as sceKernelSync already does.
2026-10-11 15:15:00 +02:00
Abdulrahman Elkordy 8b0b78f529 test(libkernel): don't require restoring the directory time on Windows
The empty-path utimes check restores the working directory's write time
afterwards and requires the restore to succeed. With MinGW,
std::filesystem::last_write_time fails with EACCES when setting a
directory's time (a file's works), so guest_filesystem aborts there on
Windows. The restore stays, only its result is no longer checked.

Claude-Session: https://claude.ai/code/session_012SLQbhAiexxW6TtjYToW8a
2026-10-11 15:49:25 +03:00
Adrià c253de1165
Merge pull request #3428 from MarcZX100/codex/fix-libkernel-open-empty-path-3308
fix(libkernel): reject empty sceKernelOpen paths
2026-10-11 13:55:48 +02:00
Adrià 712ae61a02
Merge pull request #3465 from MarcZX100/codex/fix-empty-kernel-paths-3308
fix(libkernel): reject empty filesystem paths
2026-10-11 13:50:57 +02:00
MarcZX100 d26c9bcabc fix(libkernel): reject empty filesystem paths 2026-10-11 11:00:35 +00:00
MarcZX100 b1b996b243 fix(libkernel): reject empty sceKernelOpen paths 2026-10-11 10:49:17 +00:00
MarcZX100 8c06d20f6a fix(filesystem): reject final dot removal paths
Co-authored-by: milescoviello <kitslayer29@gmail.com>
2026-10-11 10:42:14 +00:00
Hussein Kadhim 14446548a9 fix(libkernel): keep mkdir errno stable and handle trailing separators in sceKernelMkdir
Capture errno before the ENOTDIR lookup, translate EINVAL from a name
under a regular file to ENOTDIR, check the parent only once and strip a
trailing separator before taking it, and split the dense rmdir return.
2026-10-11 10:58:38 +02:00
Hussein Kadhim e4b6a7b919 fix(libkernel): report ENOTDIR from mkdir and rmdir when a path component is a file
On Windows mkdir_nid_postfix returned ENOENT and sceKernelMkdir and
sceKernelRmdir returned ENOENT or EIO when a regular file was used as a
directory in the path. FreeBSD mkdir(2) and rmdir(2) return ENOTDIR for
a path component that is not a directory.
2026-10-11 10:58:21 +02:00
Hannah Lyons 01ed49c98e feat(libkernel): implement creat 2026-10-11 03:31:04 -04:00
Adrià effc61e4cd
Merge pull request #2787 from tototomate123/fix/hfw-filesystem-split
fix(libkernel): return guest chmod errors and implement sceKernelFutimes
2026-10-11 09:19:44 +02:00
Adrià 5b5220ccfd
Merge pull request #3276 from MarcZX100/codex/test-filesystem-native-error-3178
test(libkernel): report native filesystem errors
2026-10-11 09:17:50 +02:00
Dean 7edd75e106
Merge pull request #3169 from AchrafReyani/fix/test-windows-symlink-privilege
test(libkernel): skip the Windows lstat link checks without the symlink privilege
2026-10-11 18:55:03 +13:00
Dean b64cc2ce44
Merge pull request #3053 from MarcZX100/codex/libkernel-rmdir-read-only-3049
fix(libkernel): remove read-only directories with rmdir on Windows
2026-10-11 18:44:11 +13:00
MarcZX100 c53a31bb1d test(libkernel): report native filesystem errors 2026-10-11 04:53:40 +00:00
Achraf Reyani c332bdb319 test(libkernel): skip the Windows lstat link checks without the symlink privilege
guest_filesystem creates symbolic links for the Windows lstat checks.
Without administrator rights or Developer Mode, CreateSymbolicLinkW
fails with ERROR_PRIVILEGE_NOT_HELD even with
SYMBOLIC_LINK_FLAG_ALLOW_UNPRIVILEGED_CREATE, and the test aborted there
(reported as a stale guest errno). Skip those checks with a note in that
case; any other failure to create the first link still fails the test.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-10-11 08:56:03 +09:00
Adrià 62419286cd
Merge pull request #3009 from MarcZX100/fix/libkernel-open-directory-3004
fix(libkernel): report ENOTDIR for Windows O_DIRECTORY opens
2026-10-11 01:48:46 +02:00
David b69fba6a15 fix(libkernel): remove read-only directories with rmdir on Windows
(cherry picked from commit da6889627a417df433802a45a8fcca58a6cb904f)
2026-10-10 21:14:34 +00:00
David ee0b249e4e fix(libkernel): report ENOTDIR from open with O_DIRECTORY on a file on Windows
(cherry picked from commit b2e9f59959f3eef10db3f68886ee9d9ec1d50ea4)
2026-10-10 20:31:35 +00:00
MarcZX100 a22206bfbd test(libkernel): fix Windows lstat fixture cleanup 2026-10-10 20:10:19 +00:00
MarcZX100 314c372285 test(libkernel): cover dangling Windows lstat links 2026-10-10 20:09:49 +00:00
MarcZX100 7f2a88262a fix(libkernel): detect Windows reparse points in lstat 2026-10-10 20:09:49 +00:00
Dean 43d2a7c4c0
Merge pull request #2911 from MarcZX100/codex/fix-libc-rename-win-errors-2403-latest
fix(libc): match FreeBSD rename errors on Windows
2026-10-11 09:02:14 +13:00
Dean a8d24c7e44
Merge pull request #2910 from AchrafReyani/fix/unlink-readonly
fix(libkernel): unlink read-only files on Windows
2026-10-11 08:58:25 +13:00
MarcZX100 b0690903bb fix(libc): match FreeBSD rename errors on Windows 2026-10-10 18:25:17 +00:00
Dean 2ece83f4dc
Merge pull request #2129 from sktharunbalaji13-cmd/contrib/scekernel-fdatasync
feat(libkernel): implement sceKernelFdatasync
2026-10-11 07:19:45 +13:00
Achraf Reyani f45d8933f2 fix(libkernel): unlink read-only files on Windows
FreeBSD's unlink ignores the file's own permission bits, so it succeeds
on a file the guest made read-only with chmod(0400). On Windows the guest
chmod sets the read-only attribute and _wunlink then failed with EACCES,
which sceKernelUnlink and unlink reported. When the path is a regular file
without write permission, make it writable before the single _wunlink and
restore the read-only attribute if the unlink fails, as remove() does
since #2342.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-10-11 03:15:42 +09:00