forked from Bananymous/banan-os
Kernel/LibC: Update SYS_SEEK to return new offset and implement lseek
This commit is contained in:
parent
7630170ed6
commit
83e3409bd8
|
@ -33,7 +33,7 @@ namespace Kernel
|
||||||
|
|
||||||
BAN::ErrorOr<int> fcntl(int fd, int cmd, int extra);
|
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<off_t> tell(int) const;
|
||||||
|
|
||||||
BAN::ErrorOr<void> fstat(int fd, struct stat*) const;
|
BAN::ErrorOr<void> fstat(int fd, struct stat*) const;
|
||||||
|
|
|
@ -207,7 +207,7 @@ namespace Kernel
|
||||||
return BAN::Error::from_errno(ENOTSUP);
|
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));
|
TRY(validate_fd(fd));
|
||||||
|
|
||||||
|
@ -233,7 +233,7 @@ namespace Kernel
|
||||||
|
|
||||||
m_open_files[fd]->offset = new_offset;
|
m_open_files[fd]->offset = new_offset;
|
||||||
|
|
||||||
return {};
|
return new_offset;
|
||||||
}
|
}
|
||||||
|
|
||||||
BAN::ErrorOr<off_t> OpenFileDescriptorSet::tell(int fd) const
|
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)
|
BAN::ErrorOr<long> Process::sys_seek(int fd, off_t offset, int whence)
|
||||||
{
|
{
|
||||||
LockGuard _(m_process_lock);
|
LockGuard _(m_process_lock);
|
||||||
TRY(m_open_file_descriptors.seek(fd, offset, whence));
|
return TRY(m_open_file_descriptors.seek(fd, offset, whence));
|
||||||
return 0;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
BAN::ErrorOr<long> Process::sys_tell(int fd)
|
BAN::ErrorOr<long> Process::sys_tell(int fd)
|
||||||
|
|
|
@ -93,6 +93,11 @@ ssize_t pread(int fildes, void* buf, size_t nbyte, off_t offset)
|
||||||
return syscall(SYS_PREAD, fildes, buf, nbyte, offset);
|
return syscall(SYS_PREAD, fildes, buf, nbyte, offset);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
off_t lseek(int fildes, off_t offset, int whence)
|
||||||
|
{
|
||||||
|
return syscall(SYS_SEEK, fildes, offset, whence);
|
||||||
|
}
|
||||||
|
|
||||||
int dup(int fildes)
|
int dup(int fildes)
|
||||||
{
|
{
|
||||||
return syscall(SYS_DUP, fildes);
|
return syscall(SYS_DUP, fildes);
|
||||||
|
|
Loading…
Reference in New Issue