Remove SetPosixErrno

Ideally, we've handled all possible error conditions before calling these functions, so treat errors in platform-specific code as IO errors and return POSIX_EIO instead.
This commit is contained in:
Stephen Miller 2025-02-19 19:24:22 -06:00
parent cc07a4da15
commit bdfc0c246c
3 changed files with 6 additions and 19 deletions

View file

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

View file

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