Commit Graph
393 Commits
Author SHA1 Message Date
Dean a3cf44c558 Merge pull request #10111 from xXPBSXx/fix/fchflags-kqueue-einval
fix(libkernel): fail fchflags on a kqueue descriptor with EINVAL
2026-10-24 12:54:38 +13:00
Dean Galvin a2ee2958a5 Merge main into fix/fcntl-getfl-pipe-rdwr 2026-10-24 09:07:08 +13:00
Dean 4f3087c677 Merge pull request #10136 from orezraey/fix/libkernel-close-standard-descriptors-measured-ps5
fix(libkernel): refuse closing the standard descriptors with EPERM as measured on a PS5
2026-10-24 03:23:15 +13:00
Dean Galvin 6747c5b996 Merge main into fix/fcntl-getfl-pipe-rdwr 2026-10-24 02:10:48 +13:00
Dean 06fd07ab4a Merge pull request #8700 from nikowolf123/feat/libkernel-underscore-socket-signal-entries
feat(libkernel): export the underscore entry points of the socket, directory and signal calls
2026-10-24 00:53:04 +13:00
xXPBSXxandClaude Sonnet 5.5 5b739d2b56 fix(libkernel): fail fchflags on a kqueue descriptor with EINVAL
FreeBSD resolves the descriptor with getvnode in sys_fchflags
(vfs_syscalls.c:2403), which fails with EINVAL for a descriptor that has no
vnode. fchflags threw for a kqueue descriptor instead.

Co-Authored-By: Claude Sonnet 5.5 <[email protected]>
2026-10-23 12:28:27 +02:00
orezraey 5c7cdfda26 Merge remote-tracking branch 'origin/main' into fix/libkernel-close-standard-descriptors-measured-ps5 2026-10-23 06:55:14 -03:00
Dean b3e42bd1eb Merge pull request #8359 from Ragbie/fix/windows-pwrite-append
fix(libkernel): append positioned writes on an O_APPEND descriptor on Windows
2026-10-23 22:23:57 +13:00
Dean Galvin 2f741e737f Merge main into feat/libkernel-underscore-socket-signal-entries 2026-10-23 22:00:32 +13:00
Dean fef15751e6 Merge pull request #8641 from Danigamer05/fix/libkernel-windows-birthtime
fix(libkernel): clamp Windows birth time when setting earlier timestamps
2026-10-23 21:49:21 +13:00
Dean a75292c7b3 Merge pull request #8687 from cadenasynyster/fix/win-loop-errors
fix(libkernel): report ELOOP from unlink, mkdir, rmdir, truncate on Windows
2026-10-23 21:08:52 +13:00
orezraeyandClaude Opus 5.5 2c92b0f662 fix(libkernel): refuse closing the standard descriptors with EPERM as measured on a PS5
Co-Authored-By: Claude Opus 5.5 <[email protected]>
2026-10-22 21:26:24 -03:00
Dom3005andClaude Opus 5.5 93ab8d3514 fix(libkernel): answer fstatfs on a character device as devfs does
FreeBSD keeps every character device on devfs, whose devfs_statfs reports
512-byte blocks, 2 blocks and nothing free. Windows threw for any console,
NUL or the guest random device, and Linux described the host's /dev mount.
A kqueue now returns EINVAL, as getvnode does.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
2026-10-22 23:06:03 +02:00
Adrià a6fc8a467d Merge pull request #8797 from xXPBSXx/fix/unlink-rmdir-dot-component
fix(libkernel): fail unlink and rmdir of a path that ends in a dot component with EINVAL
2026-10-22 20:40:44 +02:00
Adrià 2e2ea5e697 Merge pull request #9131 from xXPBSXx/fix/fchdir-non-vnode
fix(libkernel_sys): fail fchdir on a pipe or socket with EINVAL
2026-10-22 20:32:29 +02:00
Adrià 9b1ed888d1 Merge pull request #9206 from xXPBSXx/fix/lseek-eoverflow
fix(libkernel): fail lseek with EOVERFLOW when the new offset exceeds the 64-bit range
2026-10-22 20:16:30 +02:00
Adrià FranchandClaude 093a5ba195 fix(libkernel_sys): reach the fchdir vnode check through a _nid_no_patch export
Co-Authored-By: Claude <[email protected]>
2026-10-22 20:15:39 +02:00
xXPBSXxandClaude Sonnet 5.5 e56c6d2ba8 fix(libkernel_sys): keep ENOTDIR from fchdir on a character device
The EINVAL for a descriptor without a vnode now applies only to a pipe or socket. A character device is a vnode on FreeBSD, so getvnode succeeds and change_dir fails with ENOTDIR; File::IsCharacterDevice keeps that answer for the host character devices (a tty, NUL or /dev/null) and the guest random device. guest_kernel_sys pins it with /dev/random.

