Repository navigation
fix(libSceSystemService): answer the shell core free size calls with the host's disk space - #16787
Conversation
… the shell core partition calls On a PS5 (firmware 11.60, payload process) sceShellCoreUtilGetFreeSizeOfUserPartition returns 0 with a non-zero free and total size and sceShellCoreUtilGetFreeSizeOfAvContentsTmp returns a non-zero size. Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
…the host's disk space sceShellCoreUtilGetFreeSizeOfUserPartition and sceShellCoreUtilGetFreeSizeOfAvContentsTmp threw as unimplemented. Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
…sults Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
|
Probe source (built with ps5-payload-sdk v0.45; libSceSystemService getters probe.c (second run)/* Probe K: libSceSystemService getter family (debt libSceSystemService.md lines 77, 78, 160 and 219, main 399e7fb57e).
Only valid output pointers; no null outputs (those may fault in the library). Values that describe the console's
storage are reported only as zero/non-zero. Nothing is written, nothing is sent. */
#include <dlfcn.h>
#include <errno.h>
#include <signal.h>
#include <stdbool.h>
#include <stdint.h>
#include <stdio.h>
#include <string.h>
#include <time.h>
#include <unistd.h>
#include <ps5/kernel.h> /* only for kernel_get_fw_version() */
#ifndef PROBE_NAME
#define PROBE_NAME "unnamed"
#endif
#ifndef PROBE_BUILD
#define PROBE_BUILD "unbuilt"
#endif
/* Self limit: on a timeout the runner can only close the connection, not end the process on the console. The probe
ends itself after at most PROBE_MAX_S seconds (the build script sets the timeout minus 10 s). */
#ifndef PROBE_MAX_S
#define PROBE_MAX_S 50
#endif
static void probe_alarm(int sig) {
static const char msg[] = "TIMEOUT\tprobe self limit\n";
(void)sig;
(void)!write(1, msg, sizeof msg - 1);
_exit(124);
}
static int cases = 0;
static void probe_header(void) {
char utc[32];
time_t now = time(0);
struct tm tmv;
gmtime_r(&now, &tmv);
strftime(utc, sizeof utc, "%Y-%m-%dT%H:%M:%SZ", &tmv);
printf("PROBE\t%s\tfw=0x%08x\tbuild=%s\tpid=%d\tutc=%s\n", PROBE_NAME, kernel_get_fw_version(), PROBE_BUILD,
getpid(), utc);
fflush(stdout);
}
static void probe_case(const char* id, const char* call, long ret, int err, const char* extra) {
printf("CASE\t%s\t%s\t%ld\t%d\t%s\n", id, call, ret, err, extra ? extra : "-");
fflush(stdout);
cases++;
}
static void probe_end(void) {
printf("END\t%d\n", cases);
fflush(stdout);
}
typedef int (*fn_reason)(const char*);
typedef int (*fn_freesize)(uint64_t*, uint64_t*);
typedef uint64_t (*fn_u64void)(void);
typedef int (*fn_intvoid)(void);
typedef int (*fn_boolp)(bool*);
int main(void) {
signal(SIGALRM, probe_alarm);
alarm(PROBE_MAX_S);
char extra[96];
probe_header();
errno = 0;
void* lib = dlopen("libSceSystemService.sprx", RTLD_LAZY);
probe_case("0", "load libSceSystemService.sprx", lib ? 0 : -1, errno, lib ? "loaded" : dlerror());
if (!lib) { probe_end(); return 0; }
fn_reason unblock = (fn_reason)dlsym(lib, "sceLncUtilUnblockAppSuspend");
fn_reason block = (fn_reason)dlsym(lib, "sceLncUtilBlockAppSuspend");
fn_freesize freeSize = (fn_freesize)dlsym(lib, "sceShellCoreUtilGetFreeSizeOfUserPartition");
fn_u64void avTmp = (fn_u64void)dlsym(lib, "sceShellCoreUtilGetFreeSizeOfAvContentsTmp");
fn_intvoid ssBgm = (fn_intvoid)dlsym(lib, "sceSystemServiceIsBgmPlaying");
fn_intvoid scuBgm = (fn_intvoid)dlsym(lib, "sceShellCoreUtilIsBgmPlaying");
fn_boolp social = (fn_boolp)dlsym(lib, "sceShellCoreUtilGetSocialScreenStatus");
if (unblock) { errno = 0; long r = unblock("anyps5_probe"); probe_case("1", "sceLncUtilUnblockAppSuspend(\"anyps5_probe\") without a block", r, errno, "-"); }
else probe_case("1", "dlsym(sceLncUtilUnblockAppSuspend)", -1, 0, "missing");
if (block && unblock) {
errno = 0; long r = block("anyps5_probe"); probe_case("2", "sceLncUtilBlockAppSuspend(\"anyps5_probe\")", r, errno, "-");
errno = 0; r = unblock("anyps5_probe"); probe_case("3", "sceLncUtilUnblockAppSuspend(\"anyps5_probe\") after one block", r, errno, "-");
errno = 0; r = unblock("anyps5_probe"); probe_case("4", "sceLncUtilUnblockAppSuspend(\"anyps5_probe\") again", r, errno, "-");
} else probe_case("2", "dlsym(sceLncUtilBlockAppSuspend)", -1, 0, "missing");
if (freeSize) {
uint64_t f = 0, t = 0; errno = 0; long r = freeSize(&f, &t);
snprintf(extra, sizeof extra, "free=%s total=%s", f ? "nonzero" : "0", t ? "nonzero" : "0");
probe_case("5", "sceShellCoreUtilGetFreeSizeOfUserPartition(&free, &total)", r, errno, extra);
} else probe_case("5", "dlsym(sceShellCoreUtilGetFreeSizeOfUserPartition)", -1, 0, "missing");
if (avTmp) { errno = 0; uint64_t v = avTmp(); probe_case("6", "sceShellCoreUtilGetFreeSizeOfAvContentsTmp()", v ? 1 : 0, errno, v ? "nonzero" : "0"); }
else probe_case("6", "dlsym(sceShellCoreUtilGetFreeSizeOfAvContentsTmp)", -1, 0, "missing");
if (ssBgm) { errno = 0; long r = ssBgm(); probe_case("7", "sceSystemServiceIsBgmPlaying()", r, errno, "-"); }
else probe_case("7", "dlsym(sceSystemServiceIsBgmPlaying)", -1, 0, "missing");
if (scuBgm) { errno = 0; long r = scuBgm(); probe_case("8", "sceShellCoreUtilIsBgmPlaying()", r, errno, "-"); }
else probe_case("8", "dlsym(sceShellCoreUtilIsBgmPlaying)", -1, 0, "missing");
if (social) {
bool active = true; errno = 0; long r = social(&active);
snprintf(extra, sizeof extra, "active=%d", (int)active);
probe_case("9", "sceShellCoreUtilGetSocialScreenStatus(&active), active preset to 1", r, errno, extra);
} else probe_case("9", "dlsym(sceShellCoreUtilGetSocialScreenStatus)", -1, 0, "missing");
probe_end();
return 0;
}raw output, run at 17:49 UTCraw output, run at 18:19 UTCAI-assisted (Claude Code). 🤖 Generated with Claude Code |
|
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.
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.
|
Progress report (dd00a9c → 9273e2c)📈 System libraries: 31.6% (+0.0053%, +2 implemented functions) ✅ 2 implemented
Changed libraries (implemented exports)
|
|
Windows check of head Setup: Windows 11 Enterprise 22621, WinLibs GCC 15.2 UCRT, Release. The hosted Windows check does not run these tests on pull requests.
AI-assisted: yes. |
|
Ran The test target is registered by this PR, so I couldn't run the new test against AI-assisted: yes. |
What
sceShellCoreUtilGetFreeSizeOfUserPartitionandsceShellCoreUtilGetFreeSizeOfAvContentsTmpthrew as unimplemented. On a PS5 the first returns 0 with a non-zero free and total size and the second returns a non-zero size. They now return the available and total bytes of the host disk that holds the working directory (the partition call) and the available bytes (the other call). The exact values, the units and what the partition covers were not measured, and the debt entry says so. No title checked calls these functions.Tested
Measured on a PS5 with firmware 11.60 (
kernel_get_fw_version0x11600005), from a homebrew payload process (ps5-payload-sdk v0.45, elfldr), on 2026-11-06 at 17:49 UTC and 18:19 UTC (two runs, identical); the console's own clock read about 1 h 41 min more (see the first comment). Only zero versus non-zero was recorded. A title process may differ.mainbeforesceShellCoreUtilGetFreeSizeOfUserPartition(&free, &total)sceShellCoreUtilGetFreeSizeOfAvContentsTmp()The new test
guest_system_service_free_sizechecks the return value, that both sizes are non-zero and that free is not above total. On Ubuntu 24.04 under WSL2 with GCC 13.3.0 and an AddressSanitizer build, onmain2150294122the test commit alone aborts ("sceShellCoreUtilGetFreeSizeOfUserPartition not implemented"), and with the fix commit on the samemainit passes in 0.33 s. All 40guest_system_service*tests pass with this change when leak detection is off; with it on,guest_system_service_usb_storagereports a leak that this change does not touch.tools/check_conventions.py --base upstream/mainpasses.Overlap: the 14 other open pull requests that change
docs/dev/debt/libSceSystemService.md,PendingExports.cpp, the library'sCMakeLists.txtorGuestSystemServiceFreeSize.cppwere checked on 2026-11-07 between 16:05 UTC and 16:12 UTC againstmaindd00a9c54e(the base of this change is the older2150294122; it still merges without a conflict); two more (#12848 and #14330) have been merged. Five already conflict withmainwithout this change (#15947 and #8651 in the debt file, #16463, #14212 and #12315 in other files), and none conflicts only with this change. The other nine merge cleanly with and without it, among them #16546, which edits another entry of the debt file.Checklist
main; no other open PR implements the same functionsNotImplemented_nid_no_patch); silent stubs are listed under Silent stubs in their library's technical debt file.mdfiles or images added to the repository (attach them to this PR)AI-assisted (Claude Code).
🤖 Generated with Claude Code