Skip to content

fix(libSceSystemService): answer the shell core free size calls with the host's disk space - #16787

Merged
oneandonlydean merged 3 commits into
boykopovar:mainfrom
xXPBSXx:k/systemservice-free-size
Nov 11, 2026
Merged

oneandonlydean merged 3 commits into
boykopovar:mainfrom
xXPBSXx:k/systemservice-free-size

Conversation

@xXPBSXx

@xXPBSXx xXPBSXx commented Nov 7, 2026

Copy link
Copy Markdown
Contributor

What

sceShellCoreUtilGetFreeSizeOfUserPartition and sceShellCoreUtilGetFreeSizeOfAvContentsTmp threw 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_version 0x11600005), 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.

call PS5, payload process, firmware 11.60 main before here now
sceShellCoreUtilGetFreeSizeOfUserPartition(&free, &total) 0, free non-zero, total non-zero throws 0, free non-zero, total non-zero
sceShellCoreUtilGetFreeSizeOfAvContentsTmp() non-zero throws non-zero

The new test guest_system_service_free_size checks 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, on main 2150294122 the test commit alone aborts ("sceShellCoreUtilGetFreeSizeOfUserPartition not implemented"), and with the fix commit on the same main it passes in 0.33 s. All 40 guest_system_service* tests pass with this change when leak detection is off; with it on, guest_system_service_usb_storage reports a leak that this change does not touch. tools/check_conventions.py --base upstream/main passes.

Overlap: the 14 other open pull requests that change docs/dev/debt/libSceSystemService.md, PendingExports.cpp, the library's CMakeLists.txt or GuestSystemServiceFreeSize.cpp were checked on 2026-11-07 between 16:05 UTC and 16:12 UTC against main dd00a9c54e (the base of this change is the older 2150294122; it still merges without a conflict); two more (#12848 and #14330) have been merged. Five already conflict with main without 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

  • 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 (system service change)
  • AI-assisted: yes

AI-assisted (Claude Code).

🤖 Generated with Claude Code

xXPBSXx and others added 3 commits November 7, 2026 15:01
… 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>
@xXPBSXx

xXPBSXx commented Nov 7, 2026

Copy link
Copy Markdown
Contributor Author