Co-Authored-By: Claude Sonnet 5.5 <[email protected]>
2026-10-22 20:15:26 +02:00
Adrià 29b25aaf4a Merge pull request #9101 from xXPBSXx/fix/flock-directory-windows
fix(libkernel): accept flock on a directory descriptor on Windows
2026-10-22 19:42:03 +02:00
Dean 830ccd121f Merge pull request #9303 from oneandonlydean/fix/getdents-app0-symlink-type
fix(libkernel): report app0 symlinks as their target type in getdirentries
2026-10-23 02:19:24 +13:00
Dean ab347d144d Merge pull request #8534 from ycbuzi/pr/windows-reparse-non-link
fix(libkernel): answer Windows reparse points that are not links
2026-10-22 17:22:28 +13:00
Dean 746bdd8041 Merge pull request #8550 from Retr0G28/fix/fopen-directory-read-windows
fix(libc): open a directory with fopen in a read mode on Windows
2026-10-22 17:22:22 +13:00
blu 9897260c6e Merge branch 'boykopovar:main' into pr/windows-reparse-non-link 2026-10-21 19:08:16 -07:00
xXPBSXxandClaude Sonnet 5.5 00bb8aa409 fix(libkernel): fail lseek with EOVERFLOW when the new offset exceeds the 64-bit range
FreeBSD 11.4's vn_seek fails SEEK_CUR and SEEK_END with EOVERFLOW when the base offset plus a positive offset does not fit in an off_t, and with EINVAL only when the result is negative. The host lseek reports EINVAL for the overflow, so the guest saw EINVAL. When the host call fails with EINVAL for a positive offset on SEEK_CUR or SEEK_END, the base position is read back and the call fails with EOVERFLOW if the sum would overflow; the file position is left unchanged.

Co-Authored-By: Claude Sonnet 5.5 <[email protected]>
2026-10-21 20:56:02 +02:00
Adrià ee67ebcf2d Merge pull request #8663 from xXPBSXx/fix/transfer-descriptor-first-fb
fix(libkernel): look up the descriptor of read, write, pread and pwrite before their buffer and offset
2026-10-21 20:35:28 +02:00
Dean Galvin 58ad4eda77 fix(libkernel): report app0 symlinks as their target type in getdirentries
On Linux sceKernelGetdirentries copied the host d_type, so a directory under app0 that is a host symlink was listed as a link, and a title that only descends into directory entries skipped it. Inside the app0 tree, report a symlink (or an entry of unknown type) as the type of its target; links elsewhere, and dangling links, stay links.
2026-10-22 06:20:04 +13:00
NikoandClaude Opus 5.5 0ac2b0bc6f feat(libkernel): export the underscore entry points of the socket, directory and signal calls
The PS5 libkernel exports _accept, _bind, _connect, _getdirentries,
_getpeername, _getsockname, _getsockopt, _listen, _recvfrom, _recvmsg,
_sendmsg, _sendto, _setsockopt, _sigaction and _sigsuspend (PS5 3.20
export list, DNNDHH/PS5-3.20_Libs b2a77c0 libkernel.c), and main
exports none of them, so a title importing one fails at startup. Each
now forwards to the export without the underscore, as _close, _ioctl
and _nanosleep already do.

In FreeBSD 11.4 (8c639945a4) these are libc's plain system call
entries: lib/libc/amd64/SYS.h makes bind, getdirentries, getpeername,
getsockname, getsockopt, listen and setsockopt one stub under both
names, and lib/libc/sys/Makefile.inc gives accept, connect, recvfrom,
recvmsg, sendmsg, sendto, sigaction and sigsuspend a separate public
name that goes through libthr's interposing table, which adds the
cancellation points and the sigaction wrapper. The exports without the
underscore have no libthr layer here, so forwarding gives the system
call. docs/dev/debt/libkernel.md records what stays unverified: the
console is not measured, _sigaction shares the handler table of
sigaction, and a null set throws in _sigsuspend as in sigsuspend,
where FreeBSD's system call returns EFAULT.

guest_underscore_entries calls every new export: a loopback TCP
connection, UDP datagrams with scatter, truncation and sender
addresses, a directory listing compared with getdirentries, a SIGTERM
handler set by _sigaction, and a pending SIGUSR1 that _sigsuspend
delivers before returning EINTR with the mask restored. It checks the
errors they pass on (EBADF, EINVAL, EFAULT, ENOPROTOOPT, EOPNOTSUPP)
and that outputs stay untouched on failure.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
2026-10-21 17:02:54 +02:00
Retr0 36226741f5 fix(libc): open a directory with fopen in a read mode on Windows
FreeBSD 11 fopen opens the path with _open, and vn_open_vnode refuses a
directory only for FWRITE or O_TRUNC, so fopen of a directory in a read
mode succeeds; Linux hosts already open it. On Windows CreateFileW
without FILE_FLAG_BACKUP_SEMANTICS refused it with EACCES.

