Skip to content

feat(libkernel_sys): implement POSIX file operations - #12687

Closed
xdCloudy wants to merge 1 commit into
boykopovar:mainfrom
xdCloudy:feat/libkernel-sys-posix-file-ops
Closed

xdCloudy wants to merge 1 commit into
boykopovar:mainfrom
xdCloudy:feat/libkernel-sys-posix-file-ops

Conversation

@xdCloudy

Copy link
Copy Markdown
Contributor

What

Implement the pwrite, futimesat and symlinkat exports in libkernel_sys. pwrite forwards to libkernel's existing positioned-write implementation. futimesat resolves paths with the supplied directory descriptor and uses libkernel's native timestamp implementation. symlinkat shares the existing symlink implementation and path resolution.

Firmware 13.60 evidence: pwrite at libkernel_sys VA 0x13630 passes the four POSIX arguments to syscall 476. FreeBSD 11.4 syscall definitions support the futimesat and symlinkat prototypes. The current symlink limitations remain: absolute targets and targets containing .. throw as unimplemented. Directory-relative host paths also do not model guest aliases or constrain .. to the guest root. Console results remain unverified; details are recorded in docs/dev/debt/libkernel_sys.md.

Tested

Windows with WinLibs GCC 15.2: configured the full project, built guest_kernel_sys_tests, and passed ctest --test-dir build-win -R '^guest_kernel_sys$' --output-on-failure. The test covers all three exports and error cases.

python3 tools/check_conventions.py --base origin/main passed. python3 tools/pr_overlap.py --branch feat/libkernel-sys-posix-file-ops scanned 1,410 open PRs and found no overlap. Linux was not tested.

Checklist

  • Based on current main; no other open PR implements the same functions
  • One topic per PR; follow-ups go in a new PR
  • No comments in code except technical debt
  • Unimplemented paths throw (NotImplemented_nid_no_patch); silent stubs are listed under Silent stubs in their library's technical debt file
  • No notes, investigation .md files or images added to the repository (attach them to this PR)
  • New third-party code is a submodule built from source
  • Generic behaviour, not specific to one title
  • Depends on: none
  • Fixes: none
  • Unblocks: none
  • GPUs tested: n/a
  • AI-assisted: yes

@github-actions

Copy link
Copy Markdown

Progress report (3a2b919 → e4044fe)

📈 System libraries: 45.92% (+0.01%, +2 implemented functions)

✅ 2 implemented
Library Name
libkernel_sys futimesat_nid_postfix
libkernel_sys pwrite_nid_postfix

Changed libraries (implemented exports)

Library Before After Change
libkernel_sys 116/514 (22.57%) 118/514 (22.96%) +0.39 pp

@adriadam10 adriadam10 self-assigned this Oct 29, 2026
@rooklz

rooklz commented Oct 29, 2026

Copy link
Copy Markdown
Contributor

The checklist says no other open PR implements these functions, but two older open PRs do:

I ran python3 tools/pr_overlap.py --branch locally on this head (e4044fef46). It reports Same exports pwrite for #9019 and futimesat/symlink/symlinkat for #9161, plus conflicting lines in Export.Discovery.cpp L68-72/L2154-2158, Export.cpp L772-788/L817 and Api.hpp L102/L547. git merge-tree of this head with #9161 conflicts. Against main 3a2b919816 it is clean. I didn't build or run anything; this is a source comparison only.

Suggestion: drop the three exports from this PR, or close it and offer the parts #9161 lacks there. The readlinkat round-trip, the second-symlinkat EEXIST row and the missing-parent ENOENT row look like test rows #9161 could take. One behaviour difference to settle if they move over: here ENAMETOOLONG is checked only on the descriptor-relative branch (inside ResolveAtPath), but #9161 checks it before choosing a branch, so AT_FDCWD and absolute paths are covered too.

@adriadam10

Copy link
Copy Markdown
Collaborator

Thanks for the work here. Closing because the whole PR duplicates older open PRs:

tools/pr_overlap.py reports the same exports for both, and this head conflicts with #9161 in Export.Discovery.cpp, Export.cpp and Api.hpp, so the overlap can't be removed from this PR.

Some of your test rows look useful for #9161 (readlinkat round-trip, second symlinkat giving EEXIST, missing parent giving ENOENT), and ENAMETOOLONG should be checked before choosing the descriptor-relative branch, as #9161 does. Feel free to offer them there, and to reopen this if those PRs are dropped.

