Skip to content

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

C++

Start when /data drops the sticky bit; show the full error

Leonardo Lobatof96c3737d8a4
diff --git a/src/homebrew/view.cpp b/src/homebrew/view.cpp
index 6b025ff..53af572 100644
--- a/src/homebrew/view.cpp
+++ b/src/homebrew/view.cpp
@@ -1068,8 +1068,8 @@ class Render::Impl
for (const ViewRow &row : view.rows)
if (row.kind == RowKind::Status)
{
- ui::paragraph(scene_, fonts_.regular, row.title, 96.0F, y, 22.0F, 1180.0F, 30.0F, kAmber, 2);
- y += 92.0F;
+ // The whole error: it is what the player reports, so it is never cut short.
+ y = ui::paragraph(scene_, fonts_.regular, row.title, 96.0F, y, 22.0F, 1180.0F, 30.0F, kAmber, 12) + 32.0F;
}
draw_actions(view, 96.0F, y, 560.0F);
return;
diff --git a/src/runtime/writable_folders.cpp b/src/runtime/writable_folders.cpp
index fd501c2..025dd75 100644
--- a/src/runtime/writable_folders.cpp
+++ b/src/runtime/writable_folders.cpp
@@ -11,6 +11,7 @@
#include <fcntl.h>
#include <sys/stat.h>
#include <unistd.h>
+#include <vector>
namespace playden::runtime {
namespace {
@@ -60,7 +61,8 @@ std::string EnsureWritableFolders(const std::vector<std::filesystem::path>& fold
if (!S_ISDIR(info.st_mode)) continue;
const int first = Probe(folder);
const mode_t mode = RepairMode(folder, namespace_root);
- if (first == 0 && (!mode || (info.st_mode & 07777) == mode)) continue;
+ // The sticky bit is not compared: the PS5's /data drops it.
+ if (first == 0 && (!mode || (info.st_mode & 0777) == (mode & 0777))) continue;
int fix_error = 0;
bool ran = false;
const auto repair = [&] {
@@ -102,24 +104,38 @@ std::string PrepareRuntimeRoot(const std::filesystem::path& root, const Writable
const std::function<void(const std::string&)>& log,
const std::filesystem::path& namespace_root) {
if (root != namespace_root / "data/playden") return "Playden can't fix this runtime folder.";
+ // The step that failed and its errno, for the startup screen: the log may not be writable yet.
+ std::string failed = "root access";
+ int failed_error = 0;
+ std::vector<std::string> notes;
const bool prepared = as_root && as_root([&] {
+ const auto fail = [&](const char* step) { failed = step; failed_error = errno; return false; };
const int parent = platform::OpenDirectoryWalk(root.parent_path());
- if (parent < 0) return false;
+ if (parent < 0) return fail("open /data");
int fd = platform::OpenWalkChild(parent, "playden", O_RDONLY | O_DIRECTORY | O_NOFOLLOW | O_CLOEXEC);
if (fd < 0 && errno == ENOENT &&
(platform::MakeWalkChild(parent, "playden", 01777) == 0 || errno == EEXIST))
fd = platform::OpenWalkChild(parent, "playden", O_RDONLY | O_DIRECTORY | O_NOFOLLOW | O_CLOEXEC);
- const bool ok = fd >= 0 && ::fchmod(fd, 01777) == 0 && ::fsync(fd) == 0 && ::fsync(parent) == 0;
- const int error = errno;
+ bool ok = fd >= 0 || fail("open the folder");
+ // Sticky when the filesystem keeps it; the PS5's /data reports 0777 for 1777, which still works.
+ if (ok && ::fchmod(fd, 01777) != 0) {
+ notes.push_back("sticky chmod=" + Error(errno));
+ if (::fchmod(fd, 0777) != 0) ok = fail("chmod");
+ }
+ // A mode change that isn't on disk yet is redone at the next start: not worth refusing to start.
+ if (ok && ::fsync(fd) != 0) notes.push_back("fsync=" + Error(errno));
+ if (ok && ::fsync(parent) != 0) notes.push_back("parent fsync=" + Error(errno));
if (fd >= 0) ::close(fd);
::close(parent);
- errno = error;
return ok;
});
+ if (!prepared && failed == "root access") failed_error = as_root ? errno : ENOSYS;
+ if (log) for (const auto& line : notes) log("runtime root repair path=" + root.string() + " " + line);
if (prepared) return {};
- if (log) log("runtime root repair failed path=" + root.string() + " error=" + Error(errno));
- return "Playden can't write to " + root.string() +
- ". Make the folder writable over FTP (permissions 1777), then try again.";
+ const std::string detail = failed + " failed" + (failed_error ? " error=" + Error(failed_error) : "");
+ if (log) log("runtime root repair failed path=" + root.string() + " " + detail);
+ return "Playden can't write to " + root.string() + " (" + detail +
+ "). Make the folder writable over FTP (permissions 777), then try again.";
}
} // namespace playden::runtime
diff --git a/tests/runtime_writable_folders_test.cpp b/tests/runtime_writable_folders_test.cpp
index 32c3bd9..b00a6bf 100644
--- a/tests/runtime_writable_folders_test.cpp
+++ b/tests/runtime_writable_folders_test.cpp
@@ -122,9 +122,11 @@ int main() {
CHECK(chmod((root / "data/playden").c_str(), 0755) == 0);
CHECK(PrepareRuntimeRoot(root / "data/playden", runs, log, root).empty());
CHECK(Mode(root / "data/playden") == 01777 && Mode(locked) == 0777);
+ // A writable 0777 root is fine as it is: the PS5's /data drops the sticky bit.
CHECK(chmod((root / "data/playden").c_str(), 0777) == 0);
+ lines.clear();
CHECK(EnsureWritableFolders({root / "data/playden"}, runs, log, root).empty());
- CHECK(Mode(root / "data/playden") == 01777);
+ CHECK(Mode(root / "data/playden") == 0777 && lines.empty());
CHECK(chmod(target.c_str(), 0555) == 0);
const auto before_calls = calls;
CHECK(EnsureWritableFolders({target}, runs, log, root).empty());