diff --git a/External/FEXCore/Source/Interface/HLE/FileManagement.cpp b/External/FEXCore/Source/Interface/HLE/FileManagement.cpp index 7edc8b0ee..c6ed3fd6f 100644 --- a/External/FEXCore/Source/Interface/HLE/FileManagement.cpp +++ b/External/FEXCore/Source/Interface/HLE/FileManagement.cpp @@ -19,6 +19,15 @@ namespace FEXCore { FileManager::FileManager(FEXCore::Context::Context *ctx) : CTX {ctx} , EmuFD {ctx} { + + // calculate the non-self link to exe + // Some executables do getpid, stat("/proc/$pid/exe") + int pid = getpid(); + + char buf[50]; + snprintf(buf, 50, "/proc/%i/exe", pid); + + PidSelfPath = std::string(buf); } FileManager::~FileManager() { @@ -85,7 +94,7 @@ uint64_t FileManager::FAccessat(int dirfd, const char *pathname, int mode, int f } uint64_t FileManager::Readlink(const char *pathname, char *buf, size_t bufsiz) { - if (strcmp(pathname, "/proc/self/exe") == 0) { + if (strcmp(pathname, "/proc/self/exe") == 0 || strcmp(pathname, PidSelfPath.c_str()) == 0) { strncpy(buf, Filename.c_str(), bufsiz); return std::min(bufsiz, Filename.size()); } diff --git a/External/FEXCore/Source/Interface/HLE/FileManagement.h b/External/FEXCore/Source/Interface/HLE/FileManagement.h index f68040d80..0c50778fe 100644 --- a/External/FEXCore/Source/Interface/HLE/FileManagement.h +++ b/External/FEXCore/Source/Interface/HLE/FileManagement.h @@ -49,6 +49,7 @@ private: std::unordered_map FDToNameMap; std::string Filename; + std::string PidSelfPath; std::string GetEmulatedPath(const char *pathname); }; }