Commit Graph
117 Commits
Author SHA1 Message Date
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
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 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 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
MarcZX100 087c57ac84 test: retry transient Windows filesystem cleanup 2026-10-18 00:45:12 +00: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
MarcZX100 28eaa5bdad fix(libkernel): preserve extended paths in stat metadata 2026-10-17 16:15:54 +00:00
MarcZX100 c0a6caeed3 test(libkernel): preserve directory stat on long paths 2026-10-17 16:15:54 +00:00
MarcZX100 2644234a24 test(libkernel): keep missing long stat paths as ENOENT 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
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
pushkarreddyy a295b771eb fix(libkernel): return EFAULT from sceKernelWriteThrottlingStatus for a null status 2026-10-17 18:31:54 +05:30
Maz 6e331b3823 test(libkernel): compare absolute links by the file they name 2026-10-17 16:46:55 +04:00
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
MarcZX100 2b8e37ae0a fix(libkernel): log resolved paths for failed opens 2026-10-16 20:18:57 +00: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à FranchandClaude cd0c6ed16e test(libkernel): do not stat the dangling link on Windows
stat of a dangling link reaches FillFileStat and throws on the CI toolchain; it is not part of this change.

Co-Authored-By: Claude <noreply@anthropic.com>
2026-10-14 18:55:36 +02:00
Itamar Medyoni 52a3b15796 feat(libkernel): report relative symbolic links in lstat on Windows
lstat of a Windows symbolic link threw, although symlink creates links
with relative targets on Windows and readlink reads them. Report such a
link as S_IFLNK with its own identity and times and the length of its
target as st_size, through the reparse reader readlink already used,
now shared from libkernel. Links with absolute targets, junctions and
other reparse points still throw, as for readlink.
2026-10-14 18:55:31 +02:00
Dean c3bad39372 Merge pull request #5434 from milescoviello/fix/relinked-module-name-case
fix(libc): find a relinked module whose name differs in case
2026-10-14 22:41:23 +13:00
milescovielloandClaude Opus 5.5 f0c3a5c85e fix(libc): find a relinked module whose name differs in case
Borderlands 4 (PPSA01494) loads its UI library with
sceKernelLoadStartModule("/app0/prx/libRenoirCore.PS5.prx"), but ships
the module as prx/librenoircore.ps5.prx. On Linux the call fails:

    Could not load /app0/prx/libRenoirCore.PS5.prx result 0, handle result -2147352574

(0x80020002, ENOENT). Guest paths are resolved case-insensitively, but
that only finds a component that exists. With the documented layout,
app0/prx holds only the converted librenoircore.ps5.prx.guest.prx,
so the requested name resolves to itself and RelinkedModulePath then
looks for "libRenoirCore.PS5.prx.guest.prx" with its exact spelling.
Windows and macOS hosts ignore the case, so only Linux is affected.

RelinkedModulePath now falls back to the same ASCII case-insensitive
match as ResolveHostPath when the exact <name>.guest.prx is missing,
and throws for an ambiguous match as that does. dlopen,
sceKernelLoadStartModule, stat, open and sceKernelCheckReachability all
go through it.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-10-14 01:31:24 +00:00
milescovielloandClaude Opus 5.5 ccfadfbeef fix(libc): keep a trailing slash on paths under a mount alias
Guest path resolution trimmed the trailing slash of a path under a
mount alias (/savedata0, /download0, /app0 and the others), so the host
saw "file" for "file/": unlink, remove, sceKernelUnlink and rename
removed or moved the file, open opened it, and chmod and access
succeeded on it. The same path outside an alias already failed with
ENOTDIR, because the host got the slash.

FreeBSD 11.4 rejects it in lookup() (sys/kern/vfs_lookup.c):

	/*
	 * If we're processing a path with a trailing slash,
	 * check that the end result is a directory.
	 */
	if ((cnp->cn_flags & TRAILINGSLASH) && dp->v_type != VDIR) {
		error = ENOTDIR;
		goto bad2;
	}

