fix(libc): report the file number of each readdir entry on Windows #8116

Merged
dantdmdarealguy merged 1 commit from upstream-pr/8116 into main 2026-10-20 15:55:58 +00:00
dantdmdarealguy commented 2026-10-19 22:28:38 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by dantdmdarealguy on 2026-10-19T22:28:38Z.


What

On Windows, readdir and readdir_r returned d_fileno 0 for every entry. Directory.cpp took the number from MinGW's _wreaddir, which never reports an inode. FreeBSD never hands out such an entry: _readdir_unlocked skips every record whose d_ino is 0 (lib/libc/gen/readdir.c L83, release/11.4.0), and both readdir and readdir_r call it with skip set (L98, L102, L116, L120). A returned d_fileno is the entry's file number, the same number lstat reports as st_ino (d_fileno is 32 bits in FreeBSD 11, sys/sys/dirent.h L51). Linux already reported the host inode.

  • On Windows the directory stream no longer goes through MinGW's _wopendir/_wreaddir. It opens the directory once and reads the listing from that handle with GetFileInformationByHandleEx(FileIdBothDirectoryInfo), which gives each entry's FileId without opening the entry. A symbolic link's FileId is the link's own, so it matches lstat.
  • FileId is the nFileIndexHigh:nFileIndexLow that stat and lstat already fold into st_ino (NativeStat.cpp). The fold moves into WindowsDescriptor.hpp (WindowsFileNumber_nid_no_patch), so libc and libkernel share one definition and d_fileno equals st_ino.
  • No entry is opened, so readdir cannot fail or throw because of one entry. An entry that CreateFileW cannot open (a delete-pending file, C:\bootTel.dat, C:\Config.Msi) is listed with its number, as before.
  • rewinddir restarts the scan (FileIdBothDirectoryRestartInfo), so entries created or removed since opendir show up or disappear after it, as POSIX specifies. telldir returns the number of entries read and seekdir restarts and skips that many, as MinGW's _wtelldir/_wseekdir did. The fdopendir path keeps skipping entries by count.
  • If a file system lists no file ID (the entry's FileId is 0, or the volume rejects the class, in which case the stream falls back to FileFullDirectoryInfo), the entry gets a nonzero number hashed from its name and the directory's file index. That number differs from st_ino, so it is recorded in docs/dev/debt/libc.md. NTFS lists an ID for every entry.
  • opendir now fails with the error from opening the directory (for example EACCES without list permission), where MinGW returned a stream that listed nothing.
  • On Linux a host inode above 2^32 used to be reported as 0. It is now truncated to 32 bits, as stat already does, so d_fileno and st_ino agree there too.

guest_directory now checks: every entry has a nonzero file number; the numbers of a file, a subdirectory, and symbolic links to each equal lstat's st_ino; an entry created while the directory is open appears after rewinddir with its lstat number, and is gone after removal and rewinddir; a delete-pending entry, which lstat cannot open, is still listed and does not stop readdir; and seekdir returns the same number. The test links libkernel for lstat, as guest_path_case already does. It fails on main (d_fileno 0) and on the first version of this PR (readdir throws on the delete-pending entry), and passes with the change.

readdir over a directory of 10,000 empty files on NTFS (ms per full opendir/readdir/closedir pass, same machine; each run takes the median of its passes):

main 587bb343e first PR version 1ece463fd this version
batch 1: median of 5 runs × 10 passes 302 1390 291
batch 2: median of 5 runs × 20 passes 703 1395 688
fastest pass, all runs 285 565 275

The two batches differ because each pass on main and on this version fluctuates between about 290 and 700 ms, which comes from the d_type lookup. Both versions spend most of that time in the existing d_type lookup (std::filesystem::symlink_status, a _wstat64 per entry). Measured on its own over the same 10,000 entries, listing them takes 1.2 ms with FileIdBothDirectoryInfo and 1.8 ms with FindFirstFileW/FindNextFileW. Opening each entry (CreateFileW + GetFileInformationByHandle + CloseHandle), the step the first version added, takes about 280 ms, and symlink_status takes 280 to 670 ms.

Tested

Windows 11 Pro, Intel Core i9-14900K, 128 GB RAM, NVIDIA GeForce RTX 5080 (driver 32.0.16.1714), WinLibs GCC 15.2.0, Release, BUILD_TESTING=ON:

  • guest_directory with the new checks, the same test executable run against each build's libc.prx/libkernel.prx: aborts on main (Require(fileNumber != 0)). On 1ece463fd it aborts with readdir: cannot open directory entry ...\pending.txt, error=5. It passes with the change, symbolic link checks included (Developer Mode is on).
  • readdir of C:\: 98 entries, all numbered 0 on main; 1ece463fd throws readdir: cannot open directory entry C:/bootTel.dat, error=5; 98 entries, all nonzero, with the change.
  • Full build and --target libs: both succeed, with no warnings in the changed files.
  • ctest -R "guest_directory|guest_fdopendir|guest_filesystem|guest_file_timestamps|guest_path_case|guest_realpath|guest_statvfs|patched_libraries": all 11 tests pass. guest_app_archive*, guest_kernel_app_archive* and guest_fdopendir: all 8 pass.
  • tools/check_test_registration.py and tools/check_conventions.py --base origin/main pass.
  • Not run on Linux; there only the 32-bit truncation changes.
  • The fallback for a file system without file IDs is not exercised: no such volume is available here.
  • No title or homebrew run.

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, some AI assistance was used
<!-- greyfinch-sync:boykopovar/AnyPS5:issue:4928265016 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/8116). Originally posted by [dantdmdarealguy](https://github.com/dantdmdarealguy) on 2026-10-19T22:28:38Z. --- ### What On Windows, `readdir` and `readdir_r` returned `d_fileno` 0 for every entry. `Directory.cpp` took the number from MinGW's `_wreaddir`, which never reports an inode. FreeBSD never hands out such an entry: `_readdir_unlocked` skips every record whose `d_ino` is 0 ([`lib/libc/gen/readdir.c` L83, release/11.4.0](https://github.com/freebsd/freebsd-src/blob/release/11.4.0/lib/libc/gen/readdir.c#L83)), and both `readdir` and `readdir_r` call it with `skip` set (L98, L102, L116, L120). A returned `d_fileno` is the entry's file number, the same number `lstat` reports as `st_ino` (`d_fileno` is 32 bits in FreeBSD 11, [`sys/sys/dirent.h` L51](https://github.com/freebsd/freebsd-src/blob/release/11.4.0/sys/sys/dirent.h#L51)). Linux already reported the host inode. - On Windows the directory stream no longer goes through MinGW's `_wopendir`/`_wreaddir`. It opens the directory once and reads the listing from that handle with `GetFileInformationByHandleEx(FileIdBothDirectoryInfo)`, which gives each entry's `FileId` without opening the entry. A symbolic link's `FileId` is the link's own, so it matches `lstat`. - `FileId` is the `nFileIndexHigh:nFileIndexLow` that `stat` and `lstat` already fold into `st_ino` (`NativeStat.cpp`). The fold moves into `WindowsDescriptor.hpp` (`WindowsFileNumber_nid_no_patch`), so libc and libkernel share one definition and `d_fileno` equals `st_ino`. - No entry is opened, so `readdir` cannot fail or throw because of one entry. An entry that `CreateFileW` cannot open (a delete-pending file, `C:\bootTel.dat`, `C:\Config.Msi`) is listed with its number, as before. - `rewinddir` restarts the scan (`FileIdBothDirectoryRestartInfo`), so entries created or removed since `opendir` show up or disappear after it, as POSIX specifies. `telldir` returns the number of entries read and `seekdir` restarts and skips that many, as MinGW's `_wtelldir`/`_wseekdir` did. The `fdopendir` path keeps skipping entries by count. - If a file system lists no file ID (the entry's `FileId` is 0, or the volume rejects the class, in which case the stream falls back to `FileFullDirectoryInfo`), the entry gets a nonzero number hashed from its name and the directory's file index. That number differs from `st_ino`, so it is recorded in `docs/dev/debt/libc.md`. NTFS lists an ID for every entry. - `opendir` now fails with the error from opening the directory (for example `EACCES` without list permission), where MinGW returned a stream that listed nothing. - On Linux a host inode above 2^32 used to be reported as 0. It is now truncated to 32 bits, as `stat` already does, so `d_fileno` and `st_ino` agree there too. `guest_directory` now checks: every entry has a nonzero file number; the numbers of a file, a subdirectory, and symbolic links to each equal `lstat`'s `st_ino`; an entry created while the directory is open appears after `rewinddir` with its `lstat` number, and is gone after removal and `rewinddir`; a delete-pending entry, which `lstat` cannot open, is still listed and does not stop `readdir`; and `seekdir` returns the same number. The test links libkernel for `lstat`, as `guest_path_case` already does. It fails on `main` (`d_fileno` 0) and on the first version of this PR (`readdir` throws on the delete-pending entry), and passes with the change. `readdir` over a directory of 10,000 empty files on NTFS (ms per full `opendir`/`readdir`/`closedir` pass, same machine; each run takes the median of its passes): | | `main` 587bb343e | first PR version 1ece463fd | this version | |---|---|---|---| | batch 1: median of 5 runs × 10 passes | 302 | 1390 | 291 | | batch 2: median of 5 runs × 20 passes | 703 | 1395 | 688 | | fastest pass, all runs | 285 | 565 | 275 | The two batches differ because each pass on `main` and on this version fluctuates between about 290 and 700 ms, which comes from the `d_type` lookup. Both versions spend most of that time in the existing `d_type` lookup (`std::filesystem::symlink_status`, a `_wstat64` per entry). Measured on its own over the same 10,000 entries, listing them takes 1.2 ms with `FileIdBothDirectoryInfo` and 1.8 ms with `FindFirstFileW`/`FindNextFileW`. Opening each entry (`CreateFileW` + `GetFileInformationByHandle` + `CloseHandle`), the step the first version added, takes about 280 ms, and `symlink_status` takes 280 to 670 ms. ### Tested Windows 11 Pro, Intel Core i9-14900K, 128 GB RAM, NVIDIA GeForce RTX 5080 (driver 32.0.16.1714), WinLibs GCC 15.2.0, Release, `BUILD_TESTING=ON`: - `guest_directory` with the new checks, the same test executable run against each build's `libc.prx`/`libkernel.prx`: aborts on `main` (`Require(fileNumber != 0)`). On 1ece463fd it aborts with `readdir: cannot open directory entry ...\pending.txt, error=5`. It passes with the change, symbolic link checks included (Developer Mode is on). - `readdir` of `C:\`: 98 entries, all numbered 0 on `main`; 1ece463fd throws `readdir: cannot open directory entry C:/bootTel.dat, error=5`; 98 entries, all nonzero, with the change. - Full build and `--target libs`: both succeed, with no warnings in the changed files. - `ctest -R "guest_directory|guest_fdopendir|guest_filesystem|guest_file_timestamps|guest_path_case|guest_realpath|guest_statvfs|patched_libraries"`: all 11 tests pass. `guest_app_archive*`, `guest_kernel_app_archive*` and `guest_fdopendir`: all 8 pass. - `tools/check_test_registration.py` and `tools/check_conventions.py --base origin/main` pass. - Not run on Linux; there only the 32-bit truncation changes. - The fallback for a file system without file IDs is not exercised: no such volume is available here. - No title or homebrew run. ### Checklist <!-- Rules behind each item: https://github.com/boykopovar/AnyPS5/blob/main/CONTRIBUTING.md --> - [x] Based on current `main`; no other open PR implements the same functions - [x] One topic per PR; follow-ups go in a new PR - [x] No comments in code except [technical debt](https://github.com/boykopovar/AnyPS5/blob/main/docs/dev/CONVENTIONS.md) - [x] Unimplemented paths throw (`NotImplemented_nid_no_patch`); silent stubs are listed under Silent stubs in their library's [technical debt](https://github.com/boykopovar/AnyPS5/tree/main/docs/dev/debt) file - [x] No notes, investigation `.md` files or images added to the repository (attach them to this PR) - [x] New third-party code is a submodule built from source - [x] Generic behaviour, not specific to one title - [x] Depends on: none - [x] Fixes: none - [x] Unblocks: none - [x] GPUs tested: n/a - [x] AI-assisted: yes, some AI assistance was used
github-actions[bot] commented 2026-10-19 22:38:10 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by github-actions[bot] on 2026-10-19T22:38:10Z.


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 8150 docs/dev/debt/libc.md L93-94

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/libc/CMakeLists.txt
core/libs/prx/libkernel/File/src/NativeStat.cpp
docs/dev/debt/libc.md
PR 6044 core/libs/prx/libc/CMakeLists.txt
core/libs/tests/GuestDirectory.cpp
PR 6226 docs/dev/debt/libc.md
PR 6469 docs/dev/debt/libc.md
PR 6819 core/libs/prx/libc/CMakeLists.txt
docs/dev/debt/libc.md
PR 7081 core/libs/prx/libc/CMakeLists.txt
docs/dev/debt/libc.md
PR 7201 core/libs/prx/libc/CMakeLists.txt
core/libs/prx/libkernel/File/src/NativeStat.cpp
PR 7473 docs/dev/debt/libc.md
PR 7715 core/libs/prx/libc/CMakeLists.txt
docs/dev/debt/libc.md
<!-- greyfinch-sync:boykopovar/AnyPS5:comment:6278909706 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/8116#issuecomment-6278909706). Originally posted by [github-actions[bot]](https://github.com/apps/github-actions) on 2026-10-19T22:38:10Z. --- <!-- pr-overlap --> 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 8150](https://www.github.com/boykopovar/AnyPS5/pull/8150) | `docs/dev/debt/libc.md` [L93-94](https://github.com/boykopovar/AnyPS5/blob/7526640c3c1c5ea236c33b43b854681e8d169745/docs/dev/debt/libc.md#L93-L94) | | | 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](https://www.github.com/boykopovar/AnyPS5/pull/5021) | `core/libs/prx/libc/CMakeLists.txt`<br>`core/libs/prx/libkernel/File/src/NativeStat.cpp`<br>`docs/dev/debt/libc.md` | | [PR 6044](https://www.github.com/boykopovar/AnyPS5/pull/6044) | `core/libs/prx/libc/CMakeLists.txt`<br>`core/libs/tests/GuestDirectory.cpp` | | [PR 6226](https://www.github.com/boykopovar/AnyPS5/pull/6226) | `docs/dev/debt/libc.md` | | [PR 6469](https://www.github.com/boykopovar/AnyPS5/pull/6469) | `docs/dev/debt/libc.md` | | [PR 6819](https://www.github.com/boykopovar/AnyPS5/pull/6819) | `core/libs/prx/libc/CMakeLists.txt`<br>`docs/dev/debt/libc.md` | | [PR 7081](https://www.github.com/boykopovar/AnyPS5/pull/7081) | `core/libs/prx/libc/CMakeLists.txt`<br>`docs/dev/debt/libc.md` | | [PR 7201](https://www.github.com/boykopovar/AnyPS5/pull/7201) | `core/libs/prx/libc/CMakeLists.txt`<br>`core/libs/prx/libkernel/File/src/NativeStat.cpp` | | [PR 7473](https://www.github.com/boykopovar/AnyPS5/pull/7473) | `docs/dev/debt/libc.md` | | [PR 7715](https://www.github.com/boykopovar/AnyPS5/pull/7715) | `core/libs/prx/libc/CMakeLists.txt`<br>`docs/dev/debt/libc.md` |
oneandonlydean commented 2026-10-20 05:00:50 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by oneandonlydean on 2026-10-20T05:00:50Z.


Thanks. Making d_fileno match st_ino is right, and the Linux side now agrees with stat too. One concern before merge:

ReadFileNumber opens every directory entry (CreateFileW + GetFileInformationByHandle + CloseHandle) on each readdir. Main did no per-entry open, so a directory with thousands of entries now pays thousands of handle opens, and file-system filters such as Defender make each open more expensive. A failed open other than not-found (for example access denied on a protected entry) also throws out of readdir, where main returned the entry.

Windows can return the IDs for the whole directory without opening the entries: GetFileInformationByHandleEx(directoryHandle, FileIdBothDirectoryInfo, ...) (or FileIdExtdDirectoryInfo) gives FileId per entry. Folding it as WindowsFileNumber_nid_no_patch does now (High:Low = FileId) keeps it equal to st_ino.

Could you either switch to that, or post main-vs-PR readdir timings on Windows for a directory of about 10k files? And please don't abort readdir when a single entry can't be opened: skip it only when it's gone, otherwise fall back to a stable nonzero number.

<!-- greyfinch-sync:boykopovar/AnyPS5:comment:6283770058 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/8116#issuecomment-6283770058). Originally posted by [oneandonlydean](https://github.com/oneandonlydean) on 2026-10-20T05:00:50Z. --- Thanks. Making `d_fileno` match `st_ino` is right, and the Linux side now agrees with `stat` too. One concern before merge: `ReadFileNumber` opens every directory entry (`CreateFileW` + `GetFileInformationByHandle` + `CloseHandle`) on each `readdir`. Main did no per-entry open, so a directory with thousands of entries now pays thousands of handle opens, and file-system filters such as Defender make each open more expensive. A failed open other than not-found (for example access denied on a protected entry) also throws out of `readdir`, where main returned the entry. Windows can return the IDs for the whole directory without opening the entries: `GetFileInformationByHandleEx(directoryHandle, FileIdBothDirectoryInfo, ...)` (or `FileIdExtdDirectoryInfo`) gives `FileId` per entry. Folding it as `WindowsFileNumber_nid_no_patch` does now (High:Low = `FileId`) keeps it equal to `st_ino`. Could you either switch to that, or post main-vs-PR `readdir` timings on Windows for a directory of about 10k files? And please don't abort `readdir` when a single entry can't be opened: skip it only when it's gone, otherwise fall back to a stable nonzero number.
dantdmdarealguy commented 2026-10-20 08:57:25 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by dantdmdarealguy on 2026-10-20T08:57:25Z.


Thanks, switched to the directory handle. readdir now reads the listing with GetFileInformationByHandleEx(FileIdBothDirectoryInfo) (restart class on opendir/rewinddir) and folds FileId with WindowsFileNumber_nid_no_patch, so nothing is opened per entry. On NTFS the listed FileId equals the nFileIndexHigh:nFileIndexLow of the entry opened with FILE_FLAG_OPEN_REPARSE_POINT; I checked ., .., files, directories, and file and directory symlinks. FileIdExtdDirectoryInfo wasn't needed to match st_ino.

Since no entry is opened, a single entry can no longer abort readdir. Your access-denied case reproduces on this machine: readdir("C:/") on the previous head threw on C:\bootTel.dat (error 5), and a delete-pending file throws the same way. Both are now listed with their FileId. guest_directory covers the delete-pending case, plus symlink numbers, entries created or removed while the directory is open (visible after rewinddir), and seekdir. If a file system lists no ID (FileId 0, or it rejects the class, in which case it falls back to FileFullDirectoryInfo), the entry gets a stable nonzero hash of its name and the directory's index. That case is listed in debt/libc.md.

Timings for 10,000 empty files on NTFS (i9-14900K, Windows 11, ms per full opendir/readdir/closedir pass):

main previous head 1ece463fd now
median of 5 runs × 10 passes 302 1390 291
median of 5 runs × 20 passes 703 1395 688
fastest pass 285 565 275

One correction on main: it already opens each entry once, in the d_type lookup (std::filesystem::symlink_status → _wstat64), which is why main sits at 290 to 700 ms rather than near zero. Listing 10,000 entries alone takes 1.2 ms with FileIdBothDirectoryInfo, against 1.8 ms with FindFirstFileW. The previous head added a second open (~280 ms per 10k), and that's gone now. Taking d_type from the listing's attributes would remove the remaining per-entry stat and fix symlinks reporting their target's type (libstdc++'s symlink_status follows links on Windows). That's a separate change, so I'll leave it for a follow-up.

