From 59565b828d7adad41b978e20d80bdc554f2d631e Mon Sep 17 00:00:00 2001 From: Ryan Houdek Date: Sat, 11 Nov 2023 13:36:48 -0800 Subject: [PATCH] FEXServerClient: Expose the temp folder directly Using the server mount folder works most of the time, but when running under pressure-vessel this stacks directories in a weird way because the mount folder has some tricks applied to it. Expose the temp folder being used directly instead. --- Source/Common/FEXServerClient.cpp | 25 ++++++++++++++----------- Source/Common/FEXServerClient.h | 1 + 2 files changed, 15 insertions(+), 11 deletions(-) diff --git a/Source/Common/FEXServerClient.cpp b/Source/Common/FEXServerClient.cpp index 2cfaabd86..1f008bad8 100644 --- a/Source/Common/FEXServerClient.cpp +++ b/Source/Common/FEXServerClient.cpp @@ -104,6 +104,19 @@ namespace FEXServerClient { return GetServerLockFolder() + "RootFS.lock"; } + fextl::string GetTempFolder() { + fextl::string Folder{}; + auto XDGRuntimeEnv = getenv("XDG_RUNTIME_DIR"); + if (XDGRuntimeEnv) { + // If the XDG runtime directory works then use that. + return XDGRuntimeEnv; + } + // Fallback to `/tmp/` if XDG_RUNTIME_DIR doesn't exist. + // Might not be ideal but we don't have much of a choice. + Folder = std::filesystem::temp_directory_path().string(); + return Folder; + } + fextl::string GetServerMountFolder() { // We need a FEXServer mount directory that has some tricky requirements. // - We don't want to use `/tmp/` if possible. @@ -119,17 +132,7 @@ namespace FEXServerClient { // - If this path doesn't exist then fallback to `/tmp/` as a last resort. // - pressure-vessel explicitly creates an internal XDG_RUNTIME_DIR inside its chroot. // - This is okay since pressure-vessel rbinds the FEX rootfs from the host to `/run/pressure-vessel/interpreter-root`. - fextl::string Folder{}; - auto XDGRuntimeEnv = getenv("XDG_RUNTIME_DIR"); - if (XDGRuntimeEnv) { - // If the XDG runtime directory works then use that. - Folder = XDGRuntimeEnv; - } - else { - // Fallback to `/tmp/` if XDG_RUNTIME_DIR doesn't exist. - // Might not be ideal but we don't have much of a choice. - Folder = std::filesystem::temp_directory_path().string(); - } + auto Folder = GetTempFolder(); if (FEXCore::Config::FindContainer() == "pressure-vessel") { // In pressure-vessel the mount point changes location. diff --git a/Source/Common/FEXServerClient.h b/Source/Common/FEXServerClient.h index 9eda41a48..626fec5d5 100644 --- a/Source/Common/FEXServerClient.h +++ b/Source/Common/FEXServerClient.h @@ -50,6 +50,7 @@ namespace FEXServerClient { fextl::string GetServerLockFolder(); fextl::string GetServerLockFile(); fextl::string GetServerRootFSLockFile(); + fextl::string GetTempFolder(); fextl::string GetServerMountFolder(); fextl::string GetServerSocketName(); int GetServerFD();