diff options
author | Peter Elliott <pelliott@ualberta.ca> | 2021-07-26 23:06:22 -0600 |
---|---|---|
committer | Andreas Kling <kling@serenityos.org> | 2021-08-22 10:29:06 +0200 |
commit | 39a77559f194ca6580235b3b7e537bfe87a37d9e (patch) | |
tree | 2cd3a7fa6ef44358108bac3ef2f311ee956c6e03 /Kernel/Net/IPv4Socket.cpp | |
parent | db92e66902c691ca0d5dff8ec91e41c63149dc36 (diff) | |
download | serenity-39a77559f194ca6580235b3b7e537bfe87a37d9e.zip |
Kernel+LibC: Implement FIONREAD ioctl
FIONREAD gets the number of bytes availible to read from a file
descriptor without blocking. I only implemented it for regular files and
sockets
Diffstat (limited to 'Kernel/Net/IPv4Socket.cpp')
-rw-r--r-- | Kernel/Net/IPv4Socket.cpp | 8 |
1 files changed, 8 insertions, 0 deletions
diff --git a/Kernel/Net/IPv4Socket.cpp b/Kernel/Net/IPv4Socket.cpp index 5c56c9dc72..51e61eacd0 100644 --- a/Kernel/Net/IPv4Socket.cpp +++ b/Kernel/Net/IPv4Socket.cpp @@ -770,6 +770,14 @@ KResult IPv4Socket::ioctl(FileDescription&, unsigned request, Userspace<void*> a case SIOCSARP: case SIOCDARP: return ioctl_arp(); + + case FIONREAD: { + int readable = m_receive_buffer->immediately_readable(); + if (!copy_to_user(Userspace<int*>(arg), &readable)) + return EFAULT; + + return KSuccess; + } } return EINVAL; |