mirror of
https://github.com/FEX-Emu/FEX.git
synced 2026-10-27 18:00:48 +01:00
Merge pull request #278 from phire/pid_self
Filesystem HLE: Intercept /proc/${getpid}/exe too
This commit is contained in:
2 files changed
+11
-1
No files matched your search
+10
-1
@@ -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());
|
||||
}
|
||||
|
||||
@@ -49,6 +49,7 @@ private:
|
||||
|
||||
std::unordered_map<int32_t, std::string> FDToNameMap;
|
||||
std::string Filename;
|
||||
std::string PidSelfPath;
|
||||
std::string GetEmulatedPath(const char *pathname);
|
||||
};
|
||||
}
|
||||
Reference in new issue
Block a user