Check for read only directories

This commit is contained in:
Stephen Miller 2025-04-28 12:30:07 -05:00
parent 7ab496b435
commit 5f3da89091

View File

@ -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_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); bool exists = std::filesystem::exists(file->m_host_name);
s32 e = 0; s32 e = 0;
@ -106,6 +107,13 @@ s32 PS4_SYSV_ABI open(const char* raw_path, s32 flags, u16 mode) {
*__Error() = POSIX_EEXIST; *__Error() = POSIX_EEXIST;
return -1; 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 // Create file if it doesn't exist
Common::FS::IOFile out(file->m_host_name, Common::FS::FileAccessMode::Write); Common::FS::IOFile out(file->m_host_name, Common::FS::FileAccessMode::Write);
} else if (!exists) { } else if (!exists) {