Kernel: Support FIONBIO ioctl

This commit is contained in:
2026-07-20 04:07:23 +03:00
parent 583c2437b4
commit 51b9dcebbc
3 changed files with 31 additions and 2 deletions
@@ -34,6 +34,7 @@ namespace Kernel
BAN::ErrorOr<int> dup2(int, int); BAN::ErrorOr<int> dup2(int, int);
BAN::ErrorOr<int> fcntl(int fd, int cmd, uintptr_t extra); 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> seek(int fd, off_t offset, int whence);
BAN::ErrorOr<off_t> tell(int) const; BAN::ErrorOr<off_t> tell(int) const;
+29
View File
@@ -354,6 +354,35 @@ namespace Kernel
return BAN::Error::from_errno(ENOTSUP); 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) BAN::ErrorOr<off_t> OpenFileDescriptorSet::seek(int fd, off_t offset, int whence)
{ {
LockGuard _(m_mutex); LockGuard _(m_mutex);
+1 -2
View File
@@ -2049,8 +2049,7 @@ namespace Kernel
BAN::ErrorOr<long> Process::sys_ioctl(int fildes, unsigned long request, void* arg) BAN::ErrorOr<long> Process::sys_ioctl(int fildes, unsigned long request, void* arg)
{ {
auto inode = TRY(m_open_file_descriptors.inode_of(fildes)); return m_open_file_descriptors.ioctl(fildes, request, arg);
return TRY(inode->ioctl(request, arg));
} }
BAN::ErrorOr<long> Process::sys_pselect(sys_pselect_t* user_arguments) BAN::ErrorOr<long> Process::sys_pselect(sys_pselect_t* user_arguments)