Commit Graph
112 Commits
Author SHA1 Message Date
Dean 1075c38f07 Merge pull request #10799 from EagleBearerYS/feat/libkernel-sys-ampr-command-writers
feat(libkernel_sys): write the AMM commands and wait for their completion
2026-10-27 15:00:11 +13:00
Dean e6b0b00261 Merge pull request #11268 from camezaro-intc/feat/libkernel-sys-kld-queries
feat(libkernel_sys): implement kldfind, kldfirstmod, kldnext and kldunload
2026-10-27 11:06:13 +13:00
Dean 26bbcd1b48 Merge pull request #11288 from Gruzzberry/fix/fchmodat-follow-links
fix(libkernel_sys): fchmodat follows a symbolic link like chmod
2026-10-27 10:40:54 +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à 071552ef7f Merge pull request #10196 from orezraey/fix/libkernel-sys-pathconf-measured-ps5
fix(libkernel_sys): answer every pathconf name as the console's UFS mount does
2026-10-26 16:58:02 +01:00
camezaro-intc d4200caffc feat(libkernel_sys): implement kldfind, kldfirstmod, kldnext and kldunload 2026-10-25 23:58:13 -06:00
vaibhavindalia a385eee97c fix(libkernel_sys): validate descriptor first in fchown 2026-10-26 06:34:33 +05:30
Dean 10126f0c64 Merge pull request #9374 from cadenasynyster/test/windows-symlink-tests
test(libkernel): create the readlink and lutimes test links with CreateSymbolicLinkW on Windows
2026-10-26 13:30:41 +13:00
GruzzberryandClaude Sonnet 5.5 7322a3b9f8 fix(libkernel_sys): fchmodat follows a symbolic link like chmod
Co-Authored-By: Claude Sonnet 5.5 <[email protected]>
2026-10-25 23:50:43 +00: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 de84153592 fix(libkernel): treat Windows junctions in unlinkat like unlink and rmdir
Relative unlinkat skipped the junction path that absolute unlink and rmdir already use.
2026-10-26 00:02:20 +04:00
GruzzberryandClaude Opus 5.5 e6b07323de feat(libkernel_sys): implement settimeofday
FreeBSD 11.4's kern_settimeofday rejects a timeval with a microsecond
field outside 0 to 999999 or a negative second field with EINVAL before
changing anything, sets the clock from a valid timeval, and then stores
the timezone, which gettimeofday reports. settimeofday now checks the
timeval the same way and throws for a valid one, as clock_settime does,
because the host clock is not changed. A timezone given without a
timeval is stored and gettimeofday reports it instead of 0 and 0.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
2026-10-25 13:20:31 +00:00
ali zedan 2c5fcf6406 fix(kernel): safely copy guest path arguments 2026-10-25 08:28:09 +01:00
Dean 61fc572cee Merge pull request #10434 from Retr0G28/fix/linkat-directory-descriptor
fix(libkernel_sys): resolve linkat paths relative to a directory descriptor
2026-10-25 19:16:10 +13:00
Yunus Shaikh a666c83d20 fix(libkernel): accept every AMM id the queue has handed out in the completion wait
AmmSubmit_nid_no_patch stored the id _submit returned into lastSubmit
after _submit had released the queue's submit lock. Two submitters could
store out of order: the later id was stored first, then the earlier one
overwrote it, and a wait for the later, already submitted id failed with
ESRCH until the next submission.

The wait now checks the id against the AMM queue's own submitted count,
which _submit raises under the queue mutex before it returns, and
lastSubmit goes.

The test has four threads submit empty AMM buffers while another waits
on the newest id any of them has published, through
sceKernelWaitCommandBufferCompletion and
sceAmprAmmWaitCommandBufferCompletion, and requires every wait to
succeed.
2026-10-24 21:15:55 -07:00
Yunus Shaikh fe9d31edae test(libkernel_sys): pin the AMM writers' narrowing of a wide type
The map, map direct and mtype-protect writers take type as a 64-bit
value and store it in the record's 32-bit field. That matches
sceKernelWriteModifyMtypeProtectCommand and the libSceAmpr siblings,
whose type is 32 bits, but nothing checked it. A type with bit 32 set
now has to record the same bytes as the sibling given the low 32 bits,
and the debt entry says the console's handling of such a type is not
measured.
2026-10-24 19:49:48 -07:00
Yunus Shaikh afd5c4a20e feat(libkernel_sys): wait for AMM command buffer completion
sceKernelWaitCommandBufferCompletion waits for an AMM submission as
libSceAmpr's sceAmprAmmWaitCommandBufferCompletion does: 0 once the
submission has run, SCE_KERNEL_ERROR_ESRCH for an id that was never
submitted. The signature follows ampr_emu's libkernel hook targets,
where the libSceAmpr wait forwards to it.

