diff --git a/rpcs3/Emu/Cell/lv2/sys_fs.cpp b/rpcs3/Emu/Cell/lv2/sys_fs.cpp index cdc83ac82f..0121236ff6 100644 --- a/rpcs3/Emu/Cell/lv2/sys_fs.cpp +++ b/rpcs3/Emu/Cell/lv2/sys_fs.cpp @@ -304,7 +304,7 @@ lv2_file::lv2_file(utils::serial& ar) void lv2_file::save(utils::serial& ar) { USING_SERIALIZATION_VERSION(lv2_fs); - ar(name, mode, flags, type, lock, vfs::retrieve(real_path)); + ar(name, mode, flags, type, lock, ensure(vfs::retrieve(real_path), FN(!x.empty()))); if (!(mp->flags & lv2_mp_flag::read_only) && flags & CELL_FS_O_ACCMODE) { diff --git a/rpcs3/Emu/VFS.cpp b/rpcs3/Emu/VFS.cpp index fff1b72a88..12c0211144 100644 --- a/rpcs3/Emu/VFS.cpp +++ b/rpcs3/Emu/VFS.cpp @@ -388,13 +388,23 @@ std::string vfs::retrieve(std::string_view path, const vfs_directory* node, std: // Try to extract host root mount point name (if exists) std::string_view host_root_name; + std::string result; + std::string result_dir; + for (const auto& [name, dir] : node->dirs) { mount_path->back() = name; if (std::string res = vfs::retrieve(path, &dir, mount_path); !res.empty()) { - return res; + // Avoid app_home + // Prefer dev_bdvd over dev_hdd0 + if (result.empty() || (name == "app_home") < (result_dir == "app_home") || + (name == "dev_bdvd") > (result_dir == "dev_bdvd")) + { + result = std::move(res); + result_dir = name; + } } if (dir.path == "/"sv) @@ -403,6 +413,11 @@ std::string vfs::retrieve(std::string_view path, const vfs_directory* node, std: } } + if (!result.empty()) + { + return result; + } + mount_path->pop_back(); if (node->path.size() > 1 && path.starts_with(node->path)) @@ -434,7 +449,7 @@ std::string vfs::retrieve(std::string_view path, const vfs_directory* node, std: { // If failed to find mount point for path and /host_root is mounted // Prepend "/host_root" to path and return the constructed string - std::string result{"/"}; + result = "/"; for (const auto& name : *mount_path) { @@ -449,7 +464,7 @@ std::string vfs::retrieve(std::string_view path, const vfs_directory* node, std: return result; } - return {}; + return result; } std::string vfs::escape(std::string_view name, bool escape_slash)