<!-- greyfinch-sync:boykopovar/AnyPS5:comment:6287309193 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/8116#issuecomment-6287309193). Originally posted by [dantdmdarealguy](https://github.com/dantdmdarealguy) on 2026-10-20T08:57:25Z. --- Thanks, switched to the directory handle. `readdir` now reads the listing with `GetFileInformationByHandleEx(FileIdBothDirectoryInfo)` (restart class on `opendir`/`rewinddir`) and folds `FileId` with `WindowsFileNumber_nid_no_patch`, so nothing is opened per entry. On NTFS the listed `FileId` equals the `nFileIndexHigh:nFileIndexLow` of the entry opened with `FILE_FLAG_OPEN_REPARSE_POINT`; I checked `.`, `..`, files, directories, and file and directory symlinks. `FileIdExtdDirectoryInfo` wasn't needed to match `st_ino`. Since no entry is opened, a single entry can no longer abort `readdir`. Your access-denied case reproduces on this machine: `readdir("C:/")` on the previous head threw on `C:\bootTel.dat` (error 5), and a delete-pending file throws the same way. Both are now listed with their `FileId`. `guest_directory` covers the delete-pending case, plus symlink numbers, entries created or removed while the directory is open (visible after `rewinddir`), and `seekdir`. If a file system lists no ID (`FileId` 0, or it rejects the class, in which case it falls back to `FileFullDirectoryInfo`), the entry gets a stable nonzero hash of its name and the directory's index. That case is listed in `debt/libc.md`. Timings for 10,000 empty files on NTFS (i9-14900K, Windows 11, ms per full `opendir`/`readdir`/`closedir` pass): | | main | previous head 1ece463fd | now | |---|---|---|---| | median of 5 runs × 10 passes | 302 | 1390 | 291 | | median of 5 runs × 20 passes | 703 | 1395 | 688 | | fastest pass | 285 | 565 | 275 | One correction on main: it already opens each entry once, in the `d_type` lookup (`std::filesystem::symlink_status` → `_wstat64`), which is why main sits at 290 to 700 ms rather than near zero. Listing 10,000 entries alone takes 1.2 ms with `FileIdBothDirectoryInfo`, against 1.8 ms with `FindFirstFileW`. The previous head added a second open (~280 ms per 10k), and that's gone now. Taking `d_type` from the listing's attributes would remove the remaining per-entry stat and fix symlinks reporting their target's type (libstdc++'s `symlink_status` follows links on Windows). That's a separate change, so I'll leave it for a follow-up.
wachi35676 commented 2026-10-20 11:29:38 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by wachi35676 on 2026-10-20T11:29:38Z.


