Implementation of the fgIsQ10xYVA symbol (sceKernelChmod) and its POS… #2026
No reviewers
Labels
No labels
bug
documentation
duplicate
enhancement
GPU
GUI
help wanted
question
Shaders
Video
wontfix
No milestone
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set
Reference
github/KytyPS5--KytyPS5!2026
Loading…
Reference in a new issue
No description provided.
Delete branch "github-bot/gh-2026"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
@Ekt0re on GitHub · 2026-10-31 15:54 UTC · original
Ekt0re:Implementation-fgIsQ10xYVA→main· +637 −128 · 9 files · 5 commits · openImplement
sceKernelChmod(fgIsQ10xYVA) and sibling chmod/fchmod symbolsSummary
This PR implements the
fgIsQ10xYVAsymbol (sceKernelChmod) together with its POSIX and file-descriptor counterparts:fgIsQ10xYVAsceKernelChmodFileSystem::KernelChmodz0dtnPxYgtgposix_chmodPosix::chmodUtszJWHrDcAsceKernelFchmodFileSystem::KernelFchmodn01yNbQO5W4posix_fchmodPosix::fchmodThe previous empty dummy stub for
chmodhas been removed.Related issue: https://git.gtahub.st/github/KytyPS5--KytyPS5/issues/1960
Changes
1. Kernel file system (
src/kernel/fileSystem.h,src/kernel/fileSystem.cpp)KernelChmod(const char* path, uint32_t mode)The function validates the request and maps failures to kernel error codes:
path == nullptr→KERNEL_ERROR_EFAULT(0x8002000E)Path length > 255 characters →
KERNEL_ERROR_ENAMETOOLONGMount point cannot be resolved via the mount table (missing or empty) →
KERNEL_ERROR_ENOENTRead-only mount →
KERNEL_ERROR_EROFSFile or directory does not exist on the host →
KERNEL_ERROR_ENOENTIf all checks pass, the host permissions are updated with
std::filesystem::permissions, applying only the lower 12 bits of the mode (mode & 07777). If the host call fails, the error is translated to the appropriate kernel error code:KERNEL_ERROR_EPERMKERNEL_ERROR_ENOENTKERNEL_ERROR_EROFSKERNEL_ERROR_EIOKernelFchmod(int fd, uint32_t mode)Added the counterpart that operates on an already opened file descriptor.
2. POSIX wrappers and module registration (
src/libs/libKernel.cpp)Posix::chmod(const char* path, uint32_t mode)andPosix::fchmod(int fd, uint32_t mode), built on thePOSIX_CALL(...)macro. They return0on success, or-1on failure witherrnoset (via*Posix::GetErrorAddr()).libkernelsymbol database.chmoddummy stub.3. Unit tests (
tests/KernelFileSystemTests.cpp)Added the
TestChmodsuite, which covers:fgIsQ10xYVA,z0dtnPxYgtg,UtszJWHrDcA,n01yNbQO5W4)EFAULT,ENAMETOOLONG,ENOENT,EBADFTesting
TestChmodsuite executed and passed (chmod cases passed)AI use:
AI was used to analyze the problem and explore possible solutions.
I performed the implementation and testing manually.
@coderabbitai[bot] on GitHub · 2026-10-31 16:00 UTC · original · edited 2026-10-31 22:18 UTC
Findings
63ac3b58-a465-49d1-a9df-931b07c65a8dReviewing files that changed from the base of the PR and between
f48a8ad5bdand69e989f95a.src/common/platform/sysFileIO.hsrc/common/platform/sysLinuxFileIO.cppsrc/common/platform/sysWindowsFileIO.cppsrc/kernel/fileSystem.cppIncluded review availability: This review used your included allowance. Your plan provides up to 10 included reviews per hour; 6 remain after this review.
Walkthrough
The change adds path-based and descriptor-based permission updates. It adds host filesystem support for changing and retrieving permissions, kernel chmod operations, and permission reporting through
KernelStatandKernelFstat. POSIX and kernel symbol tables expose the operations. Tests cover successful updates and selected path and descriptor errors.Suggested reviewers:
nmzik,aspeniniChange: Feature
Merge Risk:
Moderate · up to
69e98Opening a directory inside an archive can now fail with an I/O error. Guest code can also change permissions on host files outside its mount through symlinks. A concurrent close during fchmod can touch freed descriptor state. These should be fixed before merging.
Pre-merge checks:
4 ·
1
Full details: Docstring Coverage
Explanation
Docstring coverage is 6.00% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff with cyclomatic complexity of at least 2. Documentation-only edits and deletions within surviving functions are included; unchanged diff context and fully deleted functions are excluded. Analyzed 50 functions across 9 files.
Resolution
Write docstrings for the functions missing them to satisfy the coverage threshold.
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.
Share
@ -1562,0 +1688,4 @@LOGF("\t KernelChmod: path = %s, mode = 0%o\n", path, mode & 07777);auto real_name = g_mount_points->ResolvePath(path);@coderabbitai[bot] on GitHub · 2026-10-31 16:00 UTC · original · edited 2026-10-31 16:36 UTC
Keep chmod targets inside the guest mount.
ResolvePathjoins the mount directory with guest components without rejecting... A guest path such as/chmod_test/../../outsidecan therefore make this new operation change permissions outside the mount. A symlink inside the mount can do the same becausestd::filesystem::permissionsfollows symlinks by default. Resolve and constrain the target before changing its permissions. (raw.githubusercontent.com)✅ Addressed in commit
69a2821@coderabbitai[bot] on GitHub · 2026-10-31 16:00 UTC · original · edited 2026-10-31 16:34 UTC
On
src/kernel/fileSystem.cppline 1588 (outdated):Preserve errors from the existence check.
If
std::filesystem::existsreports a permission error, this branch returnsENOENT. The caller then sees an inaccessible file as a missing file. Mapecto the corresponding kernel error before handling!exists. (raw.githubusercontent.com)✅ Addressed in commit
69a2821@coderabbitai[bot] on GitHub · 2026-10-31 16:00 UTC · original · edited 2026-10-31 17:00 UTC
On
src/kernel/fileSystem.cppline 1591 (outdated):Report changed permission bits through guest status calls.
KernelChmodchanges host permissions, butKernelStatandKernelFstatstill setst_modeto0777for ordinary files. After a successful chmod to0600, a guest status call still reports0777. Update both status paths to read the effective permission bits; the same gap affectsKernelFchmod. (raw.githubusercontent.com)✅ Addressed in commit
c82f1ea@coderabbitai[bot] on GitHub · 2026-10-31 16:00 UTC · original · edited 2026-10-31 22:13 UTC
On
src/kernel/fileSystem.cppline 1638 (outdated):Apply fchmod to the open file, not its saved pathname.
KernelFchmodusesfile->real_nameinstead of the open host file. If that file is renamed and another file takes its old pathname, fchmod changes the replacement file. If the pathname is removed, fchmod fails even though the file remains open. Use the underlying open handle for this operation. (raw.githubusercontent.com)✅ Addressed in commit
69e989f@coderabbitai[bot] on GitHub · 2026-10-31 16:00 UTC · original · reviewed
Actionable comments posted: 4
9d01d0db-f0c3-4695-be78-c4112d6ce817Reviewing files that changed from the base of the PR and between
026189166fanda8786e69df.src/kernel/fileSystem.cppsrc/kernel/fileSystem.hsrc/libs/libKernel.cpptests/KernelFileSystemTests.cppIncluded review availability: This review used your included allowance. Your plan provides up to 10 included reviews per hour; 8 remain after this review.
@ -1562,0 +1774,4 @@Common::LockGuard lock(file->mutex);if (!file->directory) {@coderabbitai[bot] on GitHub · 2026-10-31 16:44 UTC · original · edited 2026-10-31 17:01 UTC
Constrain directory fchmod targets to their guest mount.
If a directory entry inside a mount is a symlink to a host directory outside that mount,
KernelOpencan create a directory descriptor for it. This branch then reachesstd::filesystem::permissions(file->real_name, ...), which follows the symlink withoutKernelChmod’s canonical-target check. A guest can change permissions outside its mount throughKernelFchmod. Apply the mount containment check to directory descriptors before the path-based permission change. (raw.githubusercontent.com)✅ Addressed in commit
c82f1ea@coderabbitai[bot] on GitHub · 2026-10-31 16:44 UTC · original · reviewed
Actionable comments posted: 1
637f07c2-cce7-47ad-b2f0-2536722408f3Reviewing files that changed from the base of the PR and between
a8786e69dfand69a28219dc.src/common/file.cppsrc/common/file.hsrc/common/platform/sysFileIO.hsrc/common/platform/sysLinuxFileIO.cppsrc/common/platform/sysWindowsFileIO.cppsrc/kernel/fileSystem.cpptests/KernelFileSystemTests.cppIncluded review availability: This review used your included allowance. Your plan provides up to 10 included reviews per hour; 8 remain after this review.
@ -1562,0 +1710,4 @@bool exists = std::filesystem::exists(canonical_target, ec);if (ec) {LOGF("\t KernelChmod exists check failed: %s (ec = %d)\n", ec.message().c_str(),ec.value());@coderabbitai[bot] on GitHub · 2026-10-31 17:14 UTC · original · edited 2026-10-31 21:54 UTC
Script executed:
Repository: KytyPS5/KytyPS5
Length of output: 3552
Script executed:
Repository: KytyPS5/KytyPS5
Length of output: 10576
Script executed:
Repository: KytyPS5/KytyPS5
Length of output: 4957
Script executed:
Repository: KytyPS5/KytyPS5
Length of output: 2198
Synchronize
KernelChmodwithKernelRename.KernelRenameunlinks an existing destination before its later destination checks. A source symlink to an existing outside file can then replacecanonical_target. The path-basedstd::filesystem::permissions(canonical_target, ...)call may follow that symlink and modify the outside file.Use a shared filesystem-operation lock for
KernelChmodandKernelRename, or bind the permission update to the object checked for containment.✅ Addressed in commit
f48a8ad@coderabbitai[bot] on GitHub · 2026-10-31 17:14 UTC · original · edited 2026-10-31 21:55 UTC
On
src/kernel/fileSystem.cppline 1777 (outdated):Script executed:
Repository: KytyPS5/KytyPS5
Length of output: 14328
Script executed:
Repository: KytyPS5/KytyPS5
Length of output: 41355
Script executed:
Repository: KytyPS5/KytyPS5
Length of output: 10343
Script executed:
Repository: KytyPS5/KytyPS5
Length of output: 10874
Script executed:
Repository: KytyPS5/KytyPS5
Length of output: 1454
Bind directory
KernelFchmodto the opened directory handle.A guest can remove the empty directory through
KernelRmdir, then useKernelRenameto move an available symlink to an outside regular file into the removed pathname. The existing mount check andexistscheck run before this replacement. The finalstd::filesystem::permissionscall follows the replacement symlink and can change the outside file.Apply chmod through the opened directory handle instead of the previously checked pathname, or serialize it with directory removal and rename.
✅ Addressed in commit
f48a8ad@coderabbitai[bot] on GitHub · 2026-10-31 17:14 UTC · original · reviewed
Follow-up Comments
bdf03832-b010-4bfd-a47e-299a34dc33aeReviewing files that changed from the base of the PR and between
69a28219dcandc82f1eab00.src/kernel/fileSystem.cpptests/KernelFileSystemTests.cppIncluded review availability: This review used your included allowance. Your plan provides up to 10 included reviews per hour; 8 remain after this review.
@coderabbitai[bot] on GitHub · 2026-10-31 21:59 UTC · original · reviewed
Follow-up Comments
882653d1-bec5-4d28-b752-e56140f05077Reviewing files that changed from the base of the PR and between
c82f1eab00andf48a8ad5bd.src/kernel/fileSystem.cppIncluded review availability: This review used your included allowance. Your plan provides up to 10 included reviews per hour; 6 remain after this review.
@ -241,0 +245,4 @@HANDLE h_file = nullptr;h_file = CreateFileW(wide.c_str(),GENERIC_READ,FILE_SHARE_READ | FILE_SHARE_WRITE,@coderabbitai[bot] on GitHub · 2026-10-31 22:18 UTC · original
Allow deletion while a directory descriptor is open.
If a guest opens an empty directory, this share mode excludes
FILE_SHARE_DELETE. A laterKernelRmdirfor that directory fails on Windows until the descriptor closes. AddFILE_SHARE_DELETE, as the existing Windows file-open paths do. (raw.githubusercontent.com)@ -517,2 +558,4 @@EXIT_NOT_IMPLEMENTED(!directory && (trunc || creat));// Open directory handle for fchmod supportfile->dir_handle = SysFileOpenDir(file->real_name);@coderabbitai[bot] on GitHub · 2026-10-31 22:18 UTC · original
Close directory handles during filesystem shutdown.
If
EmergencyShutdownruns with directory descriptors open,FileDescriptors::CloseAlldeletes theirFileobjects without closingdir_handle. Those host handles remain open after the descriptors are removed. Close each directory handle inCloseAll, asKernelClosedoes. (raw.githubusercontent.com)Keep archive directories openable.
Common::File::GetInfocan identify a directory inside an archive.SysFileOpenDirthen tries to open its archive-member path as a host directory and fails.KernelOpenreturnsEIOinstead of opening the read-only archive directory. Skip host-handle creation for archive directories;KernelFchmodalready rejects archive paths. (raw.githubusercontent.com)@coderabbitai[bot] on GitHub · 2026-10-31 22:18 UTC · original · reviewed
Actionable comments posted: 3
63ac3b58-a465-49d1-a9df-931b07c65a8dReviewing files that changed from the base of the PR and between
f48a8ad5bdand69e989f95a.src/common/platform/sysFileIO.hsrc/common/platform/sysLinuxFileIO.cppsrc/common/platform/sysWindowsFileIO.cppsrc/kernel/fileSystem.cppIncluded review availability: This review used your included allowance. Your plan provides up to 10 included reviews per hour; 6 remain after this review.
View command line instructions
Manual merge helper
Use this merge commit message when completing the merge manually.
Checkout
From your project repository, check out a new branch and test the changes.Merge
Merge the changes and update on Forgejo.