On Linux and macOS a path under an alias now keeps its trailing slash
on the host path, as paths outside an alias do, so the host fails with
ENOTDIR for a file and directories with a trailing slash still work.
Windows keeps the previous behaviour; TechnicalDebt records it.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-10-14 01:31:01 +00:00
Dean 2e7ab67e8d Merge pull request #4917 from MarcZX100/codex/carry-directory-read-4912
fix(libkernel): fail reads on Windows directory descriptors
2026-10-14 14:25:43 +13:00
Dean 7937c97237 Merge pull request #4923 from MarcZX100/codex/carry-ftruncate-not-file-4921
fix(libkernel): reject ftruncate on non-file Windows handles
2026-10-14 14:25:27 +13:00
Dean 979a4b9bb7 Merge pull request #5464 from milescoviello/fix/kernel-stat-null-buffer
fix(libkernel): fail sceKernelStat with EFAULT for a null buffer
2026-10-14 14:24:24 +13:00
milescovielloandClaude Opus 5.5 eb78c6a45f fix(libkernel): fail sceKernelStat with EFAULT for a null buffer
Crimson Desert (PPSA25286) calls sceKernelStat with a null buffer at
start-up, and main throws "sceKernelStat: sb is null", which ends the
title in its first second.

FreeBSD 11.4 looks the path up first and only then copies the result
out, so a null buffer gets EFAULT for a path that exists and the lookup
error for one that does not (sys/kern/vfs_syscalls.c, sys_stat):

	error = kern_statat(td, 0, AT_FDCWD, uap->path, UIO_USERSPACE,
	    &sb, NULL);
	if (error == 0)
		error = copyout(&sb, uap->ub, sizeof (sb));

sceKernelStat now does the same: the lookup and its errors are as
before, and a null buffer returns SCE_KERNEL_ERROR_EFAULT where the
status would be copied.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-10-13 20:20:07 +00:00
MarcZX100 8b5cfb9850 test(libkernel): declare chflags guest entry point 2026-10-13 18:54:07 +00:00
David 4dd97f7dbe feat(libkernel): implement chflags through the guest path resolver
PS5MC (PPSA99420, Kodi 22) imports chflags (ixrw0h2tWuI) from
libkernel.prx, one reference. Predicted stop once the imports ahead of
it (pthread_getthreadid_np, sendfile, wcstok, pause, setrlimit and the
termios calls) are covered (not a run):

  FAIL: unresolved ELF import ixrw0h2tWuI from libkernel.prx

The NID is computed with tools/nid_names.py and matches aerolib.

Follows FreeBSD 11.4 (8c639945a44588f6cfdddfb057bb5aad88735da0)
sys/kern/vfs_syscalls.c kern_chflagsat and setfflags, and
sys/ufs/ufs/ufs_vnops.c ufs_setattr, for a root caller: the lookup
through the guest resolver gives EFAULT, ENOENT and ENOTDIR (also for a
file reached through a trailing slash or used as a directory), a bit
outside the 17 UFS flags of sys/sys/stat.h (VNOVAL included) gives
EOPNOTSUPP, and SF_SNAPSHOT gives EPERM, since the snapshot flag cannot
be toggled. No host keeps BSD file flags and stat reports st_flags 0,
so flags 0 succeed without touching the file and any other flag throws
with the flags named. UF_READONLY and the other Windows-attribute flags
are not mapped to FILE_ATTRIBUTE_READONLY and its siblings: UFS stores
them without enforcing them, and on Windows the read-only attribute is
already the owner write bit of chmod.

Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
(cherry picked from commit 16e5b7ccd04e6467a5a282b6cfc9271304f42244)
2026-10-13 18:54:05 +00:00
Adrià c422b57fb3 Merge pull request #4672 from milescoviello/carry/lseek-pipe-windows-4670
fix(libkernel): fail lseek on a pipe with ESPIPE on Windows
2026-10-13 17:13:35 +02:00
Dean 9fa50827dd Merge pull request #4532 from DavidSamir/fix/libc-rename-replace-open-destination-windows
fix(libc): replace an open or read-only destination in rename on Windows
2026-10-14 00:38:14 +13:00
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 097bc538ee fix(libkernel): fail ftruncate on a pipe, a directory and a device with EINVAL on Windows
(cherry picked from commit 971fb51ef3f09d6543ef20e05e4a44572d2aadbd)
2026-10-13 04:18:07 +00:00
David 2f1eb100a0 fix(libkernel): fail reads on a directory descriptor with EISDIR on Windows
(cherry picked from commit d7ef271ef7eeb1d82a337a0b0a9767ce68721bd4)
2026-10-13 04:00:38 +00:00
David 69b9d186db fix(libc): replace an open or read-only destination in rename on Windows 2026-10-13 05:58:01 +04: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
David 61fbec8ef1 fix(libkernel): fail lseek on a pipe with ESPIPE on Windows 2026-10-12 18:33:31 +00: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 SchusterandClaude Opus 5.5 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
winstrexandClaude Opus 5.5 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 KumarandClaude Opus 5.5 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