mirror of
https://github.com/shadps4-emu/shadPS4.git
synced 2025-08-03 14:48:46 +00:00
improved error codes in file system
This commit is contained in:
parent
8d647ee323
commit
6e21c73b69
1 changed files with 22 additions and 5 deletions
|
@ -150,7 +150,6 @@ int PS4_SYSV_ABI posix_close(int d) {
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
return result;
|
return result;
|
||||||
return ORBIS_OK;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
size_t PS4_SYSV_ABI sceKernelWrite(int d, const void* buf, size_t nbytes) {
|
size_t PS4_SYSV_ABI sceKernelWrite(int d, const void* buf, size_t nbytes) {
|
||||||
|
@ -367,8 +366,17 @@ s64 PS4_SYSV_ABI sceKernelPread(int d, void* buf, size_t nbytes, s64 offset) {
|
||||||
|
|
||||||
int PS4_SYSV_ABI sceKernelFStat(int fd, OrbisKernelStat* sb) {
|
int PS4_SYSV_ABI sceKernelFStat(int fd, OrbisKernelStat* sb) {
|
||||||
LOG_INFO(Kernel_Fs, "(PARTIAL) fd = {}", fd);
|
LOG_INFO(Kernel_Fs, "(PARTIAL) fd = {}", fd);
|
||||||
|
if (fd < 3) {
|
||||||
|
return ORBIS_KERNEL_ERROR_EPERM;
|
||||||
|
}
|
||||||
|
if (sb == nullptr) {
|
||||||
|
return ORBIS_KERNEL_ERROR_EFAULT;
|
||||||
|
}
|
||||||
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) {
|
||||||
|
return ORBIS_KERNEL_ERROR_EBADF;
|
||||||
|
}
|
||||||
std::memset(sb, 0, sizeof(OrbisKernelStat));
|
std::memset(sb, 0, sizeof(OrbisKernelStat));
|
||||||
|
|
||||||
if (file->is_directory) {
|
if (file->is_directory) {
|
||||||
|
@ -421,15 +429,24 @@ int PS4_SYSV_ABI sceKernelFtruncate(int fd, s64 length) {
|
||||||
}
|
}
|
||||||
|
|
||||||
static int GetDents(int fd, char* buf, int nbytes, s64* basep) {
|
static int GetDents(int fd, char* buf, int nbytes, s64* basep) {
|
||||||
// TODO error codes
|
if (fd < 3) {
|
||||||
ASSERT(buf != nullptr);
|
return ORBIS_KERNEL_ERROR_EBADF;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (buf == nullptr) {
|
||||||
|
return ORBIS_KERNEL_ERROR_EFAULT;
|
||||||
|
}
|
||||||
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) {
|
||||||
|
return ORBIS_KERNEL_ERROR_EBADF;
|
||||||
|
}
|
||||||
if (file->dirents_index == file->dirents.size()) {
|
if (file->dirents_index == file->dirents.size()) {
|
||||||
return ORBIS_OK;
|
return ORBIS_OK;
|
||||||
}
|
}
|
||||||
|
if (!file->is_directory || nbytes < 512 || file->dirents_index > file->dirents.size()) {
|
||||||
|
return ORBIS_KERNEL_ERROR_EINVAL;
|
||||||
|
}
|
||||||
const auto& entry = file->dirents.at(file->dirents_index++);
|
const auto& entry = file->dirents.at(file->dirents_index++);
|
||||||
auto str = entry.name;
|
auto str = entry.name;
|
||||||
auto str_size = str.size() - 1;
|
auto str_size = str.size() - 1;
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue