Skip to content

feat(libkernel): add clock_settime with FreeBSD argument checks - #5183

Merged
adriadam10 merged 1 commit into
boykopovar:mainfrom
p3n1cillin:claude/carry-clock-settime
Oct 13, 2026
Merged

adriadam10 merged 1 commit into
boykopovar:mainfrom
p3n1cillin:claude/carry-clock-settime

Conversation

@p3n1cillin

@p3n1cillin p3n1cillin commented Oct 13, 2026 •

Copy link
Copy Markdown

What

Carries @nabilfp's clock_settime commit from nabilfp:feat/libkernel-chroot-clock-settime (53485d5a5, author kept), which they closed #4890 to free their PR slot and offered for anyone to carry. It follows FreeBSD 11.4 sys_clock_settime/kern_clock_settime for a privileged caller: EFAULT for a null time, and EINVAL for any clock other than CLOCK_REALTIME and for a negative tv_sec or a tv_nsec outside 0 to 999999999. A valid CLOCK_REALTIME request throws, since the host clock must not be set. The details are in the commit message and the debt entry.

Title evidence: PS5MC (PPSA99420, Kodi 22, catalog release) imports clock_settime (d7nUj1LOdDU). On current main with the open #4379 (chflags), #4374 (getpriority) and #4383 (sigpending), tools/import_audit.py lists it as the title's only absent import, so the loader stops on it:

FAIL: unresolved ELF import d7nUj1LOdDU from libkernel.prx

With this commit too, PS5MC loads and runs into Kodi's start-up, which then needs #5184, #5185 and #5186.

Tested

Checklist

🤖 Generated with Claude Code

PS5MC (PPSA99420, Kodi 22) imports clock_settime (d7nUj1LOdDU) from
libkernel.prx, one reference, after sigwaitinfo in its import order.
Predicted stop once the imports ahead of it are covered (not a run):

  FAIL: unresolved ELF import d7nUj1LOdDU from libkernel.prx

The NID is computed with tools/nid_names.py and matches aerolib.

Follows FreeBSD 11.4 sys/kern/kern_time.c sys_clock_settime and
kern_clock_settime (8c639945a44588f6cfdddfb057bb5aad88735da0) for a
root caller: EFAULT for a null time (copyin), EINVAL for any clock but
CLOCK_REALTIME and for a negative tv_sec or a tv_nsec outside 0 to
999999999. A valid CLOCK_REALTIME request throws with the requested
time named, since the host clock must not be set and no guest clock
offset is kept.

Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>

Co-authored-by: David <david@example.com>
@github-actions

Copy link
Copy Markdown

Progress report (91ed4ce → ae9978a)

➖ System libraries: 88.04% (+0.0%, +1 implemented functions)

✅ 1 implemented
Library Name
libkernel clock_settime_nid_postfix

@adriadam10

Copy link
Copy Markdown
Collaborator

Checked against FreeBSD 11.4 sys_clock_settime/kern_clock_settime: EFAULT for a null time, EINVAL for non-CLOCK_REALTIME, negative tv_sec or out-of-range tv_nsec, all match; a valid request throws and the debt entry documents it. Built and ran libs + libkernel ctest (146/146), guest_freebsd_clocks fails to link without the change and passes with it. Merging once the full build is green.

@github-actions

github-actions Bot commented Oct 13, 2026 •

Copy link
Copy Markdown

Other open pull requests touch the same code. Merging one will break the other, or both implement the same thing. If this one builds on them, list them in Depends on.

Pull request Conflicting files (lines on main) Same exports Same new files
#4374 docs/dev/debt/libkernel.md L168
#4379 docs/dev/debt/libkernel.md L168
#4725 docs/dev/debt/libkernel.md L168
#4968 docs/dev/debt/libkernel.md L168
#5096 core/libs/tests/GuestFreebsdClocks.cpp L6, L207, L210-211

@adriadam10
adriadam10 merged commit ef42c5f into boykopovar:main Oct 13, 2026
10 checks passed
@p3n1cillin

Copy link
Copy Markdown
Author

Linux run: Ubuntu in WSL2, GCC 15.2.0, Ninja Release, BUILD_TESTING=ON, full build of a local test head 838d4fd85. That head is main 3faa9cb40 with this PR, my other open libkernel PRs (#5013, #5061, #5078, #5098, #5183–#5187, #5191) and the open PRs the catalog titles need (#4377, #4379, #4374, #4383, #3798, #4467, #4863, #4105). All 123 libkernel and 69 libc tests pass, including guest_system_configuration, guest_getrlimit, guest_kernel_fcntl, guest_freebsd_clocks, guest_kernel_sys and guest_filesystem. Not built alone on Linux; no title run on Linux.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants