libkernel: sceKernelMkdir rejects a trailing slash (ENOENT, nothing created) #2743

Closed
opened 2026-10-10 12:39:03 +00:00 by reyani-dev · 6 comments
reyani-dev commented 2026-10-10 12:39:03 +00:00 (Migrated from github.com)
Contributor

Imported from boykopovar/AnyPS5. Originally posted by reyani-dev on 2026-10-10T12:39:03Z.


sceKernelMkdir("dir/", mode) fails with ENOENT (0x80020002) and creates nothing, on both Windows and Linux. A second call still returns ENOENT, not EEXIST. FreeBSD's mkdir accepts a trailing slash, and so does AnyPS5's own POSIX mkdir export (mkdir_nid_postfix, through _wmkdir/mkdir(2)): mkdir("c/") creates c. Only sceKernelMkdir rejects it.

Cause. sceKernelMkdir (File/src/Stdio.cpp) checks that native.parent_path() exists before calling create_directory. For a path with a trailing separator, std::filesystem::path treats the trailing slash as an empty file name, so the "parent" is the directory being created. It doesn't exist yet, and the check returns ENOENT.

Related: for mkdir("file/child"), where the parent exists but is a regular file, it reports ENOENT, where FreeBSD reports ENOTDIR (0x80020014).

Relevance: 41 of the 48 homebrew catalog titles I relinked import sceKernelMkdir (1-LFLmRFxxM), which the SDK's mkdir reaches. I haven't found a title known to pass a trailing slash.

Fix, ready to cherry-pick. AchrafReyani:fix/mkdir-trailing-slash (5f74ddba, one commit, merges cleanly onto main b69270dd). I can't open it as a PR because of the intake check.

  • Trailing separators are stripped before the checks.
  • ENOTDIR is reported when the parent exists but isn't a directory.
  • guest_kernel_sync checks that sceKernelMkdir("…/nested/") creates the directory and records it as written. It also checks that a second call returns EEXIST, and that "…/existing.bin/child" returns ENOTDIR.

Checked on Windows (WinLibs GCC 15.2.0, Release, on main 89a1fb4e):

  • guest_kernel_sync fails without the change, at the first trailing-slash mkdir, and passes with it.
  • ctest -E "^agc_|video_out" passes 341/341, check_conventions.py passes, and pr_overlap.py reports no overlap.

Found with Claude Code.