Head 251ca1c10 merged onto main 02fb1ce53 (clean merge).

Windows 11 (10.0.26300), Ryzen 5 9600X, WinLibs GCC 15.2.0 UCRT, Release, BUILD_TESTING=ON:

  • ctest -R "^(guest_directory|guest_fdopendir|guest_filesystem|guest_rename_dot)": 7 of 7 pass, 3 runs out of 3. The build log has no warnings.
  • With Directory.cpp, WindowsDescriptor.hpp and NativeStat.cpp reverted to main, guest_directory fails (exit 0xc0000409).
  • I wrote a probe that calls opendir/readdir through libc.prx and lstat through libkernel.prx, and sets errno to 0 before each readdir:
directory entries d_fileno 0 equal to lstat st_ino different lstat failed errno at end of stream
C:/ (NTFS) 28 0 21 0 7 0
C:/Windows/System32 (NTFS) 4804 0 4794 0 10 0
WSL 9P share (\\wsl.localhost\Ubuntu, mapped as a drive), 3 files and a subdirectory 6 0 5 1 0 0
  • The 9P share is not NTFS, so it covers part of what the description lists as not exercised. Every entry there gets a nonzero number. Only .. differs from lstat (d_fileno 3590321765, st_ino 1262401), the case the new debt line describes. ., the files and the subdirectory match.
  • A side finding that this PR does not change: lstat of a symbolic link on that 9P share throws std::system_error (lstat: FSCTL_GET_REPARSE_POINT: Incorrect function) out of libkernel.prx, where it should return an error. The throw is in main's WindowsSymbolicLink.hpp, which this PR does not touch.

