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:
return SEEK_END;
default:
LOG_ERROR(Common_Filesystem, "Unsupported origin {}, defaulting to SEEK_SET",
static_cast<u32>(origin));
return SEEK_SET;
UNREACHABLE_MSG("Impossible SeekOrigin {}", static_cast<u32>(origin));
}
}

View File

@ -61,8 +61,6 @@ enum class SeekOrigin : u32 {
SetOrigin, // Seeks from the start of the file.
CurrentPosition, // Seeks from the current file pointer position.
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 {

View File

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