implemented sceKernelClose

This commit is contained in:
georgemoralis 2023-10-20 16:11:10 +03:00
parent 40a3868cbc
commit 7cfcd952d2
4 changed files with 14 additions and 1 deletions

View File

@ -48,6 +48,7 @@ void LibKernel_Register(SymbolsResolver* sym) {
LIB_FUNCTION("-2IRUCO--PM", "libkernel", 1, "libkernel", 1, 1, sceKernelReadTsc);
// fs
LIB_FUNCTION("1G3lF1Gg1k8", "libkernel", 1, "libkernel", 1, 1, Emulator::HLE::Libraries::LibKernel::FileSystem::sceKernelOpen);
LIB_FUNCTION("UK2Tl2DWUns", "libkernel", 1, "libkernel", 1, 1, Emulator::HLE::Libraries::LibKernel::FileSystem::sceKernelClose);
LIB_FUNCTION("wuCroIGjt2g", "libScePosix", 1, "libkernel", 1, 1, Emulator::HLE::Libraries::LibKernel::FileSystem::POSIX::open);
}

View File

@ -40,4 +40,12 @@ int PS4_SYSV_ABI sceKernelOpen(const char* path, int flags, u16 mode) {
return handle;
}
int PS4_SYSV_ABI sceKernelClose(int d) {
LOG_INFO_IF(log_file_fs, "sceKernelClose descriptor = {}\n", d);
auto* h = singleton<Emulator::Host::Fs::HandleTable>::instance();
Emulator::Host::Fs::File file = h->getFile(d);
file.valid = false;
h->freeHandle(d);
return SCE_OK;
}
} // namespace Emulator::HLE::Libraries::LibKernel::FileSystem

View File

@ -7,5 +7,6 @@ constexpr u32 SCE_KERNEL_O_CREAT = 0x0200;
constexpr u32 SCE_KERNEL_O_DIRECTORY = 0x00020000;
int PS4_SYSV_ABI sceKernelOpen(const char *path, int flags, /* SceKernelMode*/ u16 mode);
int PS4_SYSV_ABI sceKernelClose(int d);
} // namespace Emulator::HLE::Libraries::LibKernel::FileSystem

View File

@ -1,11 +1,14 @@
#include "posix_file_system.h"
#include <debug.h>
#include <Util/log.h>
#include "file_system.h"
namespace Emulator::HLE::Libraries::LibKernel::FileSystem::POSIX {
constexpr bool log_file_pfs = true; // disable it to disable logging
int PS4_SYSV_ABI open(const char* path, int flags, /* SceKernelMode*/ u16 mode) {
LOG_INFO_IF(log_file_pfs, "posix open redirect to sceKernelOpen\n");
int result = sceKernelOpen(path, flags, mode);
if (result < 0) {
BREAKPOINT(); // posix calls different only for their return values