<!-- greyfinch-sync:boykopovar/AnyPS5:issue:5791286518 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/issues/2743). Originally posted by [reyani-dev](https://github.com/reyani-dev) on 2026-10-10T12:39:03Z. --- `sceKernelMkdir("dir/", mode)` fails with `ENOENT` (`0x80020002`) and creates nothing, on both Windows and Linux. A second call still returns `ENOENT`, not `EEXIST`. FreeBSD's `mkdir` accepts a trailing slash, and so does AnyPS5's own POSIX `mkdir` export (`mkdir_nid_postfix`, through `_wmkdir`/`mkdir(2)`): `mkdir("c/")` creates `c`. Only `sceKernelMkdir` rejects it. **Cause.** `sceKernelMkdir` (`File/src/Stdio.cpp`) checks that `native.parent_path()` exists before calling `create_directory`. For a path with a trailing separator, `std::filesystem::path` treats the trailing slash as an empty file name, so the "parent" is the directory being created. It doesn't exist yet, and the check returns `ENOENT`. Related: for `mkdir("file/child")`, where the parent exists but is a regular file, it reports `ENOENT`, where FreeBSD reports `ENOTDIR` (`0x80020014`). Relevance: 41 of the 48 homebrew catalog titles I relinked import `sceKernelMkdir` (`1-LFLmRFxxM`), which the SDK's `mkdir` reaches. I haven't found a title known to pass a trailing slash. **Fix, ready to cherry-pick.** [`AchrafReyani:fix/mkdir-trailing-slash`](https://github.com/AchrafReyani/AnyPS5/tree/fix/mkdir-trailing-slash) (5f74ddba, one commit, merges cleanly onto `main` b69270dd). I can't open it as a PR because of the intake check. - Trailing separators are stripped before the checks. - `ENOTDIR` is reported when the parent exists but isn't a directory. - `guest_kernel_sync` checks that `sceKernelMkdir("…/nested/")` creates the directory and records it as written. It also checks that a second call returns `EEXIST`, and that `"…/existing.bin/child"` returns `ENOTDIR`. **Checked on Windows** (WinLibs GCC 15.2.0, Release, on `main` 89a1fb4e): - `guest_kernel_sync` fails without the change, at the first trailing-slash `mkdir`, and passes with it. - `ctest -E "^agc_|video_out"` passes 341/341, `check_conventions.py` passes, and `pr_overlap.py` reports no overlap. Found with Claude Code.
MarcZX10 commented 2026-10-10 12:54:33 +00:00 (Migrated from github.com)
Author
Contributor

Imported from boykopovar/AnyPS5. Originally posted by MarcZX10 on 2026-10-10T12:54:33Z.


I refreshed the reviewed sceKernelMkdir fix onto current upstream main (de5e541d) at a6ef1a4afb0336a633716b8db00950d859ac33c8. It preserves Achraf Reyani’s original trailing-slash implementation and adds the follow-up error handling and regression coverage for guest root and empty paths.

Validation on Linux (GCC 12.2, Release): rebuilt libkernel.prx and guest_kernel_sync_tests; guest_kernel_sync passed (1/1). tools/check_conventions.py --base upstream/main and git diff --check pass.

The branch is codex/mkdir-trailing-slash-2743. Achraf’s earlier Windows runs cover the trailing-slash and error-handling cases on the prior 78aedb40 base, not this current rebased head. I have not opened an upstream PR: the intake workflow requires 20 merged PRs, and my current merged count is 15.

<!-- greyfinch-sync:boykopovar/AnyPS5:comment:6097714303 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/issues/2743#issuecomment-6097714303). Originally posted by [MarcZX10](https://github.com/MarcZX10) on 2026-10-10T12:54:33Z. --- I refreshed the reviewed `sceKernelMkdir` fix onto current upstream `main` (`de5e541d`) at [`a6ef1a4afb0336a633716b8db00950d859ac33c8`](https://github.com/MarcZX100/AnyPS5/commit/a6ef1a4afb0336a633716b8db00950d859ac33c8). It preserves Achraf Reyani’s original trailing-slash implementation and adds the follow-up error handling and regression coverage for guest root and empty paths. **Validation on Linux (GCC 12.2, Release):** rebuilt `libkernel.prx` and `guest_kernel_sync_tests`; `guest_kernel_sync` passed (1/1). `tools/check_conventions.py --base upstream/main` and `git diff --check` pass. The branch is [`codex/mkdir-trailing-slash-2743`](https://github.com/MarcZX100/AnyPS5/tree/codex/mkdir-trailing-slash-2743). Achraf’s earlier Windows runs cover the trailing-slash and error-handling cases on the prior `78aedb40` base, not this current rebased head. I have not opened an upstream PR: the intake workflow requires 20 merged PRs, and my current merged count is 15.
reyani-dev commented 2026-10-10 12:59:51 +00:00 (Migrated from github.com)
Author
Contributor

Imported from boykopovar/AnyPS5. Originally posted by reyani-dev on 2026-10-10T12:59:51Z.


Fork CI for the branch merged onto current main (run 38052746387): Linux 700/700, Windows 708/708, relinker jobs green.

<!-- greyfinch-sync:boykopovar/AnyPS5:comment:6097756269 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/issues/2743#issuecomment-6097756269). Originally posted by [reyani-dev](https://github.com/reyani-dev) on 2026-10-10T12:59:51Z. --- Fork CI for the branch merged onto current `main` ([run 38052746387](https://github.com/AchrafReyani/AnyPS5/actions/runs/38052746387)): Linux 700/700, Windows 708/708, relinker jobs green.
reyani-dev commented 2026-10-10 13:11:10 +00:00 (Migrated from github.com)
Author
Contributor

Imported from boykopovar/AnyPS5. Originally posted by reyani-dev on 2026-10-10T13:11:10Z.


Thanks @MarcZX100. Here is the Windows side for your branch (986416b3, with my d15ab8ab underneath) merged onto current main 78aedb40, Windows 11, WinLibs GCC 15.2.0 r7, Release:

  • guest_kernel_sync passes 3/3 (--repeat until-fail:3), including your follow-up cases;
  • ctest -E "^agc_|video_out" passes 380/380.
<!-- greyfinch-sync:boykopovar/AnyPS5:comment:6097849641 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/issues/2743#issuecomment-6097849641). Originally posted by [reyani-dev](https://github.com/reyani-dev) on 2026-10-10T13:11:10Z. --- Thanks @MarcZX100. Here is the Windows side for your branch (`986416b3`, with my `d15ab8ab` underneath) merged onto current `main` 78aedb40, Windows 11, WinLibs GCC 15.2.0 r7, Release: - `guest_kernel_sync` passes 3/3 (`--repeat until-fail:3`), including your follow-up cases; - `ctest -E "^agc_|video_out"` passes 380/380.
reyani-dev commented 2026-10-10 18:25:37 +00:00 (Migrated from github.com)
Author
Contributor

Imported from boykopovar/AnyPS5. Originally posted by reyani-dev on 2026-10-10T18:25:37Z.


@MarcZX100 with intake at 10 merged PRs now, either of us can open this. Would you like to open your branch (986416b3, my commit plus your follow-up) as the PR, or should I open it with both commits, keeping you as the author of yours? Happy either way, I just don't want two PRs for it.

<!-- greyfinch-sync:boykopovar/AnyPS5:comment:6100768422 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/issues/2743#issuecomment-6100768422). Originally posted by [reyani-dev](https://github.com/reyani-dev) on 2026-10-10T18:25:37Z. --- @MarcZX100 with intake at 10 merged PRs now, either of us can open this. Would you like to open your branch (`986416b3`, my commit plus your follow-up) as the PR, or should I open it with both commits, keeping you as the author of yours? Happy either way, I just don't want two PRs for it.
MarcZX10 commented 2026-10-10 21:24:43 +00:00 (Migrated from github.com)
Author
Contributor

Imported from boykopovar/AnyPS5. Originally posted by MarcZX10 on 2026-10-10T21:24:43Z.


Thanks for coordinating. I opened #2819 with your original commit preserved and the follow-up cases on the same PR: https://github.com/boykopovar/AnyPS5/pull/2819. That keeps this to one PR.

<!-- greyfinch-sync:boykopovar/AnyPS5:comment:6102333468 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/issues/2743#issuecomment-6102333468). Originally posted by [MarcZX10](https://github.com/MarcZX10) on 2026-10-10T21:24:43Z. --- Thanks for coordinating. I opened #2819 with your original commit preserved and the follow-up cases on the same PR: https://github.com/boykopovar/AnyPS5/pull/2819. That keeps this to one PR.
p38593359-tech commented 2026-10-10 22:54:26 +00:00 (Migrated from github.com)
Author
Contributor

Imported from boykopovar/AnyPS5. Originally posted by p38593359-tech on 2026-10-10T22:54:26Z.


At work get get off thank

On Sat, Oct 10, 2026 at 3:25 PM MarcZX10 @.***> wrote:

MarcZX100 left a comment (boykopovar/AnyPS5#2743)
https://github.com/boykopovar/AnyPS5/issues/2743#issuecomment-6102333468

Thanks for coordinating. I opened #2819
https://github.com/boykopovar/AnyPS5/pull/2819 with your original
commit preserved and the follow-up cases on the same PR: #2819
https://github.com/boykopovar/AnyPS5/pull/2819. That keeps this to one
PR.

—
Reply to this email directly, view it on GitHub
https://github.com/boykopovar/AnyPS5/issues/2743?email_source=notifications&email_token=CRBVBYGBEOQQ2UKUG5W74RL5TKSNLA5CNFSNUABFM5UWIORPF5TWS5BNNB2WEL2JONZXKZKDN5WW2ZLOOQXTMMJQGIZTGMZUGY4KM4TFMFZW63VKON2WE43DOJUWEZLEUVSXMZLOOSWGM33PORSXEX3DNRUWG2Y#issuecomment-6102333468,
or unsubscribe
https://github.com/notifications/unsubscribe-auth/CRBVBYCLBZKE4VFGPSBHSBL5TKSNLAVCNFSNUABGKJSXA33TNF2G64TZHMYTGMRSGI2TANRWGY5US43TOVSTWNJXHEYTEOBWGUYTRILWAI
.
Triage notifications, keep track of coding agent tasks and review pull
requests on the go with GitHub Mobile for iOS
https://github.com/notifications/mobile/ios/CRBVBYGNAK5MIMTT567EMQ35TKSNLA5CNFSNUABFM5UWIORPF5TWS5BNNB2WEL2JONZXKZKDN5WW2ZLOOQXTMMJQGIZTGMZUGY4KM4TFMFZW63VKON2WE43DOJUWEZLEUVSXMZLOOSVGM33PORSXEX3JN5ZQ
and Android
https://github.com/notifications/mobile/android/CRBVBYBKEJ6VRADWXWLDEKT5TKSNLA5CNFSNUABFM5UWIORPF5TWS5BNNB2WEL2JONZXKZKDN5WW2ZLOOQXTMMJQGIZTGMZUGY4KM4TFMFZW63VKON2WE43DOJUWEZLEUVSXMZLOOSXGM33PORSXEX3BNZSHE33JMQ.
Download it today!
You are receiving this because you are subscribed to this thread.Message
ID: @.***>

<!-- greyfinch-sync:boykopovar/AnyPS5:comment:6103058525 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/issues/2743#issuecomment-6103058525). Originally posted by [p38593359-tech](https://github.com/p38593359-tech) on 2026-10-10T22:54:26Z. --- At work get get off thank On Sat, Oct 10, 2026 at 3:25 PM MarcZX10 ***@***.***> wrote: > *MarcZX100* left a comment (boykopovar/AnyPS5#2743) > <https://github.com/boykopovar/AnyPS5/issues/2743#issuecomment-6102333468> > > Thanks for coordinating. I opened #2819 > <https://github.com/boykopovar/AnyPS5/pull/2819> with your original > commit preserved and the follow-up cases on the same PR: #2819 > <https://github.com/boykopovar/AnyPS5/pull/2819>. That keeps this to one > PR. > > — > Reply to this email directly, view it on GitHub > <https://github.com/boykopovar/AnyPS5/issues/2743?email_source=notifications&email_token=CRBVBYGBEOQQ2UKUG5W74RL5TKSNLA5CNFSNUABFM5UWIORPF5TWS5BNNB2WEL2JONZXKZKDN5WW2ZLOOQXTMMJQGIZTGMZUGY4KM4TFMFZW63VKON2WE43DOJUWEZLEUVSXMZLOOSWGM33PORSXEX3DNRUWG2Y#issuecomment-6102333468>, > or unsubscribe > <https://github.com/notifications/unsubscribe-auth/CRBVBYCLBZKE4VFGPSBHSBL5TKSNLAVCNFSNUABGKJSXA33TNF2G64TZHMYTGMRSGI2TANRWGY5US43TOVSTWNJXHEYTEOBWGUYTRILWAI> > . > Triage notifications, keep track of coding agent tasks and review pull > requests on the go with GitHub Mobile for iOS > <https://github.com/notifications/mobile/ios/CRBVBYGNAK5MIMTT567EMQ35TKSNLA5CNFSNUABFM5UWIORPF5TWS5BNNB2WEL2JONZXKZKDN5WW2ZLOOQXTMMJQGIZTGMZUGY4KM4TFMFZW63VKON2WE43DOJUWEZLEUVSXMZLOOSVGM33PORSXEX3JN5ZQ> > and Android > <https://github.com/notifications/mobile/android/CRBVBYBKEJ6VRADWXWLDEKT5TKSNLA5CNFSNUABFM5UWIORPF5TWS5BNNB2WEL2JONZXKZKDN5WW2ZLOOQXTMMJQGIZTGMZUGY4KM4TFMFZW63VKON2WE43DOJUWEZLEUVSXMZLOOSXGM33PORSXEX3BNZSHE33JMQ>. > Download it today! > You are receiving this because you are subscribed to this thread.Message > ID: ***@***.***> >
Sign in to join this conversation.
No labels
No milestone
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Reference
boykopovar/AnyPS5#2743
No description provided.