Commit Graph
226 Commits
Author SHA1 Message Date
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
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 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
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 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 3cd6a37bfb fix(libkernel): fail open with O_CREAT and O_EXCL on a Windows symbolic link
FreeBSD 11.4's vn_open_cred does not follow the last component when
O_EXCL is set, so O_CREAT|O_EXCL on a symbolic link fails with EEXIST
whatever it points to. On Windows the host open followed a dangling link
and created its target. A reparse point in the last component now fails
O_CREAT|O_EXCL with EEXIST before the host open.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
2026-10-23 14:40:23 +01:00
GruzzberryandClaude Opus 5.5 4e5db13927 fix(libkernel): follow a Windows symbolic link in chmod
_wchmod changes the read-only attribute of the path it is given, so on
Windows chmod through a symbolic link changed the link and left the file
it names unchanged, and a dangling link succeeded. A reparse point is now
opened through its target and the target's path is changed, as FreeBSD
11.4's sys_chmod passes FOLLOW: a missing target fails with ENOENT and a
link loop with ELOOP. The path lookup of a handle moves out of
WindowsDescriptorPath_nid_no_patch so both use it.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
2026-10-23 14:40:15 +01:00
Dean 65f1d28e7d Merge pull request #9109 from Retr0G28/fix/alias-trailing-slash-windows
fix(libc): fail with ENOTDIR for a file named with a trailing slash on Windows
2026-10-24 02:08:03 +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
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
Retr0 0f3d4bc9ee fix(libc): fail with ENOTDIR for a file named with a trailing slash on Windows
FreeBSD 11.4's lookup() (sys/kern/vfs_lookup.c) fails with ENOTDIR when
a path with a trailing slash ends at something that is not a directory.
On Windows a mount alias dropped the slash, and the host calls do not
report ENOTDIR for "file\", so unlink, rename and open acted on the file
or failed with EINVAL. Guest path resolution now rejects an existing
non-directory named with a trailing slash with ENOTDIR on every host, and
a mount alias keeps the slash on Windows as it does on Linux and macOS.
2026-10-23 08:21:01 +03: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à 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