Kernel: Fix SYS_SEEK with SEEK_END
I was subtracting the offset from file end when I should have added it.
This commit is contained in:
parent
45ffa1b79c
commit
39be57424c
|
@ -217,23 +217,23 @@ namespace Kernel
|
||||||
{
|
{
|
||||||
TRY(validate_fd(fd));
|
TRY(validate_fd(fd));
|
||||||
|
|
||||||
off_t new_offset = 0;
|
off_t base_offset;
|
||||||
|
|
||||||
switch (whence)
|
switch (whence)
|
||||||
{
|
{
|
||||||
|
case SEEK_SET:
|
||||||
|
base_offset = 0;
|
||||||
|
break;
|
||||||
case SEEK_CUR:
|
case SEEK_CUR:
|
||||||
new_offset = m_open_files[fd]->offset + offset;
|
base_offset = m_open_files[fd]->offset;
|
||||||
break;
|
break;
|
||||||
case SEEK_END:
|
case SEEK_END:
|
||||||
new_offset = m_open_files[fd]->inode->size() - offset;
|
base_offset = m_open_files[fd]->inode->size();
|
||||||
break;
|
|
||||||
case SEEK_SET:
|
|
||||||
new_offset = offset;
|
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
return BAN::Error::from_errno(EINVAL);
|
return BAN::Error::from_errno(EINVAL);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const off_t new_offset = base_offset + offset;
|
||||||
if (new_offset < 0)
|
if (new_offset < 0)
|
||||||
return BAN::Error::from_errno(EINVAL);
|
return BAN::Error::from_errno(EINVAL);
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue