Skip to content

feat(libkernel): carry chflags implementation - #4379

Merged
oneandonlydean merged 4 commits into
boykopovar:mainfrom
MarcZX10:codex/carry-chflags-3632
Oct 13, 2026
Merged

oneandonlydean merged 4 commits into
boykopovar:mainfrom
MarcZX10:codex/carry-chflags-3632

Conversation

@MarcZX10

@MarcZX10 MarcZX10 commented Oct 12, 2026 •

Copy link
Copy Markdown
Contributor

What

Carries the chflags implementation from issue #3632. It validates the guest path, reports missing and unsupported flag errors, rejects SF_SNAPSHOT, and throws an explicit unsupported-host error when asked to set recognized BSD file flags that the host does not store.

PPSA99420 reaches the chflags import on current main now that its earlier stops have merged (issue #1578). This PR carries only chflags; the other calls from #3632 are separate changes.

Tested

  • Before this current-main rebase, Linux Release GCC 12.2 built guest_filesystem_tests; CTest guest_filesystem passed 1/1.
  • Conventions and git diff --check passed on that earlier head.
  • The current-main rebase has not been built or tested locally. CI/reviewer validation should rerun on this head.

Checklist

@github-actions

github-actions Bot commented Oct 12, 2026 •

Copy link
Copy Markdown

Progress report (0aa4cb1 → b6a10e9)

📈 System libraries: 88.16% (+0.01%, +1 implemented functions)

✅ 1 implemented
Library Name
libkernel chflags_nid_postfix

@MarcZX10

Copy link
Copy Markdown
Contributor Author

The PR description was corrected to use the template section headings (### What, ### Tested, ### Checklist) and now passes the local conventions checker. The current hosted conventions result reflects the earlier body. Posting this update to trigger a fresh PR check against the corrected description.

@reyani-dev

Copy link
Copy Markdown
Contributor

Title path for this one, from a Windows run (catalog build, main e013f8c + #3980 + #3893 + #3781):

  • PS5MC (PPSA99420) stops at FAIL: unresolved ELF import ixrw0h2tWuI from libkernel.prx (chflags). With a chflags export added, its next stop is miQ1wVwSexE (getpriority, feat(libkernel): implement getpriority for the guest process #4374).
  • The only call site (guest 0x3C9100A) is the bundled CPython's os.chflags (chflags($module, /, path, flags, follow_symlinks=True); the lchflags branch sits next to it). CPython's shutil.copystat calls os.chflags(dst, st.st_flags) when both exist, so any shutil.copy2/copytree in a Kodi add-on reaches it.
  • NativeStat zero-initialises FileStat (*sb = FileStat{};) and nothing sets st_flags, so that call is always chflags(path, 0). That's the path this PR answers with 0 after the lookup.

@blawesom

Copy link
Copy Markdown
Contributor

Rebase handoff — rebased onto current main, authorship unchanged.

One conflict in Stdio.cpp, resolved by keeping both sides: main's newer File::DuplicateFrom (the guest-socket descriptor duplication) and this PR's LookupError + chflags tables are independent additions at the same spot. TechnicalDebt.md unioned.

Verified on Linux (CachyOS, kernel 7.2.9, GCC 16.2.1, Ninja, Release, BUILD_TESTING=ON, AMD RX 9070 XT / RADV):

  • builds; tools/check_conventions.py --base origin/main passes
  • full suite: 955/955 passed

To pick it up:

git fetch https://github.com/blawesom/AnyPS5 rebase/4379
git checkout <your branch>
git merge --ff-only FETCH_HEAD

Head is fdfdc9435.

@MarcZX10
MarcZX10 force-pushed the codex/carry-chflags-3632 branch from 29346d8 to 30d54e5 Compare October 12, 2026 16:09
@github-actions github-actions Bot removed the needs rebase Conflicts with main, rebase needed label Oct 12, 2026
@github-actions github-actions Bot added the needs rebase Conflicts with main, rebase needed label Oct 12, 2026
@MarcZX10
MarcZX10 force-pushed the codex/carry-chflags-3632 branch 2 times, most recently from 45d3a89 to d9449c6 Compare October 12, 2026 18:49
@oneandonlydean oneandonlydean self-assigned this Oct 12, 2026
@github-actions github-actions Bot removed the needs rebase Conflicts with main, rebase needed label Oct 12, 2026
@screamm

screamm commented Oct 13, 2026

Copy link
Copy Markdown
Contributor

Windows validation with title evidence (Windows 11 Pro 26220, WinLibs MinGW-w64 GCC 15.2.0 r7, Ninja, Release, BUILD_TESTING=ON, full build including libs; base main 2a2a3dc6): 71fbc3ce merges cleanly but does not compile on current main: Stdio.cpp:308:22: error: redefinition of 'constexpr const int GUEST_EOPNOTSUPP', because main already has static constexpr int GUEST_EOPNOTSUPP = 45; since e99816e8 (#4391); the rebase only needs to drop the PR's copy (same value). With that one line removed: guest_filesystem 3/3; suite 688/689, the only failure being patched_libraries, which fails on main itself until #5025; conventions and git diff --check pass.

PS5MC (PPSA99420) relinked against that build: before, FAIL: unresolved ELF import ixrw0h2tWuI from libkernel.prx (chflags); after, FAIL: unresolved ELF import miQ1wVwSexE from libkernel.prx (getpriority, #4374). Stacked with #4374 and #4383 (plus a one-line test fix on #4383, see there) the title goes on to FAIL: unresolved ELF import d7nUj1LOdDU from libkernel.prx (clock_settime, the last commit of my #3632 branch).

danielradosa added a commit to danielradosa/AnyPS5 that referenced this pull request Oct 13, 2026
Dropped the duplicate GUEST_EOPNOTSUPP, resolved the path through ResolvePathError_nid_no_patch like chmod, mapped lookup errors with FilesystemError, and covered chflags in the parent-traversal test.
@p3n1cillin

Copy link
Copy Markdown

Title run with this PR: Windows 11, MinGW GCC 15.2.0 (WinLibs), Release. Built on main 3faa9cb40 merged with this PR and the other open PRs that the catalog titles below need (#4377, #4379, #4374, #4383, #3798, #4863, #4105, my #5013/#5061/#5078/#5098/#5009 and the carries #5183/#5186, plus screamm's chroot branch from #3632); every title converted from its catalog release, eboot.bin kept in app0, 60 s runs.

Build problem at this head (71fbc3ce6): core/libs/prx/libkernel/File/src/Stdio.cpp defines static constexpr int GUEST_EOPNOTSUPP = 45; twice (lines 302 and 308), so GCC 15 stops with redefinition of 'constexpr const int GUEST_EOPNOTSUPP'. One of the two lines needs to go; I dropped line 308 locally for the run above.

AI-assisted (Claude Code).

David and others added 3 commits October 13, 2026 18:54
PS5MC (PPSA99420, Kodi 22) imports chflags (ixrw0h2tWuI) from
libkernel.prx, one reference. Predicted stop once the imports ahead of
it (pthread_getthreadid_np, sendfile, wcstok, pause, setrlimit and the
termios calls) are covered (not a run):

  FAIL: unresolved ELF import ixrw0h2tWuI from libkernel.prx

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

Follows FreeBSD 11.4 (8c639945a44588f6cfdddfb057bb5aad88735da0)
sys/kern/vfs_syscalls.c kern_chflagsat and setfflags, and
sys/ufs/ufs/ufs_vnops.c ufs_setattr, for a root caller: the lookup
through the guest resolver gives EFAULT, ENOENT and ENOTDIR (also for a
file reached through a trailing slash or used as a directory), a bit
outside the 17 UFS flags of sys/sys/stat.h (VNOVAL included) gives
EOPNOTSUPP, and SF_SNAPSHOT gives EPERM, since the snapshot flag cannot
be toggled. No host keeps BSD file flags and stat reports st_flags 0,
so flags 0 succeed without touching the file and any other flag throws
with the flags named. UF_READONLY and the other Windows-attribute flags
are not mapped to FILE_ATTRIBUTE_READONLY and its siblings: UFS stores
them without enforcing them, and on Windows the read-only attribute is
already the owner write bit of chmod.

Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
(cherry picked from commit 16e5b7c)
@MarcZX10
MarcZX10 force-pushed the codex/carry-chflags-3632 branch from 71fbc3c to dfc9223 Compare October 13, 2026 18:54
@github-actions github-actions Bot removed the needs rebase Conflicts with main, rebase needed label Oct 13, 2026
@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
#4973 core/libs/prx/libkernel/File/src/Stdio.cpp L31

@MarcZX10

Copy link
Copy Markdown
Contributor Author

The title-run report identified a duplicate GUEST_EOPNOTSUPP definition in Stdio.cpp; I removed the redundant definition in commit b6a10e91a. tools/check_conventions.py --base upstream/main and git diff --check pass. I attempted a fresh Linux Release configure, but it stopped before compilation because this worktree's SDL2 submodule is uninitialized and the environment lacks XRandR development support. The hosted PR checks are running against this head.

@MarcZX10

Copy link
Copy Markdown
Contributor Author

Follow-up verification on the pushed head b6a10e91a: Linux x86-64, GCC 12.2, Ninja Release, fresh CMake configure with pinned submodules initialized. The guest_filesystem_tests target built successfully (including Stdio.cpp), and ctest -R '^guest_filesystem$' passed (1/1). This closes the local compile/test gap noted in my earlier update.

@oneandonlydean
oneandonlydean merged commit cf5f5b5 into boykopovar:main Oct 13, 2026
8 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

6 participants