WFS: Implement READ_ABSOLUTE (merged with READ implementation).

This commit is contained in:
Pierre Bourdon 2017-08-06 22:19:08 +02:00
parent 49a4712f33
commit 397f5e54e0
2 changed files with 20 additions and 6 deletions

View File

@ -189,26 +189,39 @@ IPCCommandResult WFSSRV::IOCtl(const IOCtlRequest& request)
}
case IOCTL_WFS_READ:
case IOCTL_WFS_READ_ABSOLUTE:
{
u32 addr = Memory::Read_U32(request.buffer_in);
u32 position = Memory::Read_U32(request.buffer_in + 4); // Only for absolute.
u16 fd = Memory::Read_U16(request.buffer_in + 0xC);
u32 size = Memory::Read_U32(request.buffer_in + 8);
bool absolute = request.request == IOCTL_WFS_READ_ABSOLUTE;
FileDescriptor* fd_obj = FindFileDescriptor(fd);
if (fd_obj == nullptr)
{
ERROR_LOG(IOS, "IOCTL_WFS_READ: invalid file descriptor %d", fd);
return_error_code = -1; // TODO(wfs): proper error code.
return_error_code = WFS_EBADFD;
break;
}
size_t read_bytes;
if (!fd_obj->file.ReadArray(Memory::GetPointer(addr), size, &read_bytes))
u64 previous_position = fd_obj->file.Tell();
if (absolute)
{
return_error_code = -1; // TODO(wfs): proper error code.
break;
fd_obj->file.Seek(position, SEEK_SET);
}
size_t read_bytes;
fd_obj->file.ReadArray(Memory::GetPointer(addr), size, &read_bytes);
// TODO(wfs): Handle read errors.
if (absolute)
{
fd_obj->file.Seek(previous_position, SEEK_SET);
}
else
{
fd_obj->position += read_bytes;
}
fd_obj->position += read_bytes;
INFO_LOG(IOS, "IOCTL_WFS_READ: read %zd bytes from FD %d (%s)", read_bytes, fd,
fd_obj->path.c_str());

View File

@ -67,6 +67,7 @@ private:
IOCTL_WFS_WRITE = 0x22,
IOCTL_WFS_ATTACH_DETACH = 0x2d,
IOCTL_WFS_ATTACH_DETACH_2 = 0x2e,
IOCTL_WFS_READ_ABSOLUTE = 0x48,
};
enum