NativeLseek seeked first and only checked for a pipe when the host seek
succeeded, so a negative offset reached the guest as EINVAL from
_lseeki64. FreeBSD 11.4's kern_lseek returns ESPIPE for any seek on a
descriptor without DFLAG_SEEKABLE, so the pipe check now comes first.
Co-Authored-By: Claude Opus 5.5 <[email protected]>
rmdir followed the junction and reported ENOTEMPTY, and unlink treated it as a real directory, so a junction to a non-empty folder could not be removed.
std::filesystem::status does not follow a Windows symbolic link under
MinGW, so the lookup chflags makes saw a link whose target is missing as
an existing file and returned 0. A reparse point in the last component
is now looked up through the target with the guest stat, as FreeBSD 11.4's
namei follows it: a missing target gives ENOENT, and a trailing slash
after a link to a file gives ENOTDIR.
Co-Authored-By: Claude Opus 5.5 <[email protected]>
Destroying a std::optional is noexcept in libstdc++, so a failing sync in
the guard's destructor ended the process with std::terminate instead of
raising the sync error. The Windows writev and pwritev path now uses a
plain guard, which does nothing for -1. The debt line names the synced
write calls and leaves out the AIO writes.
FreeBSD's F_SETFL may change O_FSYNC (FCNTLFLAGS), and vn_write then
writes with IO_SYNC. The flag now lives in the status table, and the
write entry points sync a regular file after the write while it is set.
Main's #9618 has lstat fill a local FileStat and copy it out to the guest.
The merge keeps that and this branch's module lookup in the same call, so an
original .prx name still resolves to its relinked .guest.prx.
fcntl(fd, F_DUPFD, min) with min at or above RLIMIT_NOFILE duplicated the
descriptor repeatedly until the CRT table was full and then failed with
EMFILE, after opening thousands of descriptors. FreeBSD checks the minimum
first: kern_dup returns EINVAL for FDDUP_FCNTL when new < 0 or
new >= maxfd (sys/kern/kern_descrip.c:836-840). Linux already answers
EINVAL through the host fcntl. Check the minimum against the guest
RLIMIT_NOFILE before the Windows loop.
Co-Authored-By: Claude Sonnet 5.5 <[email protected]>
fstat, _fstat, sceKernelFstat, stat, lstat, sceKernelStat and _fstatfs
filled the caller's struct in place, or copied into it after a check that
only tests for null, so a pointer into unmapped memory crashed the host.
Fill a local struct and copy it out with a checked write that fails with
EFAULT. FreeBSD 11.4 does the same after the lookup has succeeded:
copyout(&ub, uap->sb) in sys_fstat (sys/kern/kern_descrip.c:1328),
copyout(&sb, uap->ub) in sys_stat (sys/kern/vfs_syscalls.c:2066) and
copyout(sfp, uap->buf) in sys_fstatfs (sys/kern/vfs_syscalls.c:337).
Co-Authored-By: Claude Sonnet 5.5 <[email protected]>
Darwin opens an existing directory for O_CREAT without O_EXCL, while FreeBSD
and Linux fail with EISDIR. Close the descriptor and report EISDIR so
sceKernelOpen and open behave the same on every host.
Co-authored-by: Himansh Raj <[email protected]>
Co-Authored-By: Claude Sonnet 5.5 <[email protected]>
macOS pwrite and pwritev write at the given offset even when the
descriptor was opened with O_APPEND. FreeBSD's vn_write appends to an
O_APPEND regular file whatever the offset and leaves the file offset
unchanged, and Linux pwrite appends too. On macOS, sceKernelPwrite,
pwrite, sceKernelPwritev, pwritev and the AIO write commands now append
such writes with writev and restore the file offset, as #8359 does on
Windows.
Co-authored-by: Himansh Raj <[email protected]>
Co-Authored-By: Claude Opus 5.5 <[email protected]>