fopen now opens such a path as a libkernel directory descriptor, which
libkernel registers in libc when it loads, and fclose and freopen remove
it from libkernel's table. Reads on the stream fail with EISDIR and set
the error indicator, as on a Linux host and FreeBSD's tmpfs: the Windows
CRT fails them already but reports EINVAL. Writes fail with EBADF, and
fseek, ftell and ungetc work, as on any read-only stream.
2026-10-21 14:48:37 +03:00
xXPBSXxandClaude Sonnet 5.5 0e2252f638 fix(libkernel): accept flock on a directory descriptor on Windows
FreeBSD 11.4's sys_flock only requires a vnode descriptor, so flock on a directory descriptor succeeds. On Windows the call reached LockFileEx, which rejects a directory handle with ERROR_INVALID_PARAMETER, and flock_nid_postfix turned that into a runtime_error that aborted the process. A directory descriptor now returns 0 without taking a lock; the new guest_file_lock_directory case covers it and the debt entry records that no lock is held.

Co-Authored-By: Claude Sonnet 5.5 <[email protected]>
2026-10-21 13:35:39 +02:00
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
blu 04b1d6e5b5 Merge branch 'boykopovar:main' into pr/windows-reparse-non-link 2026-10-20 23:38:51 -07:00
xXPBSXxandClaude Sonnet 5.5 a2a77714d5 fix(libkernel): fail unlink and rmdir of a path that ends in a dot component with EINVAL
FreeBSD lookup() refuses "." and ".." as the last component of a DELETE
lookup with EINVAL (sys/kern/vfs_lookup.c:750-754 and 823-826), before the
unlink and rmdir checks run. unlink and sceKernelUnlink answered EPERM,
rmdir and sceKernelRmdir answered ENOTEMPTY for "..", and unlinkat without
AT_REMOVEDIR answered EPERM. Reuse the RenameDot check added for rename, so a
missing or non-directory parent still reports ENOENT or ENOTDIR first.

Co-Authored-By: Claude Sonnet 5.5 <[email protected]>
2026-10-21 08:01:47 +02: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 <[email protected]>
2026-10-20 20:54:15 -04:00
xXPBSXxandClaude Sonnet 5.5 c2b92498b5 fix(libkernel): look up the descriptor of read, write, pread and pwrite before their buffer and offset
A null buffer, or for pread and pwrite a negative offset, was answered with
EFAULT or EINVAL before the descriptor was looked at, so a descriptor that is not
open (EBADF) or a pipe (ESPIPE) was hidden. FreeBSD 11.4 sys_generic.c looks
the descriptor up first (kern_readv, kern_preadv: fget, then the seekable
check, then the offset) and only reaches the buffer when it copies. The check
runs only when the buffer or offset is invalid, so a normal transfer costs nothing.

Co-Authored-By: Claude Sonnet 5.5 <[email protected]>
2026-10-21 01:29:00 +02: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 e3d249fb05 fix(libkernel): report ELOOP from unlink, mkdir, rmdir and truncate on Windows
A path through a self-referencing symbolic link returned ENOTDIR, EIO or EINVAL on Windows; FreeBSD returns ELOOP. The failure paths now use the loop check that sceKernelStat uses.

Co-Authored-By: Claude Sonnet 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_01GtXavMkgCTCdmRpweviHcQ
2026-10-20 23:02:35 +02: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 <[email protected]>
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
Danigamer05 3f8f81e175 fix(libkernel): clamp Windows birth time when setting earlier timestamps 2026-10-20 21:42:41 +02: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 <[email protected]>
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 <[email protected]>
2026-10-20 20:20:20 +03:00
Retr0 2d1fa5aea5 fix(libkernel): report O_RDWR from F_GETFL on both ends of a pipe
FreeBSD 11's kern_pipe opens both ends with FREAD | FWRITE, so F_GETFL
reports O_RDWR on each. The host pipe ends are one-way, so the access
mode came back as O_RDONLY and O_WRONLY. Descriptors made by pipe() are
now marked in the guest descriptor table, the mark follows dup, dup2 and
F_DUPFD, and F_GETFL reports O_RDWR for them.
2026-10-20 19:04:22 +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
bluandClaude Opus 5.5 0ecef87c4c fix(libkernel): answer Windows reparse points that are not links
lstat and readlink threw NotImplemented for every Windows reparse point
other than a symbolic link or a drive junction. A tag without the name
surrogate bit (cloud files, deduplication) does not stand for another path,
so lstat now answers as stat does and readlink returns EINVAL, as FreeBSD
does for a file that is not a link and as CPython's os.lstat and os.readlink
do (bpo-37834). A name surrogate that is neither a symbolic link nor a
junction (a mounted volume, a WSL link) is reported as the reparse point
itself with the mode of its attributes, and readlink returns EINVAL.

The tests set reparse tags with FSCTL_SET_REPARSE_POINT, one without the
name surrogate bit and one with it. A compact /exe (WOF) file cannot serve
as the fixture: on Windows 11 24H2 the WOF filter hides the reparse point
from GetFileAttributesW and FileAttributeTagInfo alike. Windows refuses
every open of an unhandled tag without FILE_FLAG_OPEN_REPARSE_POINT, so the
test requires lstat to agree with stat rather than to succeed.

mashingaan's boykopovar/AnyPS5#6447 returned EINVAL for other reparse
points without the tag check.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Co-Authored-By: Claude Fable 5.1 <[email protected]>
2026-10-20 08:21:33 -07:00