Fix sysFsReaddir #19512

Open
digant73 opened 1:39pm on September 16, 2026 wants to merge 121 Δ into rpcs3/rpcs3 master from
fix_sysFsReaddir

Quick summary

I'm testing application that uses google drive api via curl. In the process of debugging app, i've noticed that some functions doesn't work the same as on real PS3 hardware. 1. the main issue: sysFsReaddir stops on the last available path and doesn't break a loop, while on PS3 it works as expected. 2. for curl there is no entropy source, yet it's not recorded in emulator log: - in RPCS3 logs you can find only "SYS: 'sys_fs_open' failed with 0x8001003a : CELL_ENOTMOUNTED, “/dev/urandom” " - while in curl logs from app there is: INFO: Failed - PolarSSL: ctr_drbg_init returned (-0x0034) CTR_DRBG - The entropy source failed

Details

  1. On real PS3 this code is working as expected without introduced 'previousEntry' check. On RPCS3 'while' keeps looping on the last entry. Based on the result from PS3, i believe that on the next loop after last record read "entry.d_name" should be empty. ``` std::string previousEntry = ""; while (!sysFsReaddir(fd, &entry, &read) && strlen(entry.d_name) > 0) { debugPrintf("Reading directory (%s)....\n", entry.d_name); if(strcmp(previousEntry.c_str(),entry.d_name) == 0){ debugPrintf("Double reading resource (%s) - breaking loop.\n", entry.d_name); break; }

        previousEntry = entry.d_name;
        if (strcmp(entry.d_name, ".") == 0 || strcmp(entry.d_name, "..") == 0) {
            continue;
        }
        ....
     }
    

Attach a log file

RPCS3.log.gz application_debug.log

Attach capture files for visual issues

No response

System configuration

RPCS3 v0.0.24-14316-7ae9b15b Alpha | master AMD Ryzen 7 4800H with Radeon Graphics | 16 Threads | 15.05 GiB RAM | TSC: 2.895GHz | AVX+ | FMA3 Operating system: POSIX, Name: Linux, Release: 5.18.12-arch1-1, Version: #1 SMP PREEMPT_DYNAMIC Fri, 15 Jul 2022 15:33:02 +0000 Qt version: Compiled against Qt 5.15.2 | Run-time uses Qt 5.15.5 Current Time: 2022-10-27T22:00:16

Other details

Emulator called via command: rpcs3 --verbose-curl App installed as a package (.pkg) App has enabled remote debugging on localhost udp port 18194 and can be logged via command ncat -u -l -p 18194 --no-shutdown -o debug.log ps3-cloud-drive.pkg.tar.gz

Diff Delta:
121
About 15 Diff Delta/hour
Classified as:  Bug Fix

digant73's Description of Work #12891 Unexpected behavior vs PS3: sysFsReaddir not breaking loop; cUrl: CELL_ENOTMOUNTED “/dev/urandom”

Fix issues in sysFsReaddir as reported in #12891 plus additional ones

Analysis assisted by Opus 5.

fixes #12891

Issues reported in #12891 already fixed upstream or not a bug:



  1. sysFsReaddir not breaking the loop: Fixed by commit a41d2e43f ("cellFsReaddir: Fix termination sequence", 2023-03-11), about four months after the report.

  2. CELL_ENOTMOUNTED on /dev/urandom: Not a bug. /dev/urandom is a Unix path with no mount point on the PS3 either, so the error is expected. The PolarSSL build inside the homebrew probably goes straight for the POSIX path instead of asking the console, so it was managed differently than on RPCS3.

List of fixes:



  1. . and .. are moved to the front regardless of the position the host returned them in, and the rest is sorted as before.

  2. They are synthesised when the host lists neither. Win32 volume roots are the one directory that does not.


  3. CELL_ENOENT is returned only when a stat does not see a non-reparse directory: an empty Win32 volume root fails the directory search exactly like a missing path, while a broken junction must stay ENOENT.

  4. sys_fs_readdir no longer dereferences the last entry of an empty listing.

  5. Split-file parts are listed only under the merged name: .66600 is renamed, .66601–.66699 are dropped, files only, /dev_hdd1 unchanged.

1 total changed file
Loading changes...
That’s the last hunk
LGTM-land is officially in view