Filesystem errors and Base Array Layers (#280)

* Filesystem errors and Base Array Layers

* Fixed build for POSIX

* forgot 1 file
This commit is contained in:
Vladislav Mikhalin 2024-07-11 14:37:21 +03:00 committed by GitHub
parent 59be090c83
commit 989f88837d
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
7 changed files with 34 additions and 26 deletions

View file

@ -73,28 +73,25 @@ int PS4_SYSV_ABI sceKernelOpen(const char* path, int flags, u16 mode) {
} else {
file->m_guest_name = path;
file->m_host_name = mnt->GetHostFile(file->m_guest_name);
int e = 0;
if (read) {
file->f.Open(file->m_host_name, Common::FS::FileAccessMode::Read);
} else if (write && create) {
file->f.Open(file->m_host_name, Common::FS::FileAccessMode::Write);
e = file->f.Open(file->m_host_name, Common::FS::FileAccessMode::Read);
} else if (write && (create || truncate)) {
e = file->f.Open(file->m_host_name, Common::FS::FileAccessMode::Write);
} else if (write && create && append) { // CUSA04729 (appends app0/shaderlist.txt)
file->f.Open(file->m_host_name, Common::FS::FileAccessMode::Append);
e = file->f.Open(file->m_host_name, Common::FS::FileAccessMode::Append);
} else if (rdwr) {
if (create) { // Create an empty file first.
Common::FS::IOFile out(file->m_host_name, Common::FS::FileAccessMode::Write);
}
// RW, then scekernelWrite is called and savedata is written just fine now.
file->f.Open(file->m_host_name, Common::FS::FileAccessMode::ReadWrite);
e = file->f.Open(file->m_host_name, Common::FS::FileAccessMode::ReadWrite);
} else {
UNREACHABLE();
}
if (!file->f.IsOpen()) {
if (e != 0) {
h->DeleteHandle(handle);
if (create) {
return ORBIS_KERNEL_ERROR_EACCES;
} else {
return ORBIS_KERNEL_ERROR_ENOENT;
}
return ErrnoToSceKernelError(e);
}
}
file->is_opened = true;

View file

@ -106,12 +106,17 @@ int* PS4_SYSV_ABI __Error() {
}
void ErrSceToPosix(int result) {
int rt = result > SCE_KERNEL_ERROR_UNKNOWN && result <= SCE_KERNEL_ERROR_ESTOP
? result + -SCE_KERNEL_ERROR_UNKNOWN
: POSIX_EOTHER;
const int rt = result > SCE_KERNEL_ERROR_UNKNOWN && result <= SCE_KERNEL_ERROR_ESTOP
? result + -SCE_KERNEL_ERROR_UNKNOWN
: POSIX_EOTHER;
g_posix_errno = rt;
}
int ErrnoToSceKernelError(int e) {
const auto res = SCE_KERNEL_ERROR_UNKNOWN + e;
return res > SCE_KERNEL_ERROR_ESTOP ? SCE_KERNEL_ERROR_UNKNOWN : res;
}
int PS4_SYSV_ABI sceKernelMmap(void* addr, u64 len, int prot, int flags, int fd, size_t offset,
void** res) {
LOG_INFO(Kernel_Vmm, "called addr = {}, len = {}, prot = {}, flags = {}, fd = {}, offset = {}",

View file

@ -13,6 +13,7 @@ class SymbolsResolver;
namespace Libraries::Kernel {
void ErrSceToPosix(int result);
int ErrnoToSceKernelError(int e);
struct OrbisTimesec {
time_t t;