mirror of
https://github.com/quer3q/ps5-dump-forge.git
synced 2026-10-21 13:02:18 -05:00
- PS5 payload (plain .elf): the core runs on the console, built in Docker against the ps5-payload-dev SDK v0.43 (ps5/: target JSON, ps5-ai-cli shims, entry.c, compat.c, linker.sh; FreeBSD 11 ABI via --cfg libc_unstable_freebsd_version="11", struct sizes asserted). - New crate ps5-dump-forge-server and `ps5-dump-forge serve`: the React UI over HTTP on port 8095 (fetch transport, polling, folder/file browser, Show path, Stop), no access control by design. Home-screen tile PDFG00001; the payload saves a copy of itself (two-stage build) so the tile's AppCache'd page can start it through elfldr after a restart. - FreeBSD platform layer in core: destination probe (dest.rs), publish by link or checked rename behind a device guard, bounded dirty data with adaptive fsync cadence (durable.rs), read-ahead (prefetch.rs), drive-removal messages, rest-mode PowerTick. A retried fsync fails the job. - Fast verification is the default on every platform: structure + sampled BLAKE3 slices; "Full verification" switch / --full-verify re-reads every byte; .pkg always full. One hash pass per byte. - vendor patch 0015: UFS2 range reads (cached pointer blocks, contiguous runs, checked offsets). - Tests and tooling: scripts/test-freebsd.sh (FreeBSD VM: UFS, FAT32, nullfs), scripts/release-ps5.sh (ELF, embedded UI, self copy and debug-route checks), CI and release jobs for the .elf. - Hardware (PS5 fw 13.60, /data): .ffpkg/folder sources to .exfat and folder pass their checks; writes ~273 MB/s of the drive's ~288 MB/s; tile launch after a reboot works. Other output formats and USB output are not console-tested yet (TODO.md). Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
76 lines
3.1 KiB
C
76 lines
3.1 KiB
C
/* elfldr maps payloads without a kernel executable pathname. Use the real,
|
|
* validated install path recorded by our installer for this process only.
|
|
*/
|
|
#include <errno.h>
|
|
#include <fcntl.h>
|
|
#include <limits.h>
|
|
#include <stdio.h>
|
|
#include <string.h>
|
|
#include <sys/types.h>
|
|
#include <sys/stat.h>
|
|
#include <sys/sysctl.h>
|
|
#include <unistd.h>
|
|
|
|
static char ps5_executable_path[PATH_MAX];
|
|
int ps5_init_executable_path(void) {
|
|
int fd = open("/data/ps5-ai-cli/codex-path", O_RDONLY | O_NOFOLLOW);
|
|
if (fd < 0) return -1;
|
|
ssize_t length = read(fd, ps5_executable_path, sizeof(ps5_executable_path) - 1);
|
|
close(fd);
|
|
if (length <= 0 || length == sizeof(ps5_executable_path) - 1) goto invalid;
|
|
ps5_executable_path[length] = '\0';
|
|
if (ps5_executable_path[length - 1] == '\n') ps5_executable_path[--length] = '\0';
|
|
const char *prefix = "/data/pldmgr/payloads/codex-service/";
|
|
if (strncmp(ps5_executable_path, prefix, strlen(prefix)) ||
|
|
strstr(ps5_executable_path, "..") || strchr(ps5_executable_path, '\n')) goto invalid;
|
|
fd = open(ps5_executable_path, O_RDONLY | O_NOFOLLOW);
|
|
if (fd < 0) goto invalid;
|
|
unsigned char header[20];
|
|
struct stat info;
|
|
int valid = fstat(fd, &info) == 0 && S_ISREG(info.st_mode) &&
|
|
read(fd, header, sizeof(header)) == sizeof(header) &&
|
|
memcmp(header, "\177ELF\2\1", 6) == 0 &&
|
|
header[16] == 3 && header[17] == 0 && header[18] == 62 && header[19] == 0;
|
|
close(fd);
|
|
if (!valid) goto invalid;
|
|
return 0;
|
|
invalid:
|
|
ps5_executable_path[0] = '\0';
|
|
errno = EINVAL;
|
|
return -1;
|
|
}
|
|
|
|
/* The terminal installer owns this stable runtime path. */
|
|
int ps5_set_executable_path(const char *path) {
|
|
if (strcmp(path, "/data/ps5-ai-cli/runtime/codex.elf")) { errno = EINVAL; return -1; }
|
|
int fd = open(path, O_RDONLY | O_NOFOLLOW);
|
|
if (fd < 0) return -1;
|
|
unsigned char header[20]; struct stat info;
|
|
int valid = !fstat(fd, &info) && S_ISREG(info.st_mode) &&
|
|
read(fd, header, sizeof(header)) == sizeof(header) &&
|
|
!memcmp(header, "\177ELF\2\1", 6) && header[16] == 3 && header[17] == 0 &&
|
|
header[18] == 62 && header[19] == 0;
|
|
close(fd);
|
|
if (!valid) { errno = EINVAL; return -1; }
|
|
snprintf(ps5_executable_path, sizeof(ps5_executable_path), "%s", path);
|
|
return 0;
|
|
}
|
|
|
|
extern int __real_sysctl(const int *, u_int, void *, size_t *, const void *, size_t);
|
|
int __wrap_sysctl(const int *name, u_int count, void *output, size_t *length,
|
|
const void *input, size_t input_length) {
|
|
if (ps5_executable_path[0] && count == 4 && name[0] == CTL_KERN &&
|
|
name[1] == KERN_PROC && name[2] == KERN_PROC_PATHNAME &&
|
|
(name[3] == -1 || name[3] == getpid()) && !input && !input_length) {
|
|
if (!length) { errno = EFAULT; return -1; }
|
|
size_t needed = strlen(ps5_executable_path) + 1;
|
|
size_t available = *length;
|
|
*length = needed;
|
|
if (!output) return 0;
|
|
if (available < needed) { errno = ENOMEM; return -1; }
|
|
memcpy(output, ps5_executable_path, needed);
|
|
return 0;
|
|
}
|
|
return __real_sysctl(name, count, output, length, input, input_length);
|
|
}
|