sys_fs_fcntl with parameter 0xC0000002 should extract device path from the given path and use that to gather free space information

This commit is contained in:
RipleyTom 2018-11-03 21:56:57 +01:00 committed by Ivan
parent d6afba96f1
commit 077e710e3a

View file

@ -1,4 +1,4 @@
#include "stdafx.h"
#include "stdafx.h"
#include "sys_fs.h"
#include <mutex>
@ -982,13 +982,25 @@ error_code sys_fs_fcntl(u32 fd, u32 op, vm::ptr<void> _arg, u32 _size)
const auto arg = vm::static_ptr_cast<lv2_file_c0000002>(_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};