@adriadam10 adriadam10 closed this Oct 29, 2026
@github-actions

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
PR 9019 pwrite
PR 9161 core/libs/prx/libkernel_sys/Export.Discovery.cpp L68-72, L2154-2158
core/libs/prx/libkernel_sys/Export.cpp L772-776, L787-788, L817
core/libs/prx/libkernel_sys/include/Api.hpp L102, L547
futimesat
symlink
symlinkat
PR 9162 docs/dev/debt/libkernel_sys.md L14
PR 10332 core/libs/tests/GuestKernelSys.cpp L901
PR 10625 core/libs/prx/libkernel_sys/Export.cpp L781-788

Some comparisons could not be completed because a pull request conflicts with the base branch. Review these shared files manually before concluding that there is no overlap.

Pull request Shared files not compared
PR 5021 core/libs/prx/libkernel/File/src/Stdio.cpp
core/libs/prx/libkernel_sys/Export.cpp
PR 6936 core/libs/prx/libkernel/File/src/Stdio.cpp
PR 7088 core/libs/prx/libkernel/File/include/File.hpp
PR 7121 core/libs/prx/libkernel/File/src/Stdio.cpp
PR 7447 core/libs/prx/libkernel/File/src/Stdio.cpp
PR 9019 core/libs/prx/libkernel/File/include/File.hpp
core/libs/prx/libkernel/File/src/Stdio.cpp
core/libs/prx/libkernel_sys/Export.Discovery.cpp
core/libs/prx/libkernel_sys/Export.cpp
core/libs/prx/libkernel_sys/include/Api.hpp
docs/dev/debt/libkernel_sys.md
PR 9097 core/libs/prx/libkernel_sys/Export.Discovery.cpp
core/libs/prx/libkernel_sys/Export.cpp
core/libs/prx/libkernel_sys/include/Api.hpp
core/libs/tests/GuestKernelSys.cpp
PR 9156 core/libs/prx/libkernel_sys/Export.Discovery.cpp
PR 9242 core/libs/prx/libkernel_sys/Export.Discovery.cpp
core/libs/prx/libkernel_sys/include/Api.hpp
PR 9293 core/libs/prx/libkernel/File/src/Stdio.cpp
core/libs/prx/libkernel_sys/Export.Discovery.cpp
PR 9297 core/libs/prx/libkernel/File/src/Stdio.cpp
core/libs/prx/libkernel_sys/Export.Discovery.cpp
docs/dev/debt/libkernel_sys.md
PR 9302 core/libs/prx/libkernel/File/src/Stdio.cpp
core/libs/prx/libkernel_sys/Export.Discovery.cpp
docs/dev/debt/libkernel_sys.md
PR 9383 core/libs/prx/libkernel_sys/Export.Discovery.cpp
PR 9389 core/libs/prx/libkernel_sys/Export.Discovery.cpp
core/libs/prx/libkernel_sys/Export.cpp
PR 10657 core/libs/prx/libkernel_sys/Export.Discovery.cpp
docs/dev/debt/libkernel_sys.md
PR 11031 core/libs/prx/libkernel_sys/Export.Discovery.cpp
core/libs/prx/libkernel_sys/Export.cpp
core/libs/prx/libkernel_sys/include/Api.hpp
core/libs/tests/GuestKernelSys.cpp
docs/dev/debt/libkernel_sys.md
PR 11034 core/libs/prx/libkernel_sys/Export.Discovery.cpp
core/libs/prx/libkernel_sys/Export.cpp
core/libs/prx/libkernel_sys/include/Api.hpp
core/libs/tests/GuestKernelSys.cpp
docs/dev/debt/libkernel_sys.md
PR 11212 core/libs/prx/libkernel_sys/Export.Discovery.cpp
docs/dev/debt/libkernel_sys.md
PR 11216 core/libs/prx/libkernel_sys/Export.Discovery.cpp
core/libs/prx/libkernel_sys/Export.cpp
core/libs/prx/libkernel_sys/include/Api.hpp
core/libs/tests/GuestKernelSys.cpp
docs/dev/debt/libkernel_sys.md
PR 11625 core/libs/prx/libkernel/File/src/Stdio.cpp
PR 11969 core/libs/prx/libkernel/File/include/File.hpp
core/libs/prx/libkernel/File/src/Stdio.cpp

@xdCloudy

Copy link
Copy Markdown
Contributor Author

@rooklz, @adriadam10 Thanks for identifying the duplicate exports. I agree with the closure: #12687’s futimesat, symlinkat and pwrite work duplicated #9161/#9019, so I have not reopened or reintroduced those implementations. I checked the current #9161 test patch: it still lacks the suggested readlinkat round-trip, duplicate-symlinkat EEXIST, and missing-parent ENOENT cases; the reviewer’s long-path concern is already handled before the path branch is selected. I have not added a test-only PR against the still-unmerged implementation.

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