WFS: Implemented the GET_SIZE ioctl.

This commit is contained in:
Pierre Bourdon 2017-08-06 22:18:48 +02:00
parent 2f5ddf12a9
commit 49a4712f33
2 changed files with 25 additions and 0 deletions

View File

@ -4,6 +4,7 @@
#include "Core/IOS/WFS/WFSSRV.h"
#include <cinttypes>
#include <string>
#include <vector>
@ -157,6 +158,28 @@ IPCCommandResult WFSSRV::IOCtl(const IOCtlRequest& request)
break;
}
case IOCTL_WFS_GET_SIZE:
{
u16 fd = Memory::Read_U16(request.buffer_in);
FileDescriptor* fd_obj = FindFileDescriptor(fd);
if (fd_obj == nullptr)
{
ERROR_LOG(IOS, "IOCTL_WFS_GET_SIZE: invalid file descriptor %d", fd);
return_error_code = WFS_EBADFD;
break;
}
u64 size = fd_obj->file.GetSize();
u32 truncated_size = static_cast<u32>(size);
INFO_LOG(IOS, "IOCTL_WFS_GET_SIZE(%d) -> %d", fd, truncated_size);
if (size != truncated_size)
{
ERROR_LOG(IOS, "IOCTL_WFS_GET_SIZE: file %d too large (%" PRIu64 ")", fd, size);
}
Memory::Write_U32(truncated_size, request.buffer_out);
break;
}
case IOCTL_WFS_CLOSE:
{
u16 fd = Memory::Read_U16(request.buffer_in + 0x4);

View File

@ -61,6 +61,7 @@ private:
IOCTL_WFS_DELETE = 0x15,
IOCTL_WFS_GET_ATTRIBUTES = 0x17,
IOCTL_WFS_OPEN = 0x1A,
IOCTL_WFS_GET_SIZE = 0x1B,
IOCTL_WFS_CLOSE = 0x1E,
IOCTL_WFS_READ = 0x20,
IOCTL_WFS_WRITE = 0x22,
@ -70,6 +71,7 @@ private:
enum
{
WFS_EBADFD = -10026, // Invalid file descriptor.
WFS_EEMPTY = -10028, // Directory is empty of iteration completed.
};