Commit Graph
235 Commits
Author SHA1 Message Date
Dean 16bc34bfc8 Merge pull request #10620 from Retr0G28/fix/freopen-random-device
fix(libc): reopen a stream onto /dev/random or /dev/urandom with freopen
2026-11-02 23:23:29 +13:00
Dean bf6df519a3 Merge pull request #9661 from Gruzzberry/fix/rename-onto-directory-link
fix(libc): rename onto or from a Windows directory symbolic link like a link
2026-11-02 20:58:03 +13:00
Dean c51c471250 Merge pull request #12922 from ntamas94/fix/ps4-dir-blksize
fix(libkernel): report a 64 KiB st_blksize for directories
2026-11-02 00:25:59 +13:00
ntamas94andClaude Opus 5.5 144d17f220 test(libkernel): compare a regular file's st_blksize to the host value
CopyNativeStat keeps the host block size for regular files on POSIX, so a
64 KiB host (ZFS, some network mounts) makes the st_blksize != 0x10000
assertion fail with correct production code. Compare against the host's
actual st_blksize (POSIX) or the 512 Windows convention, which still
catches an unconditional directory-size assignment spilling onto files.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
2026-11-01 08:02:30 +01:00
ntamas94 249d8cc371 Merge remote-tracking branch 'origin/main' into fix/ps4-dir-blksize 2026-11-01 07:53:32 +01:00
AdriàandClaude Sonnet 5.5 1f236c96f3 test(libkernel): drop UF_READONLY throw assertions from chflags tests
Co-Authored-By: Claude Sonnet 5.5 <[email protected]>
2026-11-01 07:51:44 +01:00
GruzzberryandClaude Sonnet 5.5 2d1342cf31 fix(libkernel): fail chflags and fchflags with EPERM when a system flag changes
FreeBSD 11.4 ufs_setattr refuses a change of any SF_* flag to a caller without PRIV_VFS_SYSFLAGS, which prison_priv_check denies a jailed root without allow.chflags. Under the credential model agreed on #11216 every SF_* flag now fails with EPERM, after the EOPNOTSUPP check for unknown bits, instead of throwing.

Co-Authored-By: Claude Sonnet 5.5 <[email protected]>
2026-11-01 07:51:40 +01:00
Dean 9f6d3b910c Merge pull request #7202 from MarcZX10/codex/lstat-long-windows-path-7201
fix(libkernel): support lstat on long Windows paths
2026-11-01 19:19:37 +13:00
Retr0 9586a81211 Merge remote-tracking branch 'origin/main' into fix/freopen-random-device
# Conflicts:
#	docs/dev/debt/libc.md
2026-10-31 02:12:35 +02:00
Adrià 48773cf610 Merge pull request #13443 from DeveshB-1/fix/write-throttling-efault
fix(libkernel): return EFAULT from sceKernelWriteThrottlingStatus for an unwritable store
2026-10-30 22:48:12 +01:00
bunbeans2-archandClaude Opus 5.5 6878d1be40 fix(tests): open scratch streams under a Unicode TEMP on Windows
On Windows, std::tmpfile() returns NULL with errno 22 when %TEMP%
contains a character outside the ANSI code page, where GetTempPathA
returns '?' in its place. Fifteen tests that capture output through it
aborted. TemporaryFile::Open() opens a unique delete-on-close file under
temp_directory_path() with _wfopen; other hosts keep std::tmpfile().

Part of #13083

Co-Authored-By: Claude Opus 5.5 <[email protected]>
2026-10-30 18:21:00 +01:00
DeveshB-1 5553cbd447 fix(libkernel): return EFAULT from sceKernelWriteThrottlingStatus for an unwritable store 2026-10-30 20:14:03 +05:30
ntamas94andClaude Opus 5.5 8604e227c9 test(libkernel): check that a regular file keeps its st_blksize
As rooklz suggested in review: a row for a regular file next to the
directory rows, so a change that reports 0x10000 for every stat fails.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
2026-10-29 18:07:23 +01:00
ntamas94andClaude Opus 5.5 da7581eec4 fix(libkernel): report a 64 KiB st_blksize for directories
A PS4 Pro (firmware 10.71) reports st_blksize 0x10000 from stat and fstat
for /app0, its subdirectories and the system library directory. Titles
size one getdents buffer from it: CUSA18659's CryPak reads st_blksize +
264 bytes once, so the 512 reported here cut its shader directory listing
short. Directories, app0.zar ones included, now report 0x10000; /data
directories (0x8000 on the console) and files are recorded as debt.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
2026-10-29 15:17:34 +01:00
Dean 1b75a2de11 Merge pull request #10433 from Retr0G28/fix/freopen-directory
fix(libc): open a directory with freopen in a read mode on Windows
2026-10-30 02:59:56 +13:00
Adrià 38a13a7512 Merge pull request #12103 from JJenkx/windows/libc-rename-dangling-link
fix(libc): rename a dangling Windows symbolic link
2026-10-29 12:57:29 +01:00
Retr0 e465f47d92 Merge remote-tracking branch 'origin/main' into fix/freopen-random-device
# Conflicts:
#	docs/dev/debt/libc.md
2026-10-29 01:28:54 +02:00
Retr0 e7798c0e4b Merge remote-tracking branch 'origin/main' into fix/freopen-directory
# Conflicts:
#	docs/dev/debt/libc.md
2026-10-29 01:22:27 +02:00
cadenasynysterandClaude Sonnet 5.5 b28edaf954 fix(libkernel): rmdir and unlink on a Windows directory symbolic link
On Windows, std::filesystem::symlink_status and is_symlink report a directory symbolic link as a plain directory, so rmdir removed the link instead of failing with ENOTDIR (20) and unlink failed with EPERM (1) instead of removing it, unlike FreeBSD. Detect the symlink reparse tag with FindFirstFileW: rmdir returns ENOTDIR, unlink removes the link with RemoveDirectoryW. Junctions and volume mounts keep their previous behaviour. Enable the directory-link and dangling-link blocks of guest_filesystem on Windows (created with CreateSymbolicLinkW).

AI-assisted: yes

Co-Authored-By: Claude Sonnet 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_01GtXavMkgCTCdmRpweviHcQ
2026-10-28 13:41:23 +01:00
B-HowellandClaude Opus 5.5 fe7a71c1ea fix(libkernel): classify the rmdir path with lstat so links give ENOTDIR on Windows
sceKernelRmdir decided whether the last component was a symbolic link with
std::filesystem::is_symlink, which follows the link with WinLibs libstdc++ on
Windows. A dangling or self-referencing file link then looked missing on
Windows 10 (ENOENT instead of ENOTDIR), and a directory link to an empty
directory looked like that directory, so rmdir removed the link and
returned 0. The last component is now classified with FillLinkStat, the
same lstat path lstat_nid_postfix uses, matching FreeBSD 11 kern_rmdirat,
which returns ENOTDIR for any non-directory vnode found without following
the last link.

Fixes #12079

