Revert "Remove SetPosixErrno"

This reverts commit bdfc0c246c.
This commit is contained in:
Stephen Miller 2025-02-27 15:00:36 -06:00
parent 8313cc6752
commit 12dc1adf66
3 changed files with 19 additions and 6 deletions

View File

@ -166,9 +166,9 @@ s32 PS4_SYSV_ABI open(const char* raw_path, s32 flags, u16 mode) {
}
if (e != 0) {
// IOFile code uses platform specific errnos. Use POSIX_EIO for now
// IOFile code uses platform specific errnos, they must be converted to POSIX errnos.
h->DeleteHandle(handle);
*__Error() = POSIX_EIO;
SetPosixErrno(e);
return -1;
}
}
@ -375,8 +375,8 @@ s64 PS4_SYSV_ABI posix_lseek(s32 fd, s64 offset, s32 whence) {
if (!file->f.Seek(offset, origin)) {
if (errno != 0) {
// Seek failed in platform-specific code. Use POSIX_EIO for now.
*__Error() = POSIX_EIO;
// Seek failed in platform-specific code, errno needs to be converted.
SetPosixErrno(errno);
} else {
// Seek failed because offset is beyond the end of the file.
*__Error() = POSIX_ENXIO;
@ -386,8 +386,8 @@ s64 PS4_SYSV_ABI posix_lseek(s32 fd, s64 offset, s32 whence) {
s64 result = file->f.Tell();
if (result < 0) {
// Tell failed in platform-specific code. Use POSIX_EIO for now.
*__Error() = POSIX_EIO;
// Tell failed in platform-specific code, errno needs to be converted.
SetPosixErrno(errno);
return -1;
}
return result;

View File

@ -84,6 +84,18 @@ int ErrnoToSceKernelError(int error) {
return error + ORBIS_KERNEL_ERROR_UNKNOWN;
}
void SetPosixErrno(int e) {
// Some error numbers are different between supported OSes
switch (e) {
case ENOENT:
g_posix_errno = POSIX_ENOENT;
break;
default:
UNREACHABLE_MSG("errno = {}", e);
g_posix_errno = e;
}
}
static uint64_t g_mspace_atomic_id_mask = 0;
static uint64_t g_mstate_table[64] = {0};

View File

@ -16,6 +16,7 @@ namespace Libraries::Kernel {
void ErrSceToPosix(int result);
int ErrnoToSceKernelError(int e);
void SetPosixErrno(int e);
template <size_t N>
struct StringLiteral {