VFS: Add device_info to vfs config

This commit is contained in:
Megamouse 2022-05-08 00:13:21 +02:00
parent de988f6a76
commit b888a6ba37
7 changed files with 180 additions and 23 deletions

View file

@ -164,15 +164,40 @@ void Emulator::Init(bool add_only)
// Mount all devices
const std::string emu_dir = rpcs3::utils::get_emu_dir();
const std::string elf_dir = fs::get_parent_dir(m_path);
const std::string dev_hdd0 = g_cfg_vfs.get(g_cfg_vfs.dev_hdd0, emu_dir);
const std::string dev_hdd1 = g_cfg_vfs.get(g_cfg_vfs.dev_hdd1, emu_dir);
const std::string dev_flsh = g_cfg_vfs.get_dev_flash();
const std::string dev_flsh2 = g_cfg_vfs.get_dev_flash2();
const std::string dev_flsh3 = g_cfg_vfs.get_dev_flash3();
vfs::mount("/dev_hdd0", g_cfg_vfs.get(g_cfg_vfs.dev_hdd0, emu_dir));
vfs::mount("/dev_flash", g_cfg_vfs.get_dev_flash());
vfs::mount("/dev_flash2", g_cfg_vfs.get_dev_flash2());
vfs::mount("/dev_flash3", g_cfg_vfs.get_dev_flash3());
vfs::mount("/dev_usb", g_cfg_vfs.get(g_cfg_vfs.dev_usb000, emu_dir));
vfs::mount("/dev_usb000", g_cfg_vfs.get(g_cfg_vfs.dev_usb000, emu_dir));
vfs::mount("/dev_hdd0", dev_hdd0);
vfs::mount("/dev_flash", dev_flsh);
vfs::mount("/dev_flash2", dev_flsh2);
vfs::mount("/dev_flash3", dev_flsh3);
vfs::mount("/app_home", g_cfg_vfs.app_home.to_string().empty() ? elf_dir + '/' : g_cfg_vfs.get(g_cfg_vfs.app_home, emu_dir));
std::string dev_usb;
for (const auto& [key, value] : g_cfg_vfs.dev_usb.get_map())
{
const cfg::device_info usb_info = g_cfg_vfs.get_device(g_cfg_vfs.dev_usb, key, emu_dir);
if (key.size() != 11 || !key.starts_with("/dev_usb00"sv) || key.back() < '0' || key.back() > '7')
{
sys_log.error("Trying to mount unsupported usb device: %s", key);
continue;
}
vfs::mount(key, usb_info.path);
if (key == "/dev_usb000"sv)
{
dev_usb = usb_info.path;
}
}
ensure(!dev_usb.empty());
if (!hdd1.empty())
{
vfs::mount("/dev_hdd1", hdd1);
@ -229,13 +254,6 @@ void Emulator::Init(bool add_only)
}
// Create directories (can be disabled if necessary)
const std::string dev_hdd0 = rpcs3::utils::get_hdd0_dir();
const std::string dev_hdd1 = g_cfg_vfs.get(g_cfg_vfs.dev_hdd1, emu_dir);
const std::string dev_usb = g_cfg_vfs.get(g_cfg_vfs.dev_usb000, emu_dir);
const std::string dev_flsh = g_cfg_vfs.get_dev_flash();
const std::string dev_flsh2 = g_cfg_vfs.get_dev_flash2();
const std::string dev_flsh3 = g_cfg_vfs.get_dev_flash3();
auto make_path_verbose = [](const std::string& path)
{
if (!fs::create_path(path))