Ubuntu 24.04 (WSL2), GCC 13.3, Release, BUILD_TESTING=ON, same merge: guest_directory, guest_fdopendir and guest_filesystem pass, 3 runs out of 3. The new symbolic-link and lstat checks run there and pass. The one build warning is the existing -Wformat-overflow in Open.cpp, which this PR does not touch. As expected, the checks also pass with the sources reverted on Linux, because the host inode was already reported there.

AI-assisted: yes (Claude Code); results above were run on this machine.

<!-- greyfinch-sync:boykopovar/AnyPS5:comment:6289842810 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/8116#issuecomment-6289842810). Originally posted by [wachi35676](https://github.com/wachi35676) on 2026-10-20T11:29:38Z. --- Head `251ca1c10` merged onto `main` `02fb1ce53` (clean merge). **Windows 11 (10.0.26300), Ryzen 5 9600X, WinLibs GCC 15.2.0 UCRT, Release, `BUILD_TESTING=ON`:** - `ctest -R "^(guest_directory|guest_fdopendir|guest_filesystem|guest_rename_dot)"`: 7 of 7 pass, 3 runs out of 3. The build log has no warnings. - With `Directory.cpp`, `WindowsDescriptor.hpp` and `NativeStat.cpp` reverted to `main`, `guest_directory` fails (exit `0xc0000409`). - I wrote a probe that calls `opendir`/`readdir` through `libc.prx` and `lstat` through `libkernel.prx`, and sets `errno` to 0 before each `readdir`: | directory | entries | `d_fileno` 0 | equal to `lstat` `st_ino` | different | `lstat` failed | `errno` at end of stream | |---|---|---|---|---|---|---| | `C:/` (NTFS) | 28 | 0 | 21 | 0 | 7 | 0 | | `C:/Windows/System32` (NTFS) | 4804 | 0 | 4794 | 0 | 10 | 0 | | WSL 9P share (`\\wsl.localhost\Ubuntu`, mapped as a drive), 3 files and a subdirectory | 6 | 0 | 5 | 1 | 0 | 0 | - The 9P share is not NTFS, so it covers part of what the description lists as not exercised. Every entry there gets a nonzero number. Only `..` differs from `lstat` (`d_fileno` 3590321765, `st_ino` 1262401), the case the new debt line describes. `.`, the files and the subdirectory match. - A side finding that this PR does not change: `lstat` of a symbolic link on that 9P share throws `std::system_error` (`lstat: FSCTL_GET_REPARSE_POINT: Incorrect function`) out of `libkernel.prx`, where it should return an error. The throw is in `main`'s `WindowsSymbolicLink.hpp`, which this PR does not touch. **Ubuntu 24.04 (WSL2), GCC 13.3, Release, `BUILD_TESTING=ON`, same merge:** `guest_directory`, `guest_fdopendir` and `guest_filesystem` pass, 3 runs out of 3. The new symbolic-link and `lstat` checks run there and pass. The one build warning is the existing `-Wformat-overflow` in `Open.cpp`, which this PR does not touch. As expected, the checks also pass with the sources reverted on Linux, because the host inode was already reported there. AI-assisted: yes (Claude Code); results above were run on this machine.
Sign in to join this conversation.
No reviewers
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!8116
No description provided.