Proper handling of whence 3 & 4

This commit is contained in:
Stephen Miller 2025-04-26 22:37:53 -05:00
parent e816bc4b99
commit 83926f90eb
3 changed files with 5 additions and 9 deletions

View File

@ -131,9 +131,7 @@ namespace {
case SeekOrigin::End: case SeekOrigin::End:
return SEEK_END; return SEEK_END;
default: default:
LOG_ERROR(Common_Filesystem, "Unsupported origin {}, defaulting to SEEK_SET", UNREACHABLE_MSG("Impossible SeekOrigin {}", static_cast<u32>(origin));
static_cast<u32>(origin));
return SEEK_SET;
} }
} }

View File

@ -61,8 +61,6 @@ enum class SeekOrigin : u32 {
SetOrigin, // Seeks from the start of the file. SetOrigin, // Seeks from the start of the file.
CurrentPosition, // Seeks from the current file pointer position. CurrentPosition, // Seeks from the current file pointer position.
End, // Seeks from the end of the file. End, // Seeks from the end of the file.
SeekHole, // Seeks from the start of the next hole in the file.
SeekData, // Seeks from the start of the next non-hole region in the file.
}; };
class IOFile final { class IOFile final {

View File

@ -365,10 +365,10 @@ s64 PS4_SYSV_ABI posix_lseek(s32 fd, s64 offset, s32 whence) {
origin = Common::FS::SeekOrigin::CurrentPosition; origin = Common::FS::SeekOrigin::CurrentPosition;
} else if (whence == 2) { } else if (whence == 2) {
origin = Common::FS::SeekOrigin::End; origin = Common::FS::SeekOrigin::End;
} else if (whence == 3) { } else if (whence == 3 || whence == 4) {
origin = Common::FS::SeekOrigin::SeekHole; // whence parameter belongs to an unsupported POSIX extension
} else if (whence == 4) { *__Error() = POSIX_ENOTTY;
origin = Common::FS::SeekOrigin::SeekData; return -1;
} else { } else {
// whence parameter is invalid // whence parameter is invalid
*__Error() = POSIX_EINVAL; *__Error() = POSIX_EINVAL;