From 1908d26093fcdf409b74eef83cffbb812d447a3f Mon Sep 17 00:00:00 2001 From: mailwl Date: Mon, 24 Mar 2025 16:51:36 +0300 Subject: [PATCH] lseek: let the host OS set lseek errors (#2370) * Fix lseek(fd, -1, SEEK_SET) for XNA * be sure, if seek really return error * refactoring * let host os set lseek errors --- src/common/io_file.cpp | 14 -------------- src/core/libraries/kernel/file_system.cpp | 1 + 2 files changed, 1 insertion(+), 14 deletions(-) diff --git a/src/common/io_file.cpp b/src/common/io_file.cpp index 067010a26..3db78a145 100644 --- a/src/common/io_file.cpp +++ b/src/common/io_file.cpp @@ -377,20 +377,6 @@ bool IOFile::Seek(s64 offset, SeekOrigin origin) const { return false; } - if (False(file_access_mode & (FileAccessMode::Write | FileAccessMode::Append))) { - u64 size = GetSize(); - if (origin == SeekOrigin::CurrentPosition && Tell() + offset > size) { - LOG_ERROR(Common_Filesystem, "Seeking past the end of the file"); - return false; - } else if (origin == SeekOrigin::SetOrigin && (u64)offset > size) { - LOG_ERROR(Common_Filesystem, "Seeking past the end of the file"); - return false; - } else if (origin == SeekOrigin::End && offset > 0) { - LOG_ERROR(Common_Filesystem, "Seeking past the end of the file"); - return false; - } - } - errno = 0; const auto seek_result = fseeko(file, offset, ToSeekOrigin(origin)) == 0; diff --git a/src/core/libraries/kernel/file_system.cpp b/src/core/libraries/kernel/file_system.cpp index 0150c11f5..ef3c2fe70 100644 --- a/src/core/libraries/kernel/file_system.cpp +++ b/src/core/libraries/kernel/file_system.cpp @@ -289,6 +289,7 @@ size_t PS4_SYSV_ABI _writev(int fd, const SceKernelIovec* iov, int iovcn) { } s64 PS4_SYSV_ABI sceKernelLseek(int d, s64 offset, int whence) { + LOG_TRACE(Kernel_Fs, "called: offset {} whence {}", offset, whence); auto* h = Common::Singleton::Instance(); auto* file = h->GetFile(d); if (file == nullptr) {