Kernel/LibC: Update SYS_SEEK to return new offset and implement lseek

This commit is contained in:
2024-05-23 14:49:23 +03:00
parent 7630170ed6
commit 83e3409bd8
4 changed files with 9 additions and 5 deletions

View File

@@ -207,7 +207,7 @@ namespace Kernel
return BAN::Error::from_errno(ENOTSUP);
}
BAN::ErrorOr<void> OpenFileDescriptorSet::seek(int fd, off_t offset, int whence)
BAN::ErrorOr<off_t> OpenFileDescriptorSet::seek(int fd, off_t offset, int whence)
{
TRY(validate_fd(fd));
@@ -233,7 +233,7 @@ namespace Kernel
m_open_files[fd]->offset = new_offset;
return {};
return new_offset;
}
BAN::ErrorOr<off_t> OpenFileDescriptorSet::tell(int fd) const

View File

@@ -1136,8 +1136,7 @@ namespace Kernel
BAN::ErrorOr<long> Process::sys_seek(int fd, off_t offset, int whence)
{
LockGuard _(m_process_lock);
TRY(m_open_file_descriptors.seek(fd, offset, whence));
return 0;
return TRY(m_open_file_descriptors.seek(fd, offset, whence));
}
BAN::ErrorOr<long> Process::sys_tell(int fd)