mirror of
https://github.com/RPCS3/rpcs3.git
synced 2025-01-06 00:59:18 +00:00
sys_fs_test implemented
This commit is contained in:
parent
f42b830ce9
commit
1bbb76fa20
@ -153,10 +153,36 @@ fs::file lv2_file::make_view(const std::shared_ptr<lv2_file>& _file, u64 offset)
|
||||
return result;
|
||||
}
|
||||
|
||||
error_code sys_fs_test(u32 arg1, u32 arg2, vm::ptr<u32> arg3, u32 arg4, vm::ptr<char> arg5, u32 arg6)
|
||||
error_code sys_fs_test(u32 arg1, u32 arg2, vm::ptr<u32> arg3, u32 arg4, vm::ptr<char> buf, u32 buf_size)
|
||||
{
|
||||
sys_fs.todo("sys_fs_test(arg1=0x%x, arg2=0x%x, arg3=*0x%x, arg4=0x%x, arg5=*0x%x, arg6=0x%x) -> CELL_OK", arg1, arg2, arg3, arg4, arg5, arg6);
|
||||
sys_fs.trace("sys_fs_test(arg1=0x%x, arg2=0x%x, arg3=*0x%x, arg4=0x%x, buf=*0x%x, buf_size=0x%x)", arg1, arg2, arg3, arg4, buf, buf_size);
|
||||
|
||||
if (arg1 != 6 || arg2 != 0 || arg4 != sizeof(u32))
|
||||
{
|
||||
sys_fs.todo("sys_fs_test: unknown arguments (arg1=0x%x, arg2=0x%x, arg3=*0x%x, arg4=0x%x)", arg1, arg2, arg3, arg4);
|
||||
}
|
||||
|
||||
if (!arg3)
|
||||
{
|
||||
return CELL_EFAULT;
|
||||
}
|
||||
|
||||
const auto file = idm::get<lv2_fs_object>(*arg3);
|
||||
|
||||
if (!file)
|
||||
{
|
||||
return CELL_EBADF;
|
||||
}
|
||||
|
||||
for (u32 i = 0; i < buf_size; i++)
|
||||
{
|
||||
if (!(buf[i] = file->name[i]))
|
||||
{
|
||||
return CELL_OK;
|
||||
}
|
||||
}
|
||||
|
||||
buf[buf_size - 1] = 0;
|
||||
return CELL_OK;
|
||||
}
|
||||
|
||||
@ -664,7 +690,7 @@ error_code sys_fs_fcntl(u32 fd, u32 op, vm::ptr<void> _arg, u32 _size)
|
||||
|
||||
fs::file stream;
|
||||
stream.reset(std::move(sdata_file));
|
||||
if (const u32 id = idm::make<lv2_fs_object, lv2_file>(file->mp, std::move(stream), file->mode, file->flags))
|
||||
if (const u32 id = idm::make<lv2_fs_object, lv2_file>(*file, std::move(stream), file->mode, file->flags))
|
||||
{
|
||||
arg->out_code = CELL_OK;
|
||||
arg->out_fd = id;
|
||||
|
@ -130,12 +130,34 @@ struct lv2_fs_object
|
||||
// Mount Point
|
||||
const std::add_pointer_t<lv2_fs_mount_point> mp;
|
||||
|
||||
lv2_fs_object(lv2_fs_mount_point* mp)
|
||||
// File Name (max 1055)
|
||||
const std::array<char, 0x420> name;
|
||||
|
||||
lv2_fs_object(lv2_fs_mount_point* mp, const char* filename)
|
||||
: mp(mp)
|
||||
, name(get_name(filename))
|
||||
{
|
||||
}
|
||||
|
||||
static lv2_fs_mount_point* get_mp(const char* filename);
|
||||
|
||||
static std::array<char, 0x420> get_name(const char* filename)
|
||||
{
|
||||
std::array<char, 0x420> name;
|
||||
|
||||
for (auto& c : name)
|
||||
{
|
||||
c = *filename++;
|
||||
|
||||
if (!c)
|
||||
{
|
||||
return name;
|
||||
}
|
||||
}
|
||||
|
||||
name.back() = 0;
|
||||
return name;
|
||||
}
|
||||
};
|
||||
|
||||
struct lv2_file final : lv2_fs_object
|
||||
@ -145,15 +167,15 @@ struct lv2_file final : lv2_fs_object
|
||||
const s32 flags;
|
||||
|
||||
lv2_file(const char* filename, fs::file&& file, s32 mode, s32 flags)
|
||||
: lv2_fs_object(lv2_fs_object::get_mp(filename))
|
||||
: lv2_fs_object(lv2_fs_object::get_mp(filename), filename)
|
||||
, file(std::move(file))
|
||||
, mode(mode)
|
||||
, flags(flags)
|
||||
{
|
||||
}
|
||||
|
||||
lv2_file(lv2_fs_mount_point* mp, fs::file&& file, s32 mode, s32 flags)
|
||||
: lv2_fs_object(mp)
|
||||
lv2_file(const lv2_file& host, fs::file&& file, s32 mode, s32 flags)
|
||||
: lv2_fs_object(host.mp, host.name.data())
|
||||
, file(std::move(file))
|
||||
, mode(mode)
|
||||
, flags(flags)
|
||||
@ -178,7 +200,7 @@ struct lv2_dir final : lv2_fs_object
|
||||
const fs::dir dir;
|
||||
|
||||
lv2_dir(const char* filename, fs::dir&& dir)
|
||||
: lv2_fs_object(lv2_fs_object::get_mp(filename))
|
||||
: lv2_fs_object(lv2_fs_object::get_mp(filename), filename)
|
||||
, dir(std::move(dir))
|
||||
{
|
||||
}
|
||||
@ -284,7 +306,7 @@ CHECK_SIZE(lv2_file_c0000006, 0x20);
|
||||
|
||||
// Syscalls
|
||||
|
||||
error_code sys_fs_test(u32 arg1, u32 arg2, vm::ps3::ptr<u32> arg3, u32 arg4, vm::ps3::ptr<char> arg5, u32 arg6);
|
||||
error_code sys_fs_test(u32 arg1, u32 arg2, vm::ps3::ptr<u32> arg3, u32 arg4, vm::ps3::ptr<char> buf, u32 buf_size);
|
||||
error_code sys_fs_open(vm::ps3::cptr<char> path, s32 flags, vm::ps3::ptr<u32> fd, s32 mode, vm::ps3::cptr<void> arg, u64 size);
|
||||
error_code sys_fs_read(u32 fd, vm::ps3::ptr<void> buf, u64 nbytes, vm::ps3::ptr<u64> nread);
|
||||
error_code sys_fs_write(u32 fd, vm::ps3::cptr<void> buf, u64 nbytes, vm::ps3::ptr<u64> nwrite);
|
||||
|
Loading…
Reference in New Issue
Block a user