Skip to content

Play your Steam library's Windows games on a jailbroken PS5.

C++

Remove the FAKE77031 tile once Playden runs as PPSA97031

Leonardo Lobatoa27ed72faf08
diff --git a/dependencies.lock.json b/dependencies.lock.json
index 1b4cf7b..26fdff2 100644
--- a/dependencies.lock.json
+++ b/dependencies.lock.json
@@ -21,7 +21,7 @@
"source": "third_party/PS5-Lapy-JB-Daemon submodule, fork branch main at owned_title_revision; build with scripts/build-lapy-helper.sh"
},
"title_remover": {
- "sha256": "b39725072337816d4c6d2b159849df5e5a3d86505b7450357d774cc8d8f90ca0",
+ "sha256": "5a452a90476a582b230504a841be863c6966187f998f7c29b4f222b7f2524deb",
"payload_sdk": "ps5_payload_sdk",
"source": "tools/title-remover/main.c; build with scripts/build-title-remover.sh (reproducible; sent by Playden to the payload loader on 127.0.0.1:9021)"
},
diff --git a/src/homebrew/ps5.cpp b/src/homebrew/ps5.cpp
index 599a0c2..5c69f8a 100644
--- a/src/homebrew/ps5.cpp
+++ b/src/homebrew/ps5.cpp
@@ -10,6 +10,7 @@
#include "stores/local/copy_runner.h"
#include "stores/local/library_source.h"
#include "app/diagnostic_log.h"
+#include "platform/ps5/title_database.h"
#include "platform/ps5/title_registry.h"
#include "platform/ps5/title_remover.h"
#include "platform/ps5/title_runtime.h"
@@ -41,6 +42,9 @@
#include "platform/ps5/system.hpp"
#include <array>
+#include <cerrno>
+#include <chrono>
+#include <thread>
#include <atomic>
#include <cstdio>
#include <cstdlib>
@@ -406,6 +410,36 @@ int main() {
return added && added->find("\"status\":0") != std::string::npos;
};
}
+ // Moved here from FAKE77031: the old title's folder and tile go once it holds no player data.
+ if (std::string(PLAYDEN_PS5_TITLE_ID) == "PPSA97031") {
+ update_config.predecessor_title_id = "FAKE77031";
+ update_config.predecessor_root = "/data/homebrew/FAKE77031";
+ update_config.unregister_title = [title_root = paths.title_root](const std::string& title) {
+ const auto gone = [&title] {
+ struct stat info{};
+ return playden::ps5::ReadNativeTitleDatabase(title).inventory == playden::runtime::TitleAvailability::kFree &&
+ lstat(("/user/app/" + title).c_str(), &info) != 0 && errno == ENOENT;
+ };
+ // Its manual source goes first: ShadowMountPlus would add the title again from it.
+ playden::ps5::ShadowMountPost("/api/v1/manual/remove", "{\"path\":\"/data/homebrew/" + title + "\"}");
+ if (gone()) return true;
+ // ShadowMountPlus refuses to uninstall while a title runs: the title remover payload does it.
+ playden::ps5::TitleRemoverConfig remover;
+ remover.payload = title_root + "/title-remover.elf";
+ remover.send = playden::ps5::SendToPayloadLoader;
+ char nonce[24];
+ std::snprintf(nonce, sizeof nonce, "%016llx",
+ static_cast<unsigned long long>(std::chrono::steady_clock::now().time_since_epoch().count()));
+ // The request is written as the app's user: no other thread raises root meanwhile.
+ remover.hold_user = playden::ps5::HoldEffectiveUid;
+ const auto outcome = playden::ps5::RunTitleRemover(remover, title, nonce);
+ playden::app::AppendLogLine(log_root, "update.log", "self-update: title remover for " + title + " sent=" +
+ std::to_string(outcome.sent) + " code=" + (outcome.code ? std::to_string(*outcome.code) : "none") +
+ " detail=" + outcome.detail);
+ for (int poll = 0; poll < 60 && !gone(); ++poll) std::this_thread::sleep_for(std::chrono::milliseconds(250));
+ return gone();
+ };
+ }
update_config.appmeta_root = std::string("/user/appmeta/") + PLAYDEN_PS5_TITLE_ID;
update_config.registered_app_root = std::string("/user/app/") + PLAYDEN_PS5_TITLE_ID;
update_config.layout_journal = "/data/playden/runtime-state/layout-0.6.json";
diff --git a/src/platform/ps5/title_remover.cpp b/src/platform/ps5/title_remover.cpp
index c0946df..51633d2 100644
--- a/src/platform/ps5/title_remover.cpp
+++ b/src/platform/ps5/title_remover.cpp
@@ -55,6 +55,7 @@ bool WriteRequest(const std::filesystem::path& directory, const std::string& tex
TitleRemoverOutcome RunTitleRemover(const TitleRemoverConfig& config, const std::string& title, const std::string& nonce) {
TitleRemoverOutcome outcome;
const auto& directory = config.request_directory;
+ auto held = config.hold_user ? config.hold_user() : nullptr;
// The payload trusts only a directory owned by Playden's user that others cannot write.
struct stat info{};
if (lstat(directory.c_str(), &info) != 0) {
@@ -74,6 +75,7 @@ TitleRemoverOutcome RunTitleRemover(const TitleRemoverConfig& config, const std:
outcome.detail = "request could not be written";
return outcome;
}
+ held.reset();
const auto payload = ReadNoFollow(config.payload, kMaxPayload);
if (!payload || payload->size() < 4 || payload->compare(0, 4, "\x7f" "ELF") != 0) {
outcome.detail = "payload missing";
diff --git a/src/platform/ps5/title_remover.h b/src/platform/ps5/title_remover.h
index 5a9a67f..d2ad37b 100644
--- a/src/platform/ps5/title_remover.h
+++ b/src/platform/ps5/title_remover.h
@@ -5,6 +5,7 @@
#include <chrono>
#include <filesystem>
#include <functional>
+#include <memory>
#include <optional>
#include <string>
@@ -24,11 +25,14 @@ struct TitleRemoverConfig {
std::filesystem::path payload; // <title root>/title-remover.elf
// Sends the payload's bytes to the payload loader; false with a reason on failure.
std::function<bool(const std::string& elf, std::string* error)> send;
+ // Keeps root from being raised elsewhere while the request is written as the app's user (the
+ // folder's owner check and the write compare against the effective UID). Optional.
+ std::function<std::shared_ptr<void>()> hold_user;
int result_polls = 60;
std::chrono::milliseconds result_interval{250};
};
-// Writes the request for title_id (FAKE78xxx) and nonce, sends the payload and
+// Writes the request for title_id (FAKE78xxx, or FAKE77031) and nonce, sends the payload and
// waits (bounded) for its answer. Worker only. The answer only reports what the
// payload saw; the caller confirms removal in the console inventory.
TitleRemoverOutcome RunTitleRemover(const TitleRemoverConfig& config, const std::string& title_id,
diff --git a/src/update/update_service.cpp b/src/update/update_service.cpp
index b9af1af..96cd59a 100644
--- a/src/update/update_service.cpp
+++ b/src/update/update_service.cpp
@@ -1,5 +1,6 @@
#include "update/update_service.h"
+#include <dirent.h>
#include <pthread.h>
#include <sys/stat.h>
#include <unistd.h>
@@ -21,7 +22,7 @@ struct UpdateService::Shared {
UpdateSnapshot snapshot;
std::atomic<bool> cancel{false};
std::atomic<bool> busy{false};
- std::function<void()> queued; // one job asked for while another ran (under mutex)
+ std::vector<std::function<void()>> queued; // jobs asked for while another ran, in order (under mutex)
bool thread_started = false;
pthread_t thread{};
};
@@ -241,6 +242,16 @@ void UpdateService::RetireRenamedKits() {
// The app user's leftovers of a confirmed update, on the worker and without root: the stage, the
// downloads, the replaced entries and the files of a kit left by going back.
+namespace {
+// The titleId in a folder's sce_sys/param.json, or empty.
+std::string ParamTitle(const std::string& folder) {
+ std::string text;
+ const auto param = ReadSmallFile(folder + "/sce_sys/param.json", &text) ? steam::json::Parse(text) : std::nullopt;
+ const auto* title = param && param->is_object() ? param->Find("titleId") : nullptr;
+ return title && title->is_string() ? title->text() : std::string();
+}
+} // namespace
+
void UpdateService::CleanUpLeftovers() {
std::vector<std::string> paths;
for (const char* name : {"/stage", "/downloads", "/replaced"})
@@ -262,10 +273,10 @@ bool UpdateService::RemoveOwnedTree(const std::string& path) {
void UpdateService::Run(std::function<void()> work) {
{
// A job asked for while another runs waits for it (the startup check behind the cleanup of a
- // confirmed update, an install behind a check); a third request replaces nothing.
+ // confirmed update and the old title's removal, an install behind a check).
std::lock_guard<std::mutex> lock(shared_->mutex);
if (shared_->busy) {
- if (!shared_->queued) shared_->queued = std::move(work);
+ shared_->queued.push_back(std::move(work));
return;
}
shared_->busy = true;
@@ -282,12 +293,12 @@ void UpdateService::Run(std::function<void()> work) {
std::function<void()> next;
{
std::lock_guard<std::mutex> lock(shared->mutex);
- next = std::move(shared->queued);
- shared->queued = nullptr;
- if (!next) {
+ if (shared->queued.empty()) {
shared->busy = false;
return;
}
+ next = std::move(shared->queued.front());
+ shared->queued.erase(shared->queued.begin());
}
if (!shared->cancel) next();
}
@@ -302,7 +313,7 @@ void UpdateService::Run(std::function<void()> work) {
{
std::lock_guard<std::mutex> lock(shared_->mutex);
shared_->busy = false;
- shared_->queued = nullptr;
+ shared_->queued.clear();
}
Fail("Playden could not start the update.", "pthread_create " + std::to_string(rc));
return;
@@ -335,6 +346,9 @@ std::optional<UpdateService::Backup> UpdateService::LatestBackup() const {
const auto version = dash == std::string::npos ? std::nullopt : ParseVersion(name.substr(0, dash));
const std::string path = config_.work_root + "/backup/" + name;
if (!version || !Exists(path + "/eboot.bin")) continue;
+ // Another title's app (from before a move) never goes into this title's folder.
+ const auto title = ParamTitle(path);
+ if (!title.empty() && title != config_.title_id) continue;
// Names end in the swap time; the newest has the largest.
const auto stamp = name.substr(dash + 1);
if (!latest || stamp.size() > latest_name.size() || (stamp.size() == latest_name.size() && stamp > latest_name)) {
@@ -398,6 +412,107 @@ std::string UpdateService::RelaunchTitle() const {
return snapshot.restart_requested && !snapshot.rollback_requested && Moving() ? staged_title_ : config_.title_id;
}
+std::string UpdateService::PredecessorRefusal() const {
+ const std::string& root = config_.predecessor_root;
+ std::string text;
+ if (!ReadSmallFile(root + "/playden-version", &text, 64)) return "no playden-version";
+ if (!text.empty() && text.back() == '\n') text.pop_back();
+ const auto version = ParseVersion(text);
+ // Before 0.6.0 the sign-in, games and logs lived in the app folder.
+ if (!version || *version < kLayoutBoundary) return "version " + text + " keeps its data in the app folder";
+ // A move to the 0.6 layout that never ran (the old version was never opened) leaves them there too.
+ // A folder that can't be read may hold them as well.
+ for (const char* data : {"/games", "/playden-data"}) {
+ DIR* folder = opendir((root + data).c_str());
+ if (!folder) {
+ if (errno == ENOENT) continue;
+ return std::string(data + 1) + " can't be read (errno=" + std::to_string(errno) + ")";
+ }
+ bool empty = true;
+ while (const dirent* entry = readdir(folder)) {
+ const std::string name = entry->d_name;
+ if (name != "." && name != ".." && name != "MOVED.txt") empty = false;
+ }
+ closedir(folder);
+ if (!empty) return std::string(data + 1) + " is not empty";
+ }
+ return {};
+}
+
+void UpdateService::RetirePredecessor() {
+ const std::string& title = config_.predecessor_title_id;
+ if (title.empty() || config_.predecessor_root.empty() || !config_.unregister_title) return;
+ const std::string retired = config_.work_root + "/retired/" + title;
+ const std::string unregistered = retired + ".unregistered";
+ if (Exists(unregistered)) {
+ if (RemoveOwnedTree(retired)) unlink(unregistered.c_str());
+ Log(Exists(retired) ? "the old " + title + " app could not be deleted" : "the old " + title + " app is deleted");
+ }
+ if (Exists(config_.predecessor_root + "/eboot.bin") && !Exists(retired)) {
+ // Right after the move the old app stays one more start: if this title fails before it has started
+ // once, the old one still works (it only points to this one).
+ std::string moving;
+ const auto pending = ReadSmallFile(StatePath(), &moving) ? steam::json::Parse(moving) : std::nullopt;
+ const auto pending_field = [&](const char* name) -> std::string {
+ const auto* value = pending && pending->is_object() ? pending->Find(name) : nullptr;
+ return value && value->is_string() ? value->text() : std::string();
+ };
+ if (pending_field("phase") == "applied" && pending_field("moved_to") == config_.title_id) {
+ Log("the old " + title + " app stays until this one has started once");
+ return;
+ }
+ const auto refusal = PredecessorRefusal();
+ if (!refusal.empty()) {
+ Log(title + " left in place: " + refusal);
+ return;
+ }
+ // ShadowMountPlus registers any folder in /data/homebrew again, so the folder leaves first. Root is
+ // process-wide: it is raised here, before the runtime starts (see ConfirmApplied).
+ const bool moved = MakeFolders(config_.work_root + "/retired") && config_.as_root([&] {
+ return rename(config_.predecessor_root.c_str(), retired.c_str()) == 0;
+ });
+ Log(moved ? "the old " + title + " app left /data/homebrew" : "the old " + title + " app could not be moved");
+ if (!moved) return;
+ // Its backups are of the old title's app, which this title must never restore into its folder.
+ for (const auto& name : ListFolder(config_.work_root + "/backup"))
+ if (ParamTitle(config_.work_root + "/backup/" + name) == title) RemoveOwnedTree(config_.work_root + "/backup/" + name);
+ // So is an update it staged (states from before 0.7.1 name no owner); only its move to this title stays.
+ std::string text;
+ const auto state = ReadSmallFile(StatePath(), &text) ? steam::json::Parse(text) : std::nullopt;
+ const auto field = [&](const char* name) -> std::string {
+ const auto* value = state && state->is_object() ? state->Find(name) : nullptr;
+ return value && value->is_string() ? value->text() : std::string();
+ };
+ const bool its = field("owner").empty() || field("owner") == title;
+ if (state && its && !(field("phase") == "applied" && field("moved_to") == config_.title_id)) {
+ Log("the old " + title + " app's update state is removed");
+ if (field("phase") == "staged") {
+ if (!field("stage").empty()) RemoveOwnedTree(field("stage"));
+ if (!field("kit").empty()) RemoveOwnedTree(field("kit"));
+ }
+ unlink(StatePath().c_str());
+ }
+ }
+ // Its tile goes from the worker once Start's own root work is over (root is process-wide; the title
+ // remover's request is written as the app's user).
+ unregister_pending_ = Exists(retired) && !Exists(unregistered);
+}
+
+void UpdateService::UnregisterPredecessor() {
+ const std::string& title = config_.predecessor_title_id;
+ const std::string retired = config_.work_root + "/retired/" + title;
+ const std::string unregistered = retired + ".unregistered";
+ if (!config_.unregister_title(title)) {
+ Log(title + " is still registered: tried again at the next start");
+ return;
+ }
+ WriteFileAtomically(unregistered, "");
+ // Most of the app's files are the app user's to delete; what is left goes at the next start, as root.
+ RemoveTree(retired);
+ if (!Exists(retired)) unlink(unregistered.c_str());
+ Log(title + " is unregistered");
+}
+
DownloadOptions UpdateService::Downloads(const std::string& part) {
DownloadOptions options;
options.fetch = config_.fetch;
@@ -429,6 +544,11 @@ std::string UpdateService::ReadyKit(const KitPart& kit) const {
}
void UpdateService::Start() {
+ StartState();
+ if (unregister_pending_) Run([this] { UnregisterPredecessor(); });
+}
+
+void UpdateService::StartState() {
// The successor title is installed (this title moved to it, or it came from ProsperoStore): updates,
// kits and the shared update state are its business now, and this title points the player to it.
if (!config_.successor_root.empty() && Exists(config_.successor_root + "/eboot.bin")) {
@@ -460,6 +580,7 @@ void UpdateService::Start() {
: "new title registration not answered"); });
return;
}
+ RetirePredecessor();
FindPrevious();
LoadCurrentNotes();
RemoveReplacedKits();
@@ -481,7 +602,8 @@ void UpdateService::Start() {
};
const std::string phase = field("phase");
// Another title's state (the two share the work folder after a move) is left alone, except the move to this one.
- const std::string owner = field("owner");
+ // Every version of a title that replaced another names the owner; a state without one is the old title's.
+ const std::string owner = field("owner").empty() ? config_.predecessor_title_id : field("owner");
if (!owner.empty() && owner != config_.title_id && !(phase == "applied" && field("moved_to") == config_.title_id)) {
Log("update state of " + owner + " left alone");
return;
diff --git a/src/update/update_service.h b/src/update/update_service.h
index c064f24..76e60a9 100644
--- a/src/update/update_service.h
+++ b/src/update/update_service.h
@@ -39,6 +39,12 @@ struct UpdateConfig {
std::string successor_title_id;
std::string successor_root; // /data/homebrew/PPSA97031
std::function<bool(const std::string& folder)> register_title;
+ // The title this one replaced (PPSA97031 builds: FAKE77031). Start moves its app folder out of
+ // /data/homebrew once it holds no player data, and unregister_title removes its tile: true once the
+ // console no longer lists it. The folder is deleted at the next start. Empty: nothing replaced.
+ std::string predecessor_title_id;
+ std::string predecessor_root; // /data/homebrew/FAKE77031
+ std::function<bool(const std::string& title)> unregister_title;
std::string appmeta_root; // /user/appmeta/FAKE77031
std::string registered_app_root; // /user/app/FAKE77031
// The 0.6 layout move's record (/data/playden/runtime-state/layout-0.6.json). While it exists,
@@ -198,6 +204,14 @@ class UpdateService {
void SwapKitBack(const std::string& installed_kit, const std::string& previous_kit);
// Whether a staged update moves Playden to the successor title.
bool Moving() const;
+ // Start without the background work it leaves for the worker.
+ void StartState();
+ // Removes the predecessor title: its folder leaves /data/homebrew now, its tile in the background
+ // (UnregisterPredecessor, queued by Start).
+ void RetirePredecessor();
+ void UnregisterPredecessor();
+ // Why the predecessor's folder must stay (it may hold player data), or empty.
+ std::string PredecessorRefusal() const;
// Why going back to `to` is refused (it can't read the 0.6 data layout), or empty.
std::string LayoutRefusal(const Version& to) const;
void FindPrevious();
@@ -238,6 +252,7 @@ class UpdateService {
// folder with its kit id (empty when the installed kit is already the release's).
// The successor title is installed: this title no longer updates or installs kits.
bool superseded_ = false;
+ bool unregister_pending_ = false;
std::string staged_folder_;
std::string staged_title_;
Version staged_version_;
diff --git a/tests/self_update_service_test.cpp b/tests/self_update_service_test.cpp
index ac9b8db..ada4358 100644
--- a/tests/self_update_service_test.cpp
+++ b/tests/self_update_service_test.cpp
@@ -1214,6 +1214,130 @@ int main() {
}
RemoveTree(fixture.root);
}
+ // The new title removes the old one: its folder leaves /data/homebrew at the start, its tile in the
+ // background (retried at the next start), and its files at the start after that.
+ {
+ Fixture fixture;
+ fixture.root = zip_fixture::TempFolder("service-retire");
+ const std::string old_app = fixture.root + "/homebrew/FAKE77031";
+ const std::string retired = fixture.root + "/playden/self-update/retired/FAKE77031";
+ const std::string state = fixture.root + "/playden/self-update/state.json";
+ const std::string stage = fixture.root + "/playden/self-update/stage/0.7.2";
+ const auto old_title = [&](const std::string& version) {
+ Put(old_app + "/eboot.bin", "eboot old");
+ Put(old_app + "/playden-version", version + "\n");
+ Put(old_app + "/games-MOVED.txt", "moved");
+ CHECK(MakeFolders(old_app + "/playden-data") && MakeFolders(old_app + "/logs"));
+ };
+ old_title("0.7.1");
+ // Right after the move it stays one more start (the move is confirmed at this start).
+ {
+ const std::string moved = R"({"phase":"applied","owner":"FAKE77031","version":"0.8.1","from":"0.7.1","moved_to":"PPSA97031","kit_id":"kitid","previous_kit":"","next_kit":""})";
+ Put(state, moved);
+ auto first = fixture.Config({0, 8, 1});
+ first.title_id = "PPSA97031";
+ first.installed_root = fixture.root + "/homebrew/PPSA97031";
+ first.predecessor_title_id = "FAKE77031";
+ first.predecessor_root = old_app;
+ first.unregister_title = [](const std::string&) { CHECK(false); return false; };
+ first.as_root = [](const std::function<bool()>& work) { return work(); };
+ UpdateService service(first);
+ service.Start();
+ Wait(service);
+ CHECK(Read(old_app + "/eboot.bin") == "eboot old" && !Exists(retired));
+ CHECK(service.Snapshot().finished_message == "Playden was updated to 0.8.1." && !Exists(state));
+ }
+ Put(fixture.root + "/playden/self-update/backup/0.7.0-900/eboot.bin", "eboot 0.7.0");
+ Put(fixture.root + "/playden/self-update/backup/0.7.0-900/sce_sys/param.json", R"({"titleId":"FAKE77031"})");
+ Put(fixture.root + "/playden/self-update/backup/0.8.0-950/eboot.bin", "eboot 0.8.0");
+ Put(fixture.root + "/playden/self-update/backup/0.8.0-950/sce_sys/param.json", R"({"titleId":"PPSA97031"})");
+ // An update the old title staged, before states named their owner.
+ Put(stage + "/eboot.bin", "eboot 0.7.2");
+ Put(state, R"({"phase":"staged","version":"0.7.2","stage":")" + stage + R"("})");
+ std::vector<std::string> unregistered;
+ std::mutex unregistered_mutex;
+ bool answer = false;
+ const auto config = [&] {
+ auto config = fixture.Config({0, 8, 1});
+ config.title_id = "PPSA97031";
+ config.installed_root = fixture.root + "/homebrew/PPSA97031";
+ config.predecessor_title_id = "FAKE77031";
+ config.predecessor_root = old_app;
+ config.unregister_title = [&](const std::string& title) {
+ std::lock_guard<std::mutex> lock(unregistered_mutex);
+ unregistered.push_back(title);
+ return answer;
+ };
+ config.as_root = [](const std::function<bool()>& work) { return work(); };
+ return config;
+ };
+ {
+ UpdateService service(config());
+ service.Start();
+ // Moved at once; the old app's backup and staged update go, this title's backup stays.
+ CHECK(!Exists(old_app) && Read(retired + "/eboot.bin") == "eboot old");
+ CHECK(!Exists(state) && !Exists(stage));
+ CHECK(!Exists(fixture.root + "/playden/self-update/backup/0.7.0-900"));
+ CHECK(service.Snapshot().previous == "0.8.0");
+ Wait(service);
+ CHECK(unregistered.size() == 1 && unregistered[0] == "FAKE77031" && Exists(retired));
+ }
+ answer = true;
+ {
+ UpdateService service(config());
+ service.Start();
+ Wait(service);
+ CHECK(unregistered.size() == 2 && !Exists(retired) && !Exists(retired + ".unregistered"));
+ }
+ {
+ UpdateService service(config());
+ service.Start();
+ Wait(service);
+ CHECK(unregistered.size() == 2); // nothing left to do
+ }
+ // An old title that still holds player data, or keeps it in its folder, stays as it is.
+ old_title("0.7.1");
+ Put(old_app + "/playden-data/session.v1", "session");
+ {
+ UpdateService service(config());
+ service.Start();
+ Wait(service);
+ CHECK(Read(old_app + "/eboot.bin") == "eboot old" && !Exists(retired) && unregistered.size() == 2);
+ }
+ RemoveTree(old_app + "/playden-data/session.v1");
+ // Games left in its folder, or a data folder that can't be read, keep it too.
+ Put(old_app + "/games/220/game.exe", "game");
+ {
+ UpdateService service(config());
+ service.Start();
+ Wait(service);
+ CHECK(Read(old_app + "/eboot.bin") == "eboot old" && !Exists(retired) && unregistered.size() == 2);
+ }
+ RemoveTree(old_app + "/games");
+ Put(old_app + "/games", "not a folder");
+ {
+ UpdateService service(config());
+ service.Start();
+ Wait(service);
+ CHECK(Read(old_app + "/eboot.bin") == "eboot old" && !Exists(retired) && unregistered.size() == 2);
+ }
+ RemoveTree(old_app + "/games");
+ old_title("0.5.0");
+ {
+ // Its state names no owner and is not this title's: an applied update of the old title is left alone.
+ const std::string applied = R"({"phase":"applied","version":"0.5.1","from":"0.5.0","backup":")" + fixture.root +
+ R"(/playden/self-update/backup/0.5.0-800","stage":")" + stage + R"("})";
+ Put(state, applied);
+ Put(fixture.root + "/playden/self-update/backup/0.5.0-800/eboot.bin", "eboot 0.5.0");
+ UpdateService service(config());
+ service.Start();
+ Wait(service);
+ CHECK(Read(old_app + "/eboot.bin") == "eboot old" && !Exists(retired) && unregistered.size() == 2);
+ CHECK(Read(state) == applied && !Exists(fixture.root + "/homebrew/PPSA97031/eboot.bin"));
+ CHECK(service.Snapshot().finished_message.empty());
+ }
+ RemoveTree(fixture.root);
+ }
// A staged move that this build can't make (no successor) is dropped.
{
Fixture fixture;
diff --git a/tools/title-remover/main.c b/tools/title-remover/main.c
index e4782be..3aeedbe 100644
--- a/tools/title-remover/main.c
+++ b/tools/title-remover/main.c
@@ -5,7 +5,8 @@
// Playden (FAKE77031) cannot load libSceAppInstUtil itself, and ShadowMountPlus
// refuses to uninstall while any title runs. This payload, which Playden sends to
// the payload loader on 127.0.0.1:9021, unregisters one of Playden's game titles
-// (FAKE78xxx) and exits. It reads one request from REQUEST_DIR:
+// (FAKE78xxx), or Playden's old title FAKE77031 once Playden runs as PPSA97031,
+// and exits. It reads one request from REQUEST_DIR:
//
// request "title=FAKE78002\nnonce=<16..64 of [0-9a-f-]>\n"
//
@@ -42,6 +43,7 @@ static int private_entry(const char *path, uid_t owner, int directory) {
}
static int valid_title(const char *title) {
+ if (strcmp(title, "FAKE77031") == 0) return 1;
if (strlen(title) != 9 || strncmp(title, "FAKE78", 6) != 0) return 0;
for (int i = 6; i < 9; ++i)
if (title[i] < '0' || title[i] > '9') return 0;