FM: Remove unused FD to Name mapping

This was completely unused so this just reduces some syscall signal
mutex locking around FD operations.
This commit is contained in:
Ryan Houdek committed 2023-03-10 16:30:49 -08:00
1 parent cd40a85567
commit 3ff7cf19c0
3 files changed
-47

No files matched your search

@@ -513,19 +513,10 @@ uint64_t FileManager::Open(const char *pathname, int flags, uint32_t mode) {
fd = ::open(SelfPath, flags, mode);
}
if (fd != -1) {
FHU::ScopedSignalMaskWithMutex lk(FDLock);
FDToNameMap.insert_or_assign(fd, SelfPath);
}
return fd;
}
uint64_t FileManager::Close(int fd) {
{
FHU::ScopedSignalMaskWithMutex lk(FDLock);
FDToNameMap.erase(fd);
}
return ::close(fd);
}
@@ -533,15 +524,6 @@ uint64_t FileManager::CloseRange(unsigned int first, unsigned int last, unsigned
#ifndef CLOSE_RANGE_CLOEXEC
#define CLOSE_RANGE_CLOEXEC (1U << 2)
#endif
if (!(flags & CLOSE_RANGE_CLOEXEC)) {
// If the flag was set then it doesn't actually close the FDs
// Just sets the flag on a range
FHU::ScopedSignalMaskWithMutex lk(FDLock);
auto Lower = FDToNameMap.lower_bound(first);
auto Upper = FDToNameMap.upper_bound(last);
// We remove from first to last inclusive
FDToNameMap.erase(Lower, Upper);
}
return ::syscall(SYSCALL_DEF(close_range), first, last, flags);
}
@@ -748,11 +730,6 @@ uint64_t FileManager::Openat([[maybe_unused]] int dirfs, const char *pathname, i
fd = ::syscall(SYSCALL_DEF(openat), dirfs, SelfPath, flags, mode);
}
if (fd != -1) {
FHU::ScopedSignalMaskWithMutex lk(FDLock);
FDToNameMap.insert_or_assign(fd, SelfPath);
}
return fd;
}
@@ -777,11 +754,6 @@ uint64_t FileManager::Openat2(int dirfs, const char *pathname, FEX::HLE::open_ho
fd = ::syscall(SYSCALL_DEF(openat2), dirfs, SelfPath, how, usize);
}
if (fd != -1) {
FHU::ScopedSignalMaskWithMutex lk(FDLock);
FDToNameMap.insert_or_assign(fd, SelfPath);
}
return fd;
}
@@ -854,13 +826,4 @@ uint64_t FileManager::NewFSStatAt64(int dirfd, const char *pathname, struct stat
return ::fstatat64(dirfd, SelfPath, buf, flag);
}
std::string *FileManager::FindFDName(int fd) {
FHU::ScopedSignalMaskWithMutex lk(FDLock);
auto it = FDToNameMap.find(fd);
if (it == FDToNameMap.end()) {
return nullptr;
}
return &it->second;
}
}
@@ -73,8 +73,6 @@ public:
// vfs
uint64_t Statfs(const char *path, void *buf);
std::string *FindFDName(int fd);
std::optional<std::string> GetSelf(const char *Pathname);
void UpdatePID(uint32_t PID) { CurrentPID = PID; }
@@ -83,13 +81,9 @@ public:
using FDPathTmpData = std::array<char[PATH_MAX], 2>;
std::pair<int, const char*> GetEmulatedFDPath(int dirfd, const char *pathname, bool FollowSymlink, FDPathTmpData &TmpFilename);
std::mutex *GetFDLock() { return &FDLock; }
private:
FEX::EmulatedFile::EmulatedFDManager EmuFD;
std::mutex FDLock;
std::map<uint32_t, std::string> FDToNameMap;
std::map<std::string, std::string, std::less<>> ThunkOverlays;
FEX_CONFIG_OPT(Filename, APP_FILENAME);
-4
View File
@@ -847,8 +847,6 @@ uint64_t UnimplementedSyscallSafe(FEXCore::Core::CpuStateFrame *Frame, uint64_t
}
void SyscallHandler::LockBeforeFork() {
FM.GetFDLock()->lock();
// XXX shared_mutex has issues with locking and forks
// VMATracking.Mutex.lock();
@@ -860,8 +858,6 @@ void SyscallHandler::UnlockAfterFork() {
// XXX shared_mutex has issues with locking and forks
// VMATracking.Mutex.unlock();
FM.GetFDLock()->unlock();
}
static bool isHEX(char c) {