Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions core/libs/prx/libkernel/File/src/NativeStat.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,14 @@
#include "prx/libc/include/General.hpp"

#include <algorithm>
#include <cerrno>
#include <stdexcept>
#include <string>

#ifdef _WIN32
#include "prx/libkernel/File/include/WindowsFileTime.hpp"
#include "prx/libkernel/File/include/WindowsSymbolicLink.hpp"
#include "prx/libc/include/WindowsDescriptor.hpp"
#include <io.h>
#include <sys/stat.h>
#include <sys/types.h>
Expand Down Expand Up @@ -42,6 +44,10 @@ static int DoStat(const std::filesystem::path& p, NativeStat* st) {
return result;
}
static int DoFstat(int fd, NativeStat* st) {
if (WindowsDescriptorHandle_nid_no_patch(fd) == INVALID_HANDLE_VALUE) {
errno = EBADF;
return -1;
}
if (_fstat64(fd, st) != 0) return -1;
return ReadHandleInfo(reinterpret_cast<HANDLE>(::_get_osfhandle(fd)), st);
}
Expand Down
15 changes: 15 additions & 0 deletions core/libs/tests/GuestFilesystem.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -96,6 +96,10 @@ std::int64_t APS5_VABI read_nid_postfix(int, void*, std::size_t);
std::int64_t APS5_VABI write_nid_postfix(int, const void*, std::size_t);
int APS5_VABI sceKernelDebugOutText(int, const char*);
}
#ifdef _WIN32
static bool g_invalidParameter = false;
static void RecordInvalidParameter(const wchar_t*, const wchar_t*, const wchar_t*, unsigned, std::uintptr_t) { g_invalidParameter = true; }
#endif
static void Check(bool value, int line) {
if (!value) {
#ifdef _WIN32
Expand Down Expand Up @@ -783,6 +787,17 @@ int main() {
Require(sceKernelFsync(socket) == static_cast<int>(0x80020009u));
Require(sceKernelFdatasync(0x7fffffff) == static_cast<int>(0x80020009u));
Require(sceKernelFsync(0x7fffffff) == static_cast<int>(0x80020009u));
#ifdef _WIN32
const auto previousParameterHandler = _set_invalid_parameter_handler(RecordInvalidParameter);
#endif
FileStat closedStatus{};
Require(sceKernelFstat(descriptor, &closedStatus) == static_cast<int>(0x80020009u));
Require(sceKernelFstat(socket, &closedStatus) == static_cast<int>(0x80020009u));
Require(sceKernelFstat(0x7fffffff, &closedStatus) == static_cast<int>(0x80020009u));
#ifdef _WIN32
_set_invalid_parameter_handler(previousParameterHandler);
Require(!g_invalidParameter);
#endif
Require(remove_nid_postfix(sized.string().c_str()) == 0);
const auto present = root / "present.txt";
const auto presentName = present.string();
Expand Down
Loading