Kernel: Implement offset for lseek with SEEK_END

This commit is contained in:
Jelle Raaijmakers 2021-06-04 20:32:19 +02:00 committed by Andreas Kling
parent f73bb164ad
commit 3dab9d0b5c
Notes: sideshowbarker 2024-07-18 16:52:18 +09:00

View File

@ -136,7 +136,9 @@ KResultOr<off_t> FileDescription::seek(off_t offset, int whence)
case SEEK_END:
if (!metadata().is_valid())
return EIO;
new_offset = metadata().size;
if (Checked<off_t>::addition_would_overflow(metadata().size, offset))
return EOVERFLOW;
new_offset = metadata().size + offset;
break;
default:
return EINVAL;