Co-Authored-By: Claude Opus 5.5 <[email protected]>
2026-10-28 03:10:08 -04:00
JJenkxandClaude Opus 5.5 2c0e7e2aec fix(libc): rename a dangling Windows symbolic link
rename looked up its source and destination with
std::filesystem::symlink_status, which MinGW's libstdc++ answers by
following the link, so a dangling or looping link counted as missing
and rename failed with ENOENT. FreeBSD renames the link itself. A path
whose own attributes are a reparse point is now treated as a symbolic
link when symlink_status reports it missing.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
2026-10-27 16:35:53 -04:00
Dean 2f0a0071f5 Merge pull request #10251 from orezraey/docs/libc-fopen-directory-measured-ps5
docs(libc): record fopen and freopen of directories as measured on a PS5
2026-10-27 20:52:15 +13:00
Dean f423468b43 Merge pull request #11339 from harisibrar1/fix/lseek-pipe-negative-espipe
fix(libkernel): fail lseek on a pipe with ESPIPE for a negative offset on Windows
2026-10-27 11:08:02 +13:00
Dean fd75cc804d Merge pull request #9095 from mazen320/fix/unlinkat-windows-junction
fix(libkernel): treat Windows junctions in unlinkat like unlink and rmdir
2026-10-27 10:29:02 +13:00
Retr0 2a999da21f test(libc): drop the freopen check that pins a write mode on a random device to throwing 2026-10-26 21:07:38 +02:00
Adrià FranchandClaude Sonnet 5.5 654eadd7f5 merge: sync archive directories with main
Co-Authored-By: Claude Sonnet 5.5 <[email protected]>
2026-10-26 10:50:37 +01:00
Dean 7109f36927 Merge pull request #8696 from cadenasynyster/fix/win-rename-loop
fix(libc): report ELOOP from rename through a Windows symlink loop
2026-10-26 20:36:42 +13:00
harisibrar1andClaude Opus 5.5 60b5b9b7ab fix(libkernel): fail lseek on a pipe with ESPIPE for a negative offset on Windows
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]>
2026-10-26 00:19:36 -04:00
qpavyros 9b2dd8dce9 merge: sync archive follow-up with main 2026-10-26 01:53:02 +02:00
Adrià efd368fec6 Merge pull request #9469 from Gruzzberry/fix/chflags-dangling-link
fix(libkernel): fail chflags through a dangling Windows symbolic link with ENOENT
2026-10-26 00:13:50 +01:00
qpavyros 6105be4431 merge: sync archive directories with main 2026-10-26 01:10:12 +02:00
Adrià 065d5dba6a Merge pull request #9502 from GitamarT045T3R/fix/libkernel-fchmod-pipe
fix(libkernel): fail fchmod on a pipe with EINVAL like FreeBSD
2026-10-25 21:03:23 +01:00
Maz 33f03f45eb fix(libkernel): guard unlinkat junction path with DIRECTORY
Match the AT_REMOVEDIR and rmdir sites so file reparse points stay on the old unlink path. Cover file symlink unlinkat on Windows and point the debt at the drive-target consumers.
2026-10-26 00:02:20 +04:00
Maz f6c24fc271 fix(libkernel): remove a Windows directory junction without emptying its target
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.
2026-10-26 00:02:20 +04:00
Adrià FranchandClaude Sonnet 5.5 a5c72e02c4 fix(libkernel): rename the chflags link test locals that clash in main()
Co-Authored-By: Claude Sonnet 5.5 <[email protected]>
2026-10-25 19:58:17 +01:00
GruzzberryandClaude Opus 5.5 720cf7e296 fix(libkernel): fail chflags through a dangling Windows symbolic link with ENOENT
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]>
2026-10-25 19:58:17 +01:00
Adrià 506991994d Merge pull request #9496 from Gruzzberry/fix/open-excl-symbolic-link
fix(libkernel): fail open with O_CREAT and O_EXCL on a Windows symbolic link
2026-10-25 18:35:57 +01:00
Adrià 2e1c72239b Merge pull request #9487 from Gruzzberry/fix/chmod-symbolic-link
fix(libkernel): follow a Windows symbolic link in chmod
2026-10-25 18:25:24 +01:00
Yunus Shaikh 20ae347f6a Merge main into fix/libkernel-lstat-relinked-prx
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.
2026-10-25 03:56:39 -07:00
MarcZX100 353077ef56 fix(libkernel): support lstat on long Windows paths 2026-10-25 04:56:53 +00:00
boykopovar f38d29fd08 refactor(sdk): add canonical headers for remaining libraries 2026-10-24 23:17:42 +03:00
qpavyros 0a64d23bdf feat(libkernel): enumerate archived app directories
Squashed onto current main, resolving the fchflags/fstatfs conflict with the kqueue guards.
2026-10-24 20:18:05 +02:00
Retr0 fbf7004b7d fix(libc): reopen a stream onto /dev/random or /dev/urandom with freopen 2026-10-24 16:15:45 +03:00
Retr0 1e32d23a9c test(libc): check the descriptor freopen leaves after a directory 2026-10-24 16:07:22 +03:00
Retr0 4080a15f22 fix(libc): open a directory with freopen in a read mode on Windows 2026-10-24 02:56:49 +03:00
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
cadenasynyster 0a238f9e49 fix(libc): keep a rename source lookup error ahead of a destination loop
On Windows, rename converted ENOENT or ENOTDIR to ELOOP when either parent directory was below a symbolic link loop. A missing source, or a source below a non-directory, paired with a destination through a loop then reported ELOOP. FreeBSD 11.4 kern_renameat returns the failed source lookup before it examines the destination. A loop below the source still gives ELOOP, and a loop below the destination gives ELOOP only when the source lookup succeeded.

guest_filesystem gains the missing-source and non-directory-source-prefix cases paired with a looping destination, for rename and sceKernelRename.
2026-10-23 21:26:38 +02:00
orezraeyandClaude Opus 5.5 85caaefe6d test(libc): check the fopen modes measured on a PS5
Co-Authored-By: Claude Opus 5.5 <[email protected]>
2026-10-23 12:39:56 -03:00
GruzzberryandClaude Opus 5.5 d1b9c7c2f4 test(libc): clean up the rename link cases where each path still exists
On success the moved link and the replaced link are already gone, so
only the link now named rename-occupied.txt is removed there; the links
and files a skipped run may leave behind are removed in that branch.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
2026-10-23 14:40:31 +01:00
GruzzberryandClaude Opus 5.5 ece70592d7 test(libc): cover rename onto and from a Windows directory junction
The rename change recognises junctions by IO_REPARSE_TAG_MOUNT_POINT but
the test only made directory symbolic links. The same three calls now
also run on two junctions made with mklink /J, which needs no Developer
Mode, so the cases run where symbolic links cannot be created.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
2026-10-23 14:40:31 +01:00