Kernel: Support FIONBIO ioctl
This commit is contained in:
@@ -34,6 +34,7 @@ namespace Kernel
|
||||
BAN::ErrorOr<int> dup2(int, int);
|
||||
|
||||
BAN::ErrorOr<int> fcntl(int fd, int cmd, uintptr_t extra);
|
||||
BAN::ErrorOr<long> ioctl(int fd, unsigned long request, void* arg);
|
||||
|
||||
BAN::ErrorOr<off_t> seek(int fd, off_t offset, int whence);
|
||||
BAN::ErrorOr<off_t> tell(int) const;
|
||||
|
||||
@@ -354,6 +354,35 @@ namespace Kernel
|
||||
return BAN::Error::from_errno(ENOTSUP);
|
||||
}
|
||||
|
||||
BAN::ErrorOr<long> OpenFileDescriptorSet::ioctl(int fd, unsigned long request, void* arg)
|
||||
{
|
||||
BAN::RefPtr<Inode> inode;
|
||||
|
||||
{
|
||||
LockGuard _(m_mutex);
|
||||
|
||||
TRY(validate_fd(fd));
|
||||
|
||||
switch (request)
|
||||
{
|
||||
case FIONBIO:
|
||||
{
|
||||
int enabled;
|
||||
TRY(read_from_user(arg, &enabled, sizeof(int)));
|
||||
if (enabled)
|
||||
m_open_files[fd]->status_flags |= O_NONBLOCK;
|
||||
else
|
||||
m_open_files[fd]->status_flags &= ~O_NONBLOCK;
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
inode = m_open_files[fd]->file.inode;
|
||||
}
|
||||
|
||||
return inode->ioctl(request, arg);
|
||||
}
|
||||
|
||||
BAN::ErrorOr<off_t> OpenFileDescriptorSet::seek(int fd, off_t offset, int whence)
|
||||
{
|
||||
LockGuard _(m_mutex);
|
||||
|
||||
@@ -2049,8 +2049,7 @@ namespace Kernel
|
||||
|
||||
BAN::ErrorOr<long> Process::sys_ioctl(int fildes, unsigned long request, void* arg)
|
||||
{
|
||||
auto inode = TRY(m_open_file_descriptors.inode_of(fildes));
|
||||
return TRY(inode->ioctl(request, arg));
|
||||
return m_open_file_descriptors.ioctl(fildes, request, arg);
|
||||
}
|
||||
|
||||
BAN::ErrorOr<long> Process::sys_pselect(sys_pselect_t* user_arguments)
|
||||
|
||||
Reference in New Issue
Block a user