Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

VSH: sys_fs: Minor fixup #12913

Merged
merged 1 commit into from Nov 1, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
2 changes: 1 addition & 1 deletion rpcs3/Emu/Cell/lv2/lv2.cpp
Expand Up @@ -788,7 +788,7 @@ const std::array<std::pair<ppu_intrp_func_t, std::string_view>, 1024> g_ppu_sysc
BIND_SYSC(sys_fs_symbolic_link), //833 (0x341)
BIND_SYSC(sys_fs_chmod), //834 (0x342)
BIND_SYSC(sys_fs_chown), //835 (0x343)
NULL_FUNC(sys_fs_newfs), //836 (0x344)
BIND_SYSC(sys_fs_newfs), //836 (0x344)
BIND_SYSC(sys_fs_mount), //837 (0x345)
BIND_SYSC(sys_fs_unmount), //838 (0x346)
NULL_FUNC(sys_fs_sync), //839 (0x347)
Expand Down
23 changes: 18 additions & 5 deletions rpcs3/Emu/Cell/lv2/sys_fs.cpp
Expand Up @@ -228,7 +228,7 @@ std::string lv2_fs_object::get_vfs(std::string_view filename)
if (mp_name == "app_home"sv && filename.data() != Emu.argv[0].data())
return lv2_fs_object::get_vfs(Emu.argv[0]);
if (mp_name == "host_root"sv)
return {}; // Unsupported in VFS
return g_cfg.vfs.host_root ? "/" : std::string();
if (mp_name == "dev_flash"sv)
return g_cfg_vfs.get_dev_flash();
if (mp_name == "dev_flash2"sv)
Expand Down Expand Up @@ -2992,6 +2992,18 @@ error_code sys_fs_get_mount_info(ppu_thread&, vm::ptr<CellFsMountInfo> info, u32
return CELL_OK;
}

error_code sys_fs_newfs(ppu_thread& ppu, vm::cptr<char> dev_name, vm::cptr<char> file_system, s32 unk1, vm::cptr<char> str1)
{
sys_fs.todo("sys_fs_newfs(dev_name=%s, file_system=%s, unk1=0x%x, str1=%s)", dev_name, file_system, unk1, str1);

if (!g_ps3_process_info.has_root_perm())
{
return CELL_ENOSYS;
}

return CELL_OK;
}

error_code sys_fs_mount(ppu_thread&, vm::cptr<char> dev_name, vm::cptr<char> file_system, vm::cptr<char> path, s32 unk1, s32 prot, s32 unk3, vm::cptr<char> str1, u32 str_len)
{
sys_fs.warning("sys_fs_mount(dev_name=%s, file_system=%s, path=%s, unk1=0x%x, prot=0x%x, unk3=0x%x, str1=%s, str_len=%d)", dev_name, file_system, path, unk1, prot, unk3, str1, str_len);
Expand Down Expand Up @@ -3020,30 +3032,31 @@ error_code sys_fs_mount(ppu_thread&, vm::cptr<char> dev_name, vm::cptr<char> fil

auto vfs_mount = [&vpath = vpath, &filesystem = filesystem, &mp = mp](std::string mount_path)
{
const u64 file_size = filesystem == "CELL_FS_SIMPLEFS" ? mp->sector_size * mp->sector_count : 0;
if (!mount_path.ends_with('/'))
mount_path += '/';
if (!fs::is_dir(mount_path) && !fs::create_dir(mount_path))
{
sys_fs.error("Failed to create directory \"%s\"", mount_path);
return false;
}
if (file_size > 0)
const bool is_simplefs = filesystem == "CELL_FS_SIMPLEFS";
if (is_simplefs)
{
mount_path += "loop.tmp";
fs::file loop_file;
if (loop_file.open(mount_path, fs::create + fs::read + fs::write + fs::trunc + fs::lock))
{
const u64 file_size = mp->sector_size * mp->sector_count;
loop_file.trunc(file_size);
sys_fs.notice("Created a loop file of size %d at \"%s\"", file_size, mount_path);
sys_fs.notice("Created a loop file of size 0x%x at \"%s\"", file_size, mount_path);
}
else
{
sys_fs.error("Failed to create loop file \"%s\"", mount_path);
return false;
}
}
return vfs::mount(vpath, mount_path, file_size == 0);
return vfs::mount(vpath, mount_path, !is_simplefs);
};

if (mp == &g_mp_sys_dev_hdd1)
Expand Down
1 change: 1 addition & 0 deletions rpcs3/Emu/Cell/lv2/sys_fs.h
Expand Up @@ -617,6 +617,7 @@ error_code sys_fs_lsn_write(ppu_thread& ppu, u32 fd, vm::cptr<void>, u64);
error_code sys_fs_mapped_allocate(ppu_thread& ppu, u32 fd, u64, vm::pptr<void> out_ptr);
error_code sys_fs_mapped_free(ppu_thread& ppu, u32 fd, vm::ptr<void> ptr);
error_code sys_fs_truncate2(ppu_thread& ppu, u32 fd, u64 size);
error_code sys_fs_newfs(ppu_thread& ppu, vm::cptr<char> dev_name, vm::cptr<char> file_system, s32 unk1, vm::cptr<char> str1);
error_code sys_fs_mount(ppu_thread& ppu, vm::cptr<char> dev_name, vm::cptr<char> file_system, vm::cptr<char> path, s32 unk1, s32 prot, s32 unk3, vm::cptr<char> str1, u32 str_len);
error_code sys_fs_unmount(ppu_thread&, vm::cptr<char> path, s32 unk1, s32 unk2);
error_code sys_fs_get_mount_info_size(ppu_thread& ppu, vm::ptr<u64> len);
Expand Down