Kernel/LibC: Update SYS_SEEK to return new offset and implement lseek
This commit is contained in:
@@ -33,7 +33,7 @@ namespace Kernel
|
||||
|
||||
BAN::ErrorOr<int> fcntl(int fd, int cmd, int extra);
|
||||
|
||||
BAN::ErrorOr<void> seek(int fd, off_t offset, int whence);
|
||||
BAN::ErrorOr<off_t> seek(int fd, off_t offset, int whence);
|
||||
BAN::ErrorOr<off_t> tell(int) const;
|
||||
|
||||
BAN::ErrorOr<void> fstat(int fd, struct stat*) const;
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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)
|
||||
|
||||
Reference in New Issue
Block a user