Commit Graph

58 Commits

Author SHA1 Message Date
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
MathiasDevelopes 7fe298bfab fix(libkernel): return ENOENT from sceKernelStat for unconvertible paths
A guest path whose bytes the host cannot convert to a native path made
ResolvePath throw std::filesystem::filesystem_error, which aborted the
process. No file can have such a name on the host, so stat reports
ENOENT, as for any other missing file.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-10-10 18:15:59 +02:00
Tharun Balaji 57be03a4c1 fix: guard sceKernelFdatasync against guest socket descriptors
Add the guest socket descriptor guard to sceKernelFdatasync before any
native syscall, matching the existing sceKernelFchmod pattern. This
prevents high guest socket descriptors (e.g. 0x10000000) from reaching
the Windows CRT _commit, which would trigger the invalid-parameter
handler, and ensures the correct SCE error is returned on all platforms.

Refactor fdatasync_nid_postfix to delegate to sceKernelFdatasync via
PosixResult, removing the duplicated socket guard and native syscall.

Extend GuestFilesystem tests to cover:
- sceKernelFdatasync on a valid guest socket returns SCE EINVAL (0x80020016)
- sceKernelFdatasync on a closed guest socket returns SCE EBADF (0x80020009)
- sceKernelFdatasync on a high invalid descriptor (0x7fffffff) returns SCE EBADF
- closed-ordinary-descriptor tests now run on Windows (verified _commit on
  a closed descriptor returns EBADF without provoking the CRT handler)
2026-10-10 20:42:36 +05:30
tototomate123 9107be460f fix(libkernel): implement kernel futimes with POSIX error translation 2026-10-10 16:57:31 +02:00
tototomate123 a79bf5a727 fix(libkernel): return guest errors from chmod calls 2026-10-10 16:57:31 +02:00
Tharun Balaji 36bc9214cf fix(libkernel): return SCE errors from sceKernelFdatasync 2026-10-10 16:55:24 +05:30
Tharun Balaji 8839f6a1ba feat(libkernel): implement sceKernelFdatasync 2026-10-10 16:55:24 +05:30
Hussein Kadhim 0b1941b313 fix(libkernel): report a stable file identity from stat and fstat on Windows
st_ino was always 0 and st_dev differed between stat (drive number) and
fstat (0), so the usual a.st_dev == b.st_dev && a.st_ino == b.st_ino
identity check gave wrong answers. Read the volume serial, the file index
and the link count from the file handle, which works the same for path and
descriptor lookups.

Fixes #2296
2026-10-10 11:08:09 +02:00
MathiasDevelopes 7810f8464e feat(libkernel): open /dev/random and /dev/urandom for reading
Neither existed under the guest root, so opening them failed and titles
that then read from the descriptor crashed. Opening either for reading
now returns a descriptor whose reads, positioned reads and vector reads
fill the buffer from the host's random device, as
sceRandomGetRandomNumber does. Opening them for writing throws.

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
2026-10-10 09:12:55 +02:00
Dean 01dc5c14a3
Merge pull request #1764 from Zurisen/fix/flock-nonblocking-contention
fix(libkernel): return EWOULDBLOCK from a contended LOCK_NB flock
2026-10-10 20:08:00 +13:00
Dean 79d1220320
Merge pull request #2342 from AchrafReyani/fix/remove-readonly
fix(libc): remove read-only files on Windows
2026-10-10 20:07:46 +13:00
Adrià 7d94990371
Merge pull request #2300 from AchrafReyani/fix/libkernel-stat-trailing-slash
fix(libkernel): report ENOTDIR from stat for a file with a trailing slash
2026-10-10 08:27:27 +02:00
Zurisen 6d7d4b09e4 test(libkernel): check that a combined flock operation takes an exclusive lock 2026-10-10 07:55:48 +02:00
Zurisen 0f770d2203 fix(libkernel): return EWOULDBLOCK from a contended LOCK_NB flock
flock_nid_postfix threw on every failure, so a LOCK_NB request on a lock
held through another descriptor ended the process. FreeBSD flock(2)
returns -1 with EWOULDBLOCK there. Return guest errno 35 when LOCK_NB is
set and the host reports the lock as held: ERROR_LOCK_VIOLATION on
Windows, EWOULDBLOCK on Linux. Other failures still throw.
2026-10-10 07:55:48 +02:00
Zurisen d2b8e66c09 fix(libkernel): decode flock operations as FreeBSD does
FreeBSD sys_flock takes LOCK_UN over LOCK_EX over LOCK_SH, ignores other
bits and fails with EBADF when none of the three is set. The operation
reached the host unchanged, so malformed operations differed between
hosts: Linux rejects them with EINVAL and the Windows lock tracking threw.
Decode the operation before either host sees it.
2026-10-10 06:49:20 +02:00
Zurisen 6daf7df9ae fix(libkernel): give flock BSD semantics on Windows
flock mapped each call straight onto LockFileEx/UnlockFileEx, whose
byte-range locks stack per handle. LOCK_UN without a lock failed with
ERROR_NOT_LOCKED and aborted the process, a repeated LOCK_EX blocked
forever, converting between shared and exclusive failed, and a repeated
LOCK_SH needed as many unlocks.

