Files
AnyPS5/core/libs/prx/libc/src/HostErrno.cpp
T
Alexej Szpevák dc324d3d5f fix(libc): translate the host errno of a failed fopen
fopen left the host's errno in place when the host open failed, so on Linux a symlink loop reached the title as 40 and an over-long name as 36, which are EMSGSIZE and EINPROGRESS on FreeBSD. GuestErrnoFromHost_nid_no_patch maps the host value to FreeBSD 11.4's: 1 to 34 are shared except EAGAIN (35), and ELOOP, ENAMETOOLONG, ENOTEMPTY, EDQUOT, EOVERFLOW and EDEADLK get their FreeBSD numbers; anything else is EIO.
2026-10-17 11:51:00 +02:00

36 lines
887 B
C++

#include "prx/libc/include/HostErrno.hpp"
#include <cerrno>
namespace {
constexpr int GuestEio = 5;
constexpr int GuestEdeadlk = 11;
constexpr int GuestEagain = 35;
constexpr int GuestEloop = 62;
constexpr int GuestEnametoolong = 63;
constexpr int GuestEnotempty = 66;
constexpr int GuestEdquot = 69;
constexpr int GuestEoverflow = 84;
}
extern "C" int GuestErrnoFromHost_nid_no_patch(int error) {
if (error == EAGAIN) return GuestEagain;
#ifdef EDEADLK
if (error == EDEADLK) return GuestEdeadlk;
#endif
if (error == ENAMETOOLONG) return GuestEnametoolong;
if (error == ENOTEMPTY) return GuestEnotempty;
#ifdef ELOOP
if (error == ELOOP) return GuestEloop;
#endif
#ifdef EDQUOT
if (error == EDQUOT) return GuestEdquot;
#endif
#ifdef EOVERFLOW
if (error == EOVERFLOW) return GuestEoverflow;
#endif
return error > 0 && error <= 34 ? error : GuestEio;
}