mirror of
git://git.kernel.org/pub/scm/linux/kernel/git/xiang/erofs.git
synced 2026-10-30 22:03:17 +01:00
vsock: Add support for SIOCINQ ioctl
Add support for SIOCINQ ioctl, indicating the length of bytes unread in the socket. The value is obtained from `vsock_stream_has_data()`. Signed-off-by: Xuewei Niu <[email protected]> Reviewed-by: Stefano Garzarella <[email protected]> Reviewed-by: Luigi Leonardi <[email protected]> Link: https://patch.msgid.link/[email protected] Signed-off-by: Jakub Kicinski <[email protected]>
This commit is contained in:
1 parent
f0c5827d07
commit
f7c7226592
1 file changed
+22
@@ -1389,6 +1389,28 @@ static int vsock_do_ioctl(struct socket *sock, unsigned int cmd,
|
||||
vsk = vsock_sk(sk);
|
||||
|
||||
switch (cmd) {
|
||||
case SIOCINQ: {
|
||||
ssize_t n_bytes;
|
||||
|
||||
if (!vsk->transport) {
|
||||
ret = -EOPNOTSUPP;
|
||||
break;
|
||||
}
|
||||
|
||||
if (sock_type_connectible(sk->sk_type) &&
|
||||
sk->sk_state == TCP_LISTEN) {
|
||||
ret = -EINVAL;
|
||||
break;
|
||||
}
|
||||
|
||||
n_bytes = vsock_stream_has_data(vsk);
|
||||
if (n_bytes < 0) {
|
||||
ret = n_bytes;
|
||||
break;
|
||||
}
|
||||
ret = put_user(n_bytes, arg);
|
||||
break;
|
||||
}
|
||||
case SIOCOUTQ: {
|
||||
ssize_t n_bytes;
|
||||
|
||||
|
||||
Reference in new issue
Block a user