Implement the FIONREAD ioctl for sockets. We already supported it in userland
but the kernel part was missing. It is used to query for the buffer size that can be retrieved using recv(). It returns the same value we use for the read select(). git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@30786 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
@@ -70,7 +70,7 @@ int socket_bind(net_socket* socket, const struct sockaddr* address,
|
||||
socklen_t addressLength);
|
||||
int socket_setsockopt(net_socket* socket, int level, int option,
|
||||
const void* value, int length);
|
||||
|
||||
ssize_t socket_read_avail(net_socket* socket);
|
||||
|
||||
static SocketList sSocketList;
|
||||
static mutex sSocketLock;
|
||||
@@ -496,6 +496,23 @@ socket_control(net_socket* socket, int32 op, void* data, size_t length)
|
||||
sizeof(int));
|
||||
}
|
||||
|
||||
case FIONREAD:
|
||||
{
|
||||
if (data == NULL)
|
||||
return B_BAD_VALUE;
|
||||
|
||||
ssize_t available = socket_read_avail(socket);
|
||||
if (is_syscall()) {
|
||||
if (!IS_USER_ADDRESS(data)
|
||||
|| user_memcpy(data, &available, sizeof(ssize_t)) != B_OK) {
|
||||
return B_BAD_ADDRESS;
|
||||
}
|
||||
} else
|
||||
*(ssize_t *)data = available;
|
||||
|
||||
return B_OK;
|
||||
}
|
||||
|
||||
case B_SET_BLOCKING_IO:
|
||||
case B_SET_NONBLOCKING_IO:
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user