guest_kernel_sys submits a map written by sceKernelWriteMapCommand,
waits for it and uses the mapped page, and checks ids 0 and past the
last submission.
2026-10-25 00:09:03 +00:00
Yunus Shaikh 92f7271cc6 feat(libkernel_sys): write the AMM map, unmap, remap and protection commands
The twelve AMM kernel writers record into a caller buffer the command
their libSceAmpr command buffer sibling appends, built with the shared
encoder: sceKernelWriteMapCommand, sceKernelWriteMapWithGpuMaskIdCommand,
sceKernelWriteMapDirectCommand, sceKernelWriteMapDirectWithGpuMaskIdCommand,
sceKernelWriteUnmapCommand, sceKernelWriteRemapCommand,
sceKernelWriteRemapWithGpuMaskIdCommand, sceKernelWriteMultiMapCommand,
sceKernelWriteMultiMapWithGpuMaskIdCommand,
sceKernelWriteModifyProtectCommand,
sceKernelWriteModifyProtectWithGpuMaskIdCommand and
sceKernelWriteModifyMtypeProtectWithGpuMaskIdCommand.

The signatures follow ampr_emu's libkernel hook targets: the sibling's
arguments as 64-bit values between the destination and the size output.
A null destination only reports the size and a null size output only
writes, as for sceKernelWriteModifyMtypeProtectCommand. Invalid ranges,
offsets and protections return the sibling's SCE_KERNEL_ERROR_EINVAL and
write nothing; protection or mask bits above 32 are rejected too.

guest_kernel_sys compares each writer with its sibling on valid and
invalid arguments, in both modes.
2026-10-25 00:07:53 +00:00
orezraeyandClaude Opus 5.5 88bf509e20 Merge main into fix/libkernel-sys-pathconf-measured-ps5
Co-Authored-By: Claude Opus 5.5 <[email protected]>
2026-10-24 20:04:44 -03:00
boykopovar f38d29fd08 refactor(sdk): add canonical headers for remaining libraries 2026-10-24 23:17:42 +03:00
Retr0 2d32e8bd85 fix(libkernel_sys): check the linkat source before resolving the target 2026-10-24 16:00:43 +03:00
Dean Galvin b0b291be0b Merge main into feat/libkernel-sys-underscore-openat 2026-10-24 21:42:59 +13:00
Dean dd04e33b38 Merge pull request #10363 from cadenasynyster/fix/windows-mkdirat-loop
fix(libkernel_sys): report ELOOP from mkdirat through a Windows symli…
2026-10-24 16:36:38 +13:00
Retr0 d44d5685eb fix(libkernel_sys): resolve linkat paths relative to a directory descriptor 2026-10-24 02:58:00 +03:00
Dean c675a415f2 Merge pull request #9103 from HQasper/claude/project-thread-w0s18y-chown
feat(libkernel_sys): implement chown, lchown, fchownat and linkat
2026-10-24 11:56:40 +13:00
orezraeyandClaude Opus 5.5 f32fd62397 Merge main into fix/libkernel-sys-pathconf-measured-ps5
Co-Authored-By: Claude Opus 5.5 <[email protected]>
2026-10-23 17:14:25 -03:00
cadenasynyster 0aef357591 fix(libkernel_sys): report ELOOP from mkdirat through a Windows symlink loop on a descriptor
On Windows, mkdirat with a directory descriptor and a relative path that goes through a symbolic link pointing to itself reported EIO. CreateDirectoryW fails with ERROR_CANT_RESOLVE_FILENAME for such a path, and the error mapping had no case for it, so it fell through to GuestEio. FreeBSD fails the lookup with ELOOP. The path form of mkdir and openat with the same descriptor already return ELOOP. ERROR_CANT_RESOLVE_FILENAME now gives ELOOP.