Probe source (built with ps5-payload-sdk v0.45; PROBE_BUILD is the first 12 hex digits of the source's SHA-256) and the raw output of its two runs. The clock in each PROBE line is the console's own clock, which was about 1 h 41 min ahead of the host clock (runs at 17:49 UTC and 18:19 UTC on 2026-11-06). The first run (build id c6b94207a551) is the same probe without the self-imposed time limit that the second (a5555d3f5f20) adds. Comments translated from German; the code is identical to the one that ran.

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 UTC
PROBE	libSceSystemService_getters	fw=0x11600005	build=c6b94207a551	pid=106	utc=2026-11-06T19:30:29Z
[SceLncUtil] W:\Build\J03675035\vsh\common_lib\lnc_util\src\lnc_util_ipc_client.cpp(382) getAppStatus: LNC_ISOK::0x80940004
CASE	0	load libSceSystemService.sprx	0	3	loaded
CASE	1	sceLncUtilUnblockAppSuspend("anyps5_probe") without a block	-2137784305	0	-
CASE	2	sceLncUtilBlockAppSuspend("anyps5_probe")	-2137784305	0	-
CASE	3	sceLncUtilUnblockAppSuspend("anyps5_probe") after one block	-2137784305	0	-
CASE	4	sceLncUtilUnblockAppSuspend("anyps5_probe") again	-2137784305	0	-
CASE	5	sceShellCoreUtilGetFreeSizeOfUserPartition(&free, &total)	0	0	free=nonzero total=nonzero
CASE	6	sceShellCoreUtilGetFreeSizeOfAvContentsTmp()	1	0	nonzero
CASE	7	sceSystemServiceIsBgmPlaying()	0	0	-
CASE	8	sceShellCoreUtilIsBgmPlaying()	0	0	-
CASE	9	sceShellCoreUtilGetSocialScreenStatus(&active), active preset to 1	0	16	active=0
END	10
raw output, run at 18:19 UTC
PROBE	libSceSystemService_getters	fw=0x11600005	build=a5555d3f5f20	pid=112	utc=2026-11-06T20:00:56Z
[SceLncUtil] W:\Build\J03675035\vsh\common_lib\lnc_util\src\lnc_util_ipc_client.cpp(382) getAppStatus: LNC_ISOK::0x80940004
CASE	0	load libSceSystemService.sprx	0	3	loaded
CASE	1	sceLncUtilUnblockAppSuspend("anyps5_probe") without a block	-2137784305	0	-
CASE	2	sceLncUtilBlockAppSuspend("anyps5_probe")	-2137784305	0	-
CASE	3	sceLncUtilUnblockAppSuspend("anyps5_probe") after one block	-2137784305	0	-
CASE	4	sceLncUtilUnblockAppSuspend("anyps5_probe") again	-2137784305	0	-
CASE	5	sceShellCoreUtilGetFreeSizeOfUserPartition(&free, &total)	0	0	free=nonzero total=nonzero
CASE	6	sceShellCoreUtilGetFreeSizeOfAvContentsTmp()	1	0	nonzero
CASE	7	sceSystemServiceIsBgmPlaying()	0	0	-
CASE	8	sceShellCoreUtilIsBgmPlaying()	0	0	-
CASE	9	sceShellCoreUtilGetSocialScreenStatus(&active), active preset to 1	0	16	active=0
END	10

AI-assisted (Claude Code).

🤖 Generated with Claude Code

@github-actions

github-actions Bot commented Nov 7, 2026 •

Copy link
Copy Markdown

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 18009 core/libs/prx/libSceSystemService/PendingExports.cpp L5

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 8651 core/libs/prx/libSceSystemService/PendingExports.cpp
docs/dev/debt/libSceSystemService.md
PR 14212 docs/dev/debt/libSceSystemService.md
PR 15947 docs/dev/debt/libSceSystemService.md

@github-actions

github-actions Bot commented Nov 7, 2026

Copy link
Copy Markdown

Progress report (dd00a9c → 9273e2c)

📈 System libraries: 31.6% (+0.0053%, +2 implemented functions)

✅ 2 implemented
Library Name
libSceSystemService sceShellCoreUtilGetFreeSizeOfAvContentsTmp
libSceSystemService sceShellCoreUtilGetFreeSizeOfUserPartition

Changed libraries (implemented exports)

Library Before After Change
libSceSystemService 146/617 (23.66%) 148/617 (23.99%) +0.32%

@JJenkx

JJenkx commented Nov 8, 2026

Copy link
Copy Markdown
Contributor

Windows check of head 9273e2c5a0, merged onto main 62e7ca8676 (92378e9245, clean merge).

Setup: Windows 11 Enterprise 22621, WinLibs GCC 15.2 UCRT, Release. The hosted Windows check does not run these tests on pull requests.

  • guest_system_service_free_size passes in 3 of 3 runs, none skipped.

AI-assisted: yes.

@gabichuuuuu

Copy link
Copy Markdown
Contributor

Ran 9273e2c5a0 merged on main 302864d on Windows 11 x64 (WinLibs GCC 15.2), ctest -R '^guest_system_service_free_size$' -V: guest_system_service_free_size passed 3/3 runs.

The test target is registered by this PR, so I couldn't run the new test against main's sources, and this doesn't show that the test fails without the fix. It doesn't open a Vulkan device, so the GPU doesn't matter here.

AI-assisted: yes.

@adriadam10 adriadam10 self-assigned this Nov 11, 2026
@oneandonlydean
oneandonlydean merged commit 5293014 into boykopovar:main Nov 11, 2026
13 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants