mirror of
https://github.com/boykopovar/AnyPS5.git
synced 2026-11-05 13:20:11 +00:00
Merge pull request #8591 from xXPBSXx/fix/getdirentries-basep-windows
fix(libkernel): report the starting entry index in getdirentries basep on Windows
This commit is contained in:
4 files changed
+15
-10
No files matched your search
@@ -1662,12 +1662,17 @@ if(BUILD_TESTING)
|
||||
set_tests_properties(guest_directory_rewind PROPERTIES TIMEOUT 15 ENVIRONMENT_MODIFICATION
|
||||
"PATH=path_list_prepend:$<TARGET_FILE_DIR:libkernel>")
|
||||
endif()
|
||||
if(NOT WIN32)
|
||||
add_test_executable(guest_directory_entry_tests ${LIBS_INCLUDE_DIR}/tests/GuestDirectoryEntries.cpp)
|
||||
target_include_directories(guest_directory_entry_tests PRIVATE ${LIBS_INCLUDE_DIR})
|
||||
target_link_libraries(guest_directory_entry_tests PRIVATE libkernel libc)
|
||||
add_test(NAME guest_directory_entries COMMAND guest_directory_entry_tests)
|
||||
else()
|
||||
add_test_executable(guest_directory_entry_tests ${LIBS_INCLUDE_DIR}/tests/GuestDirectoryEntries.cpp)
|
||||
target_include_directories(guest_directory_entry_tests PRIVATE ${LIBS_INCLUDE_DIR})
|
||||
target_link_libraries(guest_directory_entry_tests PRIVATE libkernel libc)
|
||||
add_test(NAME guest_directory_entries COMMAND guest_directory_entry_tests)
|
||||
if(WIN32)
|
||||
configure_windows_unwind(guest_directory_entry_tests)
|
||||
set_tests_properties(guest_directory_entries PROPERTIES TIMEOUT 15 ENVIRONMENT_MODIFICATION
|
||||
"PATH=path_list_prepend:$<TARGET_FILE_DIR:libkernel>")
|
||||
if(MINGW)
|
||||
target_compile_options(guest_directory_entry_tests PRIVATE -fasynchronous-unwind-tables)
|
||||
endif()
|
||||
add_test_executable(guest_directory_close_tests ${LIBS_INCLUDE_DIR}/tests/GuestDirectoryClose.cpp)
|
||||
target_include_directories(guest_directory_close_tests PRIVATE ${LIBS_INCLUDE_DIR})
|
||||
target_link_libraries(guest_directory_close_tests PRIVATE libkernel libc)
|
||||
|
||||
@@ -20,7 +20,7 @@ std::optional<std::filesystem::path> DirectoryDescriptorPath(int fd);
|
||||
void ForgetDirectoryDescriptor(int fd);
|
||||
void DuplicateDirectoryDescriptor(int from, int to);
|
||||
std::optional<std::int64_t> SeekDirectoryDescriptor(int fd, std::int64_t offset, int whence);
|
||||
int ReadDirectoryDescriptor(int fd, char* buf, int nbytes);
|
||||
int ReadDirectoryDescriptor(int fd, char* buf, int nbytes, std::int64_t* base = nullptr);
|
||||
|
||||
}
|
||||
|
||||
|
||||
@@ -153,12 +153,13 @@ std::optional<std::int64_t> SeekDirectoryDescriptor(int fd, std::int64_t offset,
|
||||
return target;
|
||||
}
|
||||
|
||||
int ReadDirectoryDescriptor(int fd, char* buf, int nbytes) {
|
||||
int ReadDirectoryDescriptor(int fd, char* buf, int nbytes, std::int64_t* base) {
|
||||
const auto found = Find(fd);
|
||||
if (!found) return SCE_KERNEL_ERROR_ENOTDIR;
|
||||
auto& state = *found;
|
||||
std::lock_guard lock(state.mutex);
|
||||
Load(state, fd);
|
||||
if (base != nullptr) *base = static_cast<std::int64_t>(state.cursor);
|
||||
std::size_t used = 0;
|
||||
while (state.cursor < state.entries.size()) {
|
||||
const auto& [name, type] = state.entries[state.cursor];
|
||||
|
||||
@@ -1101,8 +1101,7 @@ int APS5_VABI sceKernelGetdirentries(int fd, char* buf, int nbytes, int64_t* bas
|
||||
const GuestArena::HostWrite destination(buf, static_cast<std::size_t>(nbytes));
|
||||
const GuestArena::HostWrite baseDestination(basep, basep == nullptr ? 0 : sizeof(*basep));
|
||||
if (!destination.Open() || !baseDestination.Open()) return SceErrorFromErrno(GUEST_EFAULT);
|
||||
if (basep != nullptr) *basep = 0;
|
||||
return File::ReadDirectoryDescriptor(fd, buf, nbytes);
|
||||
return File::ReadDirectoryDescriptor(fd, buf, nbytes, basep);
|
||||
}
|
||||
|
||||
int APS5_VABI sceKernelGetdents(int fd, char* buf, int nbytes) {
|
||||
|
||||
Reference in new issue
Block a user