1
0
mirror of https://github.com/RPCS3/rpcs3.git synced 2024-11-25 12:12:50 +01:00

sys_fs: Further implemented cellFsArcadeHddSerialNumber (0xc0000007)

This commit is contained in:
brian218 2023-05-02 23:57:39 +08:00 committed by Ivan
parent 5696065727
commit 6a41b22a1b
4 changed files with 31 additions and 8 deletions

View File

@ -15,7 +15,7 @@ std::u16string utf8_to_utf16(std::string_view src);
// Copy null-terminated string from a std::string or a char array to a char array with truncation
template <typename D, typename T>
inline void strcpy_trunc(D& dst, const T& src)
inline void strcpy_trunc(D&& dst, const T& src)
{
const usz count = std::size(src) >= std::size(dst) ? std::max<usz>(std::size(dst), 1) - 1 : std::size(src);
std::memcpy(std::data(dst), std::data(src), count);

View File

@ -2053,8 +2053,28 @@ error_code sys_fs_fcntl(ppu_thread& ppu, u32 fd, u32 op, vm::ptr<void> _arg, u32
case 0xc0000007: // cellFsArcadeHddSerialNumber
{
const auto arg = vm::static_ptr_cast<lv2_file_c0000007>(_arg);
// TODO populate arg-> unk1+2
std::string_view device{arg->device.get_ptr(), arg->device_size};
// Trim trailing '\0'
if (const auto trim_pos = device.find('\0'); trim_pos != umax)
device.remove_suffix(device.size() - trim_pos);
if (device != "CELL_FS_IOS:ATA_HDD"sv)
{
arg->out_code = CELL_ENOTSUP;
return {CELL_ENOTSUP, device};
}
const auto model = g_cfg.sys.hdd_model.to_string();
const auto serial = g_cfg.sys.hdd_serial.to_string();
strcpy_trunc(std::span(arg->model.get_ptr(), arg->model_size), model);
strcpy_trunc(std::span(arg->serial.get_ptr(), arg->serial_size), serial);
arg->out_code = CELL_OK;
sys_fs.trace("sys_fs_fcntl(0xc0000007): found device \"%s\" (model=\"%s\", serial=\"%s\")", device, model, serial);
return CELL_OK;
}

View File

@ -535,15 +535,16 @@ struct lv2_file_c0000006 : lv2_file_op
CHECK_SIZE(lv2_file_c0000006, 0x20);
// sys_fs_fcntl: cellFsArcadeHddSerialNumber
struct lv2_file_c0000007 : lv2_file_op
{
be_t<u32> out_code;
vm::bcptr<char> name;
be_t<u32> name_size; // 0x14
vm::bptr<char> unk1;
be_t<u32> unk1_size; //0x41
vm::bptr<char> unk2;
be_t<u32> unk2_size; //0x21
vm::bcptr<char> device;
be_t<u32> device_size; // 0x14
vm::bptr<char> model;
be_t<u32> model_size; // 0x29
vm::bptr<char> serial;
be_t<u32> serial_size; // 0x15
};
CHECK_SIZE(lv2_file_c0000007, 0x1c);

View File

@ -288,6 +288,8 @@ struct cfg_root : cfg::node
cfg::_int<-60*60*24*365*100LL, 60*60*24*365*100LL> console_time_offset{ this, "Console time offset (s)", 0 }; // console time offset, limited to +/-100years
cfg::uint<0, umax> console_psid_high{this, "PSID high"};
cfg::uint<0, umax> console_psid_low{this, "PSID low"};
cfg::string hdd_model{this, "HDD Model Name", ""};
cfg::string hdd_serial{this, "HDD Serial Number", ""};
} sys{ this };
struct node_net : cfg::node