guest_kernel_sys gains a Windows check with a file-type and a directory-type self-loop: mkdirat through the loop returns ELOOP and mkdirat of the link itself still returns EEXIST. The check is skipped when the host denies symbolic link creation.
2026-10-23 21:17:33 +02:00
orezraeyandClaude Opus 5.5 9fc8d159bd fix(libkernel_sys): answer every pathconf name as the console's UFS mount does
Measured in a payload process on a PS5 (firmware 13.60) through libkernel_sys.sprx's pathconf: /system_data gives 65536 for the allocation, transfer and hole sizes, 16384 for the transfer alignment, 3 for _PC_ACL_PATH_MAX and 0 for the ACL and MAC flags, and EINVAL for _PC_MAX_CANON, _PC_MAX_INPUT, _PC_VDISABLE and _PC_ASYNC_IO, which used to throw.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
2026-10-23 09:37:36 -03:00
xXPBSXxandClaude Sonnet 5.5 01655d7219 fix(libkernel_sys): answer fpathconf for pipes and _PC_ASYNC_IO as FreeBSD does
kern_fpathconf answers _PC_ASYNC_IO with _POSIX_ASYNCHRONOUS_IO (200112) after the descriptor lookup, and a pipe or socket (no vnode) with PIPE_BUF for _PC_PIPE_BUF and EINVAL for every other name. Drop the unused File.hpp include and the duplicate KernelErrors.hpp include.

Co-Authored-By: Claude Sonnet 5.5 <[email protected]>
2026-10-23 13:44:46 +02:00
QuentinRemondandClaude Sonnet 5.5 07d3d6447a feat(libkernel_sys): implement fpathconf and _fpathconf
Co-Authored-By: Claude Sonnet 5.5 <[email protected]>
2026-10-23 13:44:43 +02:00
Dean 58ceeb8ed5 Merge pull request #9040 from YossiYad/feat/kernel-sys-workaround-process-type
feat(libkernel_sys): implement sceKernelTitleWorkaroundIsEnabled and sceKernelGetProcessType
2026-10-24 00:33:16 +13:00
Yossi Yadgar 4cbcf1fa23 test(libkernel_sys): cover the workaround bit limit and the process type pids 2026-10-23 11:12:16 +03:00
zaryabzip 6653dffe62 feat(libkernel_sys): implement scePthreadCondattrGetclock
Read the clock of a libkernel condition attribute, returning
SCE_KERNEL_ERROR_EINVAL for a null or destroyed attribute as
scePthreadCondattrSetclock does, after FreeBSD 11.4 libthr's
_pthread_condattr_getclock. A null clock pointer throws.
2026-10-23 12:17:02 +05:00
Claude 705f6e1580 feat(libkernel_sys): implement chown, lchown, fchownat and linkat
All four exports threw. The ownership calls follow fchown: owner and
group 0 and the unchanged value are accepted and any other value
throws. The path is looked up first with stat, lstat or fstatat, as
FreeBSD 11's kern_fchownat does, so a lookup error is returned before
the owner is checked. fchownat rejects flags other than
AT_SYMLINK_NOFOLLOW with EINVAL. linkat passes AT_FDCWD and absolute
paths to link and rejects flags other than AT_SYMLINK_FOLLOW with
EINVAL; a relative path with a directory descriptor and a symbolic
link source without AT_SYMLINK_FOLLOW throw. On Windows a symbolic
link source is detected with the file attributes, since libstdc++
there reports it as a regular file.

Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>
2026-10-23 06:34:32 +00:00
Dean 5d2eb583bf Merge pull request #9008 from verusferro/feat/libkernel-sys-fstat
feat(libkernel_sys): implement fstat
2026-10-23 13:58:39 +13:00
Dean f1db096084 Merge pull request #9200 from KernelPanicNT/feat/libkernel-sys-lchmod
feat(libkernel_sys): implement lchmod
2026-10-23 12:53:19 +13:00
Dean 287d539503 Merge pull request #9336 from ycbuzi/fix/libkernel-sys-link-follow-windows
fix(libkernel_sys): follow a symbolic link in link on Windows
2026-10-23 11:02:54 +13:00
cadenasynysterandClaude Opus 5.5 d22b6916a9 test(libkernel): create the readlink and lutimes test links with CreateSymbolicLinkW on Windows
MinGW's std::filesystem::create_symlink always fails on Windows, so the readlink checks in guest_kernel_sys and the lutimes checks in guest_file_timestamps skipped their link cases there. They now create the link with CreateSymbolicLinkW and SYMBOLIC_LINK_FLAG_ALLOW_UNPRIVILEGED_CREATE, as SaveDataFileWriteFailure.cpp does.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_01GtXavMkgCTCdmRpweviHcQ
2026-10-22 21:05:43 +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
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
xXPBSXxandClaude Sonnet 5.5 e1605dda52 fix(libkernel_sys): fail fchdir on a pipe or socket with EINVAL
FreeBSD 11.4's sys_fchdir resolves the descriptor with getvnode, which fails with EINVAL for a descriptor that has no vnode; only a vnode that is not a directory gives ENOTDIR from change_dir. fchdir returned ENOTDIR for a pipe or socket. A descriptor that is neither a vnode nor a random device now gets EINVAL; the debt entry records the order of the three errors.

