From 5f3da890914bfeb4639990fe925ef30ed1817f76 Mon Sep 17 00:00:00 2001 From: Stephen Miller Date: Mon, 28 Apr 2025 12:30:07 -0500 Subject: [PATCH] Check for read only directories --- src/core/libraries/kernel/file_system.cpp | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/src/core/libraries/kernel/file_system.cpp b/src/core/libraries/kernel/file_system.cpp index bf9413fbf..720d74778 100644 --- a/src/core/libraries/kernel/file_system.cpp +++ b/src/core/libraries/kernel/file_system.cpp @@ -94,8 +94,9 @@ s32 PS4_SYSV_ABI open(const char* raw_path, s32 flags, u16 mode) { } } + bool read_only = false; file->m_guest_name = path; - file->m_host_name = mnt->GetHostPath(file->m_guest_name); + file->m_host_name = mnt->GetHostPath(file->m_guest_name, &read_only); bool exists = std::filesystem::exists(file->m_host_name); s32 e = 0; @@ -106,6 +107,13 @@ s32 PS4_SYSV_ABI open(const char* raw_path, s32 flags, u16 mode) { *__Error() = POSIX_EEXIST; return -1; } + + if (read_only) { + // Can't create files in a read only directory + h->DeleteHandle(handle); + *__Error() = POSIX_EROFS; + return -1; + } // Create file if it doesn't exist Common::FS::IOFile out(file->m_host_name, Common::FS::FileAccessMode::Write); } else if (!exists) {