From 116268b2752077d1f768845e3b0c0df2a99c89de Mon Sep 17 00:00:00 2001 From: Ryan Houdek Date: Thu, 13 Feb 2025 00:42:27 -0800 Subject: [PATCH] FileManagement: Throw a warning if `/proc` can't be opened We use this for ProcFD collision checking. Give a warning if it can't be opened, also not doing the additional work when it fails. This isn't likely to occur unless someone messes up their rootfs mounts. --- .../LinuxSyscalls/FileManagement.cpp | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) diff --git a/Source/Tools/LinuxEmulation/LinuxSyscalls/FileManagement.cpp b/Source/Tools/LinuxEmulation/LinuxSyscalls/FileManagement.cpp index 240cf46077..314f05181a 100644 --- a/Source/Tools/LinuxEmulation/LinuxSyscalls/FileManagement.cpp +++ b/Source/Tools/LinuxEmulation/LinuxSyscalls/FileManagement.cpp @@ -325,12 +325,15 @@ FileManager::FileManager(FEXCore::Context::Context* ctx) // Keep an fd open for /proc, to bypass chroot-style sandboxes ProcFD = open("/proc", O_RDONLY | O_CLOEXEC); - - // Track the st_dev of /proc, to check for inode equality - struct stat Buffer; - auto Result = fstat(ProcFD, &Buffer); - if (Result >= 0) { - ProcFSDev = Buffer.st_dev; + if (ProcFD != -1) { + // Track the st_dev of /proc, to check for inode equality + struct stat Buffer; + auto Result = fstat(ProcFD, &Buffer); + if (Result >= 0) { + ProcFSDev = Buffer.st_dev; + } + } else { + LogMan::Msg::EFmt("Couldn't open `/proc`. Is ProcFS mounted? FEX won't be able to track FD conflicts"); } UpdatePID(::getpid());