mirror of
https://github.com/shadps4-emu/shadPS4.git
synced 2025-06-07 03:03:15 +00:00
Implement posix_writev and sceKernelWritev
Also fixes error behavior on writev, since it shouldn't ever return kernel errors (since our device files return those)
This commit is contained in:
parent
2920707702
commit
dd027c6d36
1 changed files with 23 additions and 4 deletions
|
@ -291,25 +291,44 @@ size_t PS4_SYSV_ABI sceKernelReadv(s32 fd, const SceKernelIovec* iov, s32 iovcnt
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
size_t PS4_SYSV_ABI writev(int fd, const SceKernelIovec* iov, int iovcn) {
|
size_t PS4_SYSV_ABI writev(s32 fd, const SceKernelIovec* iov, s32 iovcnt) {
|
||||||
auto* h = Common::Singleton<Core::FileSys::HandleTable>::Instance();
|
auto* h = Common::Singleton<Core::FileSys::HandleTable>::Instance();
|
||||||
auto* file = h->GetFile(fd);
|
auto* file = h->GetFile(fd);
|
||||||
if (file == nullptr) {
|
if (file == nullptr) {
|
||||||
return ORBIS_KERNEL_ERROR_EBADF;
|
*__Error() = POSIX_EBADF;
|
||||||
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
std::scoped_lock lk{file->m_mutex};
|
std::scoped_lock lk{file->m_mutex};
|
||||||
|
|
||||||
if (file->type == Core::FileSys::FileType::Device) {
|
if (file->type == Core::FileSys::FileType::Device) {
|
||||||
return file->device->writev(iov, iovcn);
|
size_t result = file->device->writev(iov, iovcnt);
|
||||||
|
if (result < 0) {
|
||||||
|
ErrSceToPosix(result);
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
return result;
|
||||||
}
|
}
|
||||||
size_t total_written = 0;
|
size_t total_written = 0;
|
||||||
for (int i = 0; i < iovcn; i++) {
|
for (s32 i = 0; i < iovcnt; i++) {
|
||||||
total_written += file->f.WriteRaw<u8>(iov[i].iov_base, iov[i].iov_len);
|
total_written += file->f.WriteRaw<u8>(iov[i].iov_base, iov[i].iov_len);
|
||||||
}
|
}
|
||||||
return total_written;
|
return total_written;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
size_t PS4_SYSV_ABI posix_writev(int fd, const SceKernelIovec* iov, int iovcnt) {
|
||||||
|
return writev(fd, iov, iovcnt);
|
||||||
|
}
|
||||||
|
|
||||||
|
size_t PS4_SYSV_ABI sceKernelWritev(int fd, const SceKernelIovec* iov, int iovcnt) {
|
||||||
|
size_t result = writev(fd, iov, iovcnt);
|
||||||
|
if (result < 0) {
|
||||||
|
LOG_ERROR(Kernel_Fs, "writev: error = {}", *__Error());
|
||||||
|
return ErrnoToSceKernelError(*__Error());
|
||||||
|
}
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
s64 PS4_SYSV_ABI sceKernelLseek(int d, s64 offset, int whence) {
|
s64 PS4_SYSV_ABI sceKernelLseek(int d, s64 offset, int whence) {
|
||||||
auto* h = Common::Singleton<Core::FileSys::HandleTable>::Instance();
|
auto* h = Common::Singleton<Core::FileSys::HandleTable>::Instance();
|
||||||
auto* file = h->GetFile(d);
|
auto* file = h->GetFile(d);
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue