From 077e710e3a29758bb832ad50b253ef474068651f Mon Sep 17 00:00:00 2001 From: RipleyTom Date: Sat, 3 Nov 2018 21:56:57 +0100 Subject: [PATCH] sys_fs_fcntl with parameter 0xC0000002 should extract device path from the given path and use that to gather free space information --- rpcs3/Emu/Cell/lv2/sys_fs.cpp | 18 +++++++++++++++--- 1 file changed, 15 insertions(+), 3 deletions(-) diff --git a/rpcs3/Emu/Cell/lv2/sys_fs.cpp b/rpcs3/Emu/Cell/lv2/sys_fs.cpp index 27cb7c92a8..4689c369b7 100644 --- a/rpcs3/Emu/Cell/lv2/sys_fs.cpp +++ b/rpcs3/Emu/Cell/lv2/sys_fs.cpp @@ -1,4 +1,4 @@ -#include "stdafx.h" +#include "stdafx.h" #include "sys_fs.h" #include @@ -982,13 +982,25 @@ error_code sys_fs_fcntl(u32 fd, u32 op, vm::ptr _arg, u32 _size) const auto arg = vm::static_ptr_cast(_arg); const std::string_view vpath = arg->path.get_ptr(); - const std::string local_path = vfs::get(vpath); - if (vpath.find_first_not_of('/') == -1) + if (vpath[0] != '/') { return {CELL_EPERM, vpath}; } + // Extract device from path + std::size_t lastslash = vpath.find_first_not_of('/', 1); + if (lastslash != std::string_view::npos) + { + lastslash = vpath.find_first_of('/', lastslash + 1); + } + + if (lastslash == std::string_view::npos) lastslash = vpath.length(); + else lastslash++; + + const std::string_view device_path = vpath.substr(0, lastslash); + const std::string local_path = vfs::get(device_path); + if (local_path.empty()) { return {CELL_ENOTMOUNTED, vpath};