Co-Authored-By: Claude Sonnet 5.5 <[email protected]>
2026-10-22 20:15:26 +02:00
Adrià 6671bb3a17 Merge pull request #8723 from xXPBSXx/fix/symlink-target-too-long
fix(libkernel_sys): fail symlink with ENAMETOOLONG for a target of 1024 bytes or more
2026-10-22 19:36:50 +02:00
bluandClaude Opus 5.5 37ba44ce4d test(libkernel_sys): link through a symbolic link loop on Windows
Co-Authored-By: Claude Opus 5.5 <[email protected]>
2026-10-22 07:54:57 -07:00
verusferro fa5fc8d5ac test(libkernel_sys): compare fstat with _fstat
fstat must fill the same FileStat as _fstat for an open descriptor, return EFAULT for a null buffer and EBADF for a closed or invalid descriptor, as the fstatfs check beside it does for _fstatfs.
2026-10-22 13:22:59 +03:00
blu 9897260c6e Merge branch 'boykopovar:main' into pr/windows-reparse-non-link 2026-10-21 19:08:16 -07:00
bluandClaude Opus 5.5 339d5c11d7 Merge upstream main into fix/libkernel-sys-link-follow-windows
Resolves the conflict with #8522 in link_nid_postfix: keep its ENOTDIR
return for a destination below a regular file and the Windows
symbolic-link follow after it.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
2026-10-21 12:13:24 -07:00
Adrià 38d3c0858a Merge pull request #8522 from xXPBSXx/fix/enotdir-through-file-4
fix(libkernel_sys): fail link, symlink, pathconf and fchmodat through a regular file with ENOTDIR
2026-10-21 20:47:51 +02:00
bluandClaude Opus 5.5 a293868561 fix(libkernel_sys): follow a symbolic link in link on Windows
link_nid_postfix decided whether to follow the source with
std::filesystem::is_symlink, which MinGW-w64's libstdc++ never reports for
a Windows symbolic link, so on Windows link made a hard link to the link
itself. Follow a reparse-point source to its final path with
GetFinalPathNameByHandleW instead, and run the link-through-a-link case of
guest_kernel_sys on Windows too.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
2026-10-21 11:00:06 -07:00
KernelPanicNT 0858e024fb feat(libkernel_sys): implement lchmod
lchmod forwards to fchmodat with AT_FDCWD and AT_SYMLINK_NOFOLLOW, as
FreeBSD 11.4's sys_lchmod does. On Linux and Windows, which cannot change
the mode of a symbolic link itself, a symbolic link throws instead of
succeeding without a change.
2026-10-21 14:54:33 +00:00
NikoandClaude Opus 5.5 673ff23c5b feat(libkernel_sys): export _openat
_openat now opens files as openat does. It reads the mode argument only
when O_CREAT is set, as openat and _open do, and calls openat with the
same descriptor, path, flags and mode, so it returns the same
descriptors and errors.

The PS5 3.20 libkernel_sys export list (DNNDHH/PS5-3.20_Libs) has
_openat, NID bGVEgWXy6dg, as well as openat (A8Yk5AhNDck). In FreeBSD
11.4, _openat is the openat system call stub (lib/libc/sys/Makefile.inc,
amd64/SYS.h) and only libthr's openat adds a cancellation point
(thr_syscalls.c). openat here is not a cancellation point, so
forwarding to it leaves _openat without one, as in FreeBSD.

The openat debt entry now names _openat and no longer says that
O_NOFOLLOW is ignored: open, and so openat, has returned EMLINK for
O_NOFOLLOW on a symbolic link since 9421484572.

The kernel_sys test opens a file through a directory descriptor with
_openat and reads it back, creates one with O_CREAT, O_EXCL and mode
0600, checks outside Windows that it has mode 0600, reopens it for
writing, and checks EEXIST, EINVAL, EBADF and ENOTDIR.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
2026-10-21 16:25:53 +02:00