mirror of
https://github.com/RPCS3/rpcs3.git
synced 2025-04-21 03:55:32 +00:00
sys_fs: Updated sys_fs_fcntl(0xc0000015&0xc000001c)'s error handling according to real hardware testing
This commit is contained in:
parent
0b829be798
commit
9a5bdc9b4f
2 changed files with 27 additions and 29 deletions
|
@ -2181,39 +2181,37 @@ error_code sys_fs_fcntl(ppu_thread& ppu, u32 fd, u32 op, vm::ptr<void> _arg, u32
|
|||
break;
|
||||
}
|
||||
|
||||
std::string_view vpath{arg->name.get_ptr(), arg->name_size};
|
||||
std::string_view vpath{arg->path.get_ptr(), arg->path_size};
|
||||
|
||||
if (vpath.size() == 0)
|
||||
return CELL_ENOMEM;
|
||||
|
||||
// Trim trailing '\0'
|
||||
if (const auto trim_pos = vpath.find('\0'); trim_pos != umax)
|
||||
vpath.remove_suffix(vpath.size() - trim_pos);
|
||||
|
||||
if (vfs::get(vpath).empty())
|
||||
arg->out_code = CELL_ENOTMOUNTED; // arg->out_code is set to CELL_ENOTMOUNTED on real hardware when the device doesn't exist or when the device isn't USB
|
||||
|
||||
if (!vfs::get(vpath).empty())
|
||||
{
|
||||
arg->out_code = CELL_ENOTMOUNTED;
|
||||
return {CELL_ENOTMOUNTED, vpath};
|
||||
if (const auto& mp = g_fxo->get<lv2_fs_mount_info_map>().lookup(vpath, true); mp == &g_mp_sys_dev_usb)
|
||||
{
|
||||
const cfg::device_info device = g_cfg_vfs.get_device(g_cfg_vfs.dev_usb, fmt::format("%s%s", mp->root, mp.device.substr(mp->device.size())));
|
||||
const auto usb_ids = device.get_usb_ids();
|
||||
std::tie(arg->vendorID, arg->productID) = usb_ids;
|
||||
|
||||
if (with_serial)
|
||||
{
|
||||
const auto arg_c000001c = vm::static_ptr_cast<lv2_file_c000001c>(_arg);
|
||||
const std::u16string serial = utf8_to_utf16(device.serial); // Serial needs to be encoded to utf-16 BE
|
||||
std::copy_n(serial.begin(), std::min(serial.size(), sizeof(arg_c000001c->serial) / sizeof(u16)), arg_c000001c->serial);
|
||||
}
|
||||
|
||||
arg->out_code = CELL_OK;
|
||||
sys_fs.trace("sys_fs_fcntl(0x%08x): found device \"%s\" (vid=0x%04x, pid=0x%04x, serial=\"%s\")", op, mp.device, usb_ids.first, usb_ids.second, device.serial);
|
||||
}
|
||||
}
|
||||
|
||||
const auto& mp = g_fxo->get<lv2_fs_mount_info_map>().lookup(vpath, true);
|
||||
|
||||
if (mp != &g_mp_sys_dev_usb)
|
||||
{
|
||||
arg->out_code = CELL_ENOTSUP;
|
||||
return {CELL_ENOTSUP, vpath};
|
||||
}
|
||||
|
||||
const cfg::device_info device = g_cfg_vfs.get_device(g_cfg_vfs.dev_usb, fmt::format("%s%s", mp->root, mp.device.substr(mp->device.size())));
|
||||
std::tie(arg->vendorID, arg->productID) = device.get_usb_ids();
|
||||
|
||||
if (with_serial)
|
||||
{
|
||||
const auto arg_c000001c = vm::static_ptr_cast<lv2_file_c000001c>(_arg);
|
||||
const std::u16string serial = utf8_to_utf16(device.serial); // Serial needs to be encoded to utf-16 BE
|
||||
std::copy_n(serial.begin(), std::min(serial.size(), sizeof(arg_c000001c->serial) / sizeof(u16)), arg_c000001c->serial);
|
||||
}
|
||||
|
||||
arg->out_code = CELL_OK;
|
||||
|
||||
sys_fs.trace("sys_fs_fcntl(0x%08x): found device \"%s\" (vid=0x%04x, pid=0x%04x, serial=\"%s\")", op, mp.device, arg->vendorID, arg->productID, device.serial);
|
||||
return CELL_OK;
|
||||
}
|
||||
|
||||
|
|
|
@ -562,8 +562,8 @@ struct lv2_file_c0000015 : lv2_file_op
|
|||
be_t<u32> size; // 0x20
|
||||
be_t<u32> _x4; // 0x10
|
||||
be_t<u32> _x8; // 0x18 - offset of out_code
|
||||
be_t<u32> name_size;
|
||||
vm::bcptr<char> name;
|
||||
be_t<u32> path_size;
|
||||
vm::bcptr<char> path;
|
||||
be_t<u32> _x14; //
|
||||
be_t<u16> vendorID;
|
||||
be_t<u16> productID;
|
||||
|
@ -590,8 +590,8 @@ struct lv2_file_c000001c : lv2_file_op
|
|||
be_t<u32> size; // 0x60
|
||||
be_t<u32> _x4; // 0x10
|
||||
be_t<u32> _x8; // 0x18 - offset of out_code
|
||||
be_t<u32> name_size;
|
||||
vm::bcptr<char> name;
|
||||
be_t<u32> path_size;
|
||||
vm::bcptr<char> path;
|
||||
be_t<u32> unk1;
|
||||
be_t<u16> vendorID;
|
||||
be_t<u16> productID;
|
||||
|
|
Loading…
Add table
Reference in a new issue