1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-05-31 11:08:11 +00:00

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

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;