Commit Graph
356 Commits
Author SHA1 Message Date
Dean 3e91c8edf5 Merge pull request #8850 from UnhealthyKraken/feat/libkernel-cfsetspeed
feat(libkernel): implement cfsetspeed
2026-10-22 00:13:16 +13:00
Dean 8425543705 Merge pull request #8655 from cadenasynyster/fix/win-open-loop-inside
fix(libkernel): report ELOOP for a path below a Windows symlink loop
2026-10-21 20:57:12 +13:00
Kraken aae12fa111 feat(libkernel): implement cfsetspeed 2026-10-21 04:00:42 +01:00
Dean 557682ca44 Merge pull request #8798 from JJenkx/windows/open-keep-native-error
fix(libkernel): keep the native open error when the Windows directory probe finds no directory
2026-10-21 14:38:41 +13:00
Dean 8a803d3e6d Merge pull request #8743 from valenciana-nc/fix/kernel-iovec-table-copy
fix(libkernel): return EFAULT for unreadable iovec tables
2026-10-21 14:24:39 +13:00
JJenkxandClaude Opus 5.5 af086114c7 fix(libkernel): keep the native open error when the Windows directory probe finds no directory
When the native open failed with an error other than ENOENT, OpenNative
probed whether the path is a directory with std::filesystem::is_directory.
With the MinGW runtime that probe can set errno to ENOENT, and OpenNative
then reported the probe's ENOENT instead of the open error. On Windows 11
22621 a symbolic link loop failed with ELOOP from the native open and
sceKernelOpen returned 0x80020002, so guest_filesystem aborted at the
ELOOP check added by #8640.

Keep the open error and restore it when the path is not a directory.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-10-20 20:54:15 -04:00
Dean eea640a5bf Merge pull request #8386 from xXPBSXx/fix/lseek-descriptor-first-fb
fix(libkernel): look up the descriptor of lseek before the whence value
2026-10-21 12:06:53 +13:00
valenciana-nc 23c43725f6 fix(libkernel): copy guest iovec tables before vector transfers 2026-10-20 17:04:30 -06:00
cadenasynysterandClaude Sonnet 5.5 97a2dcb27f fix(libkernel): report ELOOP when opening below a Windows symbolic link loop
A path below a self-referencing symbolic link returned ENOTDIR on Windows; FreeBSD returns ELOOP. A failed native open now uses the loop check that sceKernelStat uses.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01GtXavMkgCTCdmRpweviHcQ
2026-10-20 22:06:36 +02:00
Dean 9a97ac784d Merge pull request #8591 from xXPBSXx/fix/getdirentries-basep-windows
fix(libkernel): report the starting entry index in getdirentries basep on Windows
2026-10-21 09:04:26 +13:00
xXPBSXxandClaude Sonnet 5.5 eaadb2924b fix(libkernel): report the starting entry index in getdirentries basep on Windows
The Windows sceKernelGetdirentries stored 0 in *basep on every read, so a
guest looping on the cookie saw it stall (FreeBSD stores the directory
offset the read started at, kern_getdirentries: *basep = loff). Report the
index of the first entry of the read, the same unit lseek takes on these
descriptors, and run guest_directory_entries on Windows, where it was never
built.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
2026-10-20 19:33:03 +02:00
mantavisualandClaude Opus 5.5 73784e2050 fix(libkernel): leave a file's times untouched when Windows utimes refuses them
On Windows, utimes, lutimes, sceKernelUtimes and futimes open a
FILE_WRITE_ATTRIBUTES handle and only then encode the times. A time the
host cannot represent returned EINVAL without calling SetFileTime, and
with NTFS last-access updates enabled closing that handle set the file's
access time to the current time, so a rejected call still changed the
file and guest_file_timestamps failed on "access time preserves
microseconds". A rejected time now marks the handle with 0xFFFFFFFF,
which SetFileTime documents as preventing operations on the handle from
updating the times, before the handle is closed. Error order is
unchanged.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-10-20 20:20:20 +03:00
Dean 77e31219c8 Merge pull request #8116 from dantdmdarealguy/fix/libc-readdir-fileno-windows
fix(libc): report the file number of each readdir entry on Windows
2026-10-21 04:55:57 +13:00
Adrià 4036fab1b2 Merge pull request #7437 from lucaslima430/fix/libkernel-socket-fcntl-duplication
fix(libkernel): support socket fcntl duplication
2026-10-20 17:40:06 +02:00
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
Queuze bbcce1736e fix(libkernel): support socket fcntl duplication 2026-10-20 13:40:22 +02:00
xXPBSXxandClaude Sonnet 5.5 06ee881eba fix(libkernel): look up the descriptor of lseek before the whence value
lseek on a descriptor that is not open with an invalid whence answered EINVAL.
FreeBSD 11.4 kern_lseek looks the descriptor up first and only then lets the
file's seek operation judge the whence, so the answer is EBADF.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
2026-10-20 13:39:50 +02: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
dantdmdarealguy 251ca1c100 fix(libc): report the file number of each readdir entry on Windows
readdir and readdir_r returned d_fileno 0 for every entry on Windows,
because MinGW's _wreaddir reports no inode. FreeBSD 11.4's
_readdir_unlocked (lib/libc/gen/readdir.c) never returns an entry whose
d_ino is 0, and d_fileno is the number lstat reports as st_ino.

The Windows directory stream now reads the listing from the directory
handle with GetFileInformationByHandleEx(FileIdBothDirectoryInfo), so
each entry carries the file ID of the entry itself, symbolic links
included, without opening it. The ID is folded as stat and lstat fold
nFileIndexHigh:nFileIndexLow; the fold moves to WindowsDescriptor.hpp so
both libraries use it. rewinddir restarts the scan, telldir and seekdir
count entries as _wtelldir and _wseekdir did, and opendir fails with the
open error of the directory. A file system that lists no file ID gets a
nonzero number hashed from the name. Linux truncates the host inode to
32 bits as stat does instead of reporting 0 above 2^32.

guest_directory checks that every entry has a nonzero file number, that
the numbers of a file, a subdirectory and symbolic links to both equal
lstat's st_ino, that an entry created or removed while the directory is
open shows up after rewinddir, that a delete-pending entry no lstat can
open is still listed, and that seekdir returns the same number.
2026-10-20 03:52:39 -05: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