diff --git a/src/common/path_util.cpp b/src/common/path_util.cpp index 702d0fabc..0f71dcb2f 100644 --- a/src/common/path_util.cpp +++ b/src/common/path_util.cpp @@ -136,6 +136,7 @@ static auto UserPaths = [] { create_path(PathType::PatchesDir, user_dir / PATCHES_DIR); create_path(PathType::MetaDataDir, user_dir / METADATA_DIR); create_path(PathType::CustomTrophy, user_dir / CUSTOM_TROPHY); + create_path(PathType::DevicesDir, user_dir / DEVICES_DIR); std::ofstream notice_file(user_dir / CUSTOM_TROPHY / "Notice.txt"); if (notice_file.is_open()) { diff --git a/src/common/path_util.h b/src/common/path_util.h index 2fd9b1588..848bf27f7 100644 --- a/src/common/path_util.h +++ b/src/common/path_util.h @@ -28,6 +28,7 @@ enum class PathType { PatchesDir, // Where patches are stored. MetaDataDir, // Where game metadata (e.g. trophies and menu backgrounds) is stored. CustomTrophy, // Where custom files for trophies are stored. + DevicesDir, // Where temporary device files are located. }; constexpr auto PORTABLE_DIR = "user"; @@ -46,6 +47,7 @@ constexpr auto CHEATS_DIR = "cheats"; constexpr auto PATCHES_DIR = "patches"; constexpr auto METADATA_DIR = "game_data"; constexpr auto CUSTOM_TROPHY = "custom_trophy"; +constexpr auto DEVICES_DIR = "device"; // Filenames constexpr auto LOG_FILE = "shad_log.txt"; diff --git a/src/core/libraries/kernel/file_system.cpp b/src/core/libraries/kernel/file_system.cpp index 8ef63641f..845aa294a 100644 --- a/src/core/libraries/kernel/file_system.cpp +++ b/src/core/libraries/kernel/file_system.cpp @@ -91,6 +91,15 @@ s32 PS4_SYSV_ABI open(const char* raw_path, s32 flags, u16 mode) { file->type = Core::FileSys::FileType::Device; file->m_guest_name = path; file->device = factory(handle, path.data(), flags, mode); + + // Some libraries map memory to their file. We need a host file to support this. + file->m_host_name = mnt->GetHostPath(file->m_guest_name); + bool exists = std::filesystem::exists(file->m_host_name); + if (!exists) { + Common::FS::IOFile out(file->m_host_name, Common::FS::FileAccessMode::Write); + } + auto e = file->f.Open(file->m_host_name, Common::FS::FileAccessMode::ReadWrite); + ASSERT(e == 0); return handle; } } diff --git a/src/emulator.cpp b/src/emulator.cpp index 45e93dc22..efc3480dc 100644 --- a/src/emulator.cpp +++ b/src/emulator.cpp @@ -245,6 +245,12 @@ void Emulator::Run(const std::filesystem::path& file, const std::vectorMount(devices_dir, "/dev"); + // Initialize kernel and library facilities. Libraries::InitHLELibs(&linker->GetHLESymbols());