Track the one lock each descriptor holds: a repeated mode and LOCK_UN
without a lock succeed, a conversion releases the old lock before taking
the new one, and close forgets the descriptor's lock.
2026-10-10 06:49:20 +02:00
Dean 65bd2f778a
Merge pull request #2289 from AchrafReyani/fix/libkernel-unlink-directory-eperm
fix(libkernel): return EPERM when unlinking a directory
2026-10-10 17:46:40 +13:00
Adrià Franch c1b714f242 test(libkernel): keep the file stat intact for the lstat checks 2026-10-10 06:14:41 +02:00
Achraf Reyani 610ffbbeba fix(libkernel): report ENOTDIR from stat for a file with a trailing slash
On Windows the existence check accepts "file/", then _wstat64 rejects
it and FillFileStat throws, aborting the title. On Linux the host
reports ENOTDIR, which became ENOENT. A trailing slash on something
that is not a directory now returns ENOTDIR on both hosts, as on
FreeBSD.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-10-10 06:14:41 +02:00
Hannah Lyons 94a33bfa5c fix(libkernel): honour open flags when Windows falls back to a directory descriptor 2026-10-09 21:22:23 -04:00
Adrià 72cf6c3c5a
Merge pull request #1624 from babyhuey/feat/libkernel-lstat
feat(libkernel): implement lstat
2026-10-09 23:52:02 +02:00
Hannah Lyons 903f50a3b4 feat(libkernel): implement lstat 2026-10-09 17:30:43 -04:00
Hannah Lyons 6768210713 feat(libkernel): implement fdatasync 2026-10-09 17:30:24 -04:00
Achraf Reyani 58e18f0828 fix(libc): remove read-only files on Windows
FreeBSD's unlink ignores the file's own permission bits, so remove()
succeeds on a file the guest made read-only with chmod(0400). On Windows
the guest chmod sets FILE_ATTRIBUTE_READONLY, and DeleteFileW then fails
with ERROR_ACCESS_DENIED, which remove() reported as EACCES. Clear the
attribute and retry, restoring it if the retry still fails.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-10-10 00:55:32 +09:00
Achraf Reyani 275163277b fix(libkernel): return EPERM when unlinking a directory
FreeBSD's unlink(2) reports EPERM for a directory, but the host call
returns EACCES on Windows and EISDIR on Linux, so the guest saw a
different error on each host. Check for a directory, not following a
symbolic link, before unlinking.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-10-09 22:39:50 +09:00
mrk1987 a9d31f3cba fix(libkernel): return POSIX errors from mkdir 2026-10-08 09:20:04 +02:00