mirror of
git://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
synced 2025-08-05 16:54:27 +00: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 <niuxuewei.nxw@antgroup.com> Reviewed-by: Stefano Garzarella <sgarzare@redhat.com> Reviewed-by: Luigi Leonardi <leonardi@redhat.com> Link: https://patch.msgid.link/20250708-siocinq-v6-2-3775f9a9e359@antgroup.com Signed-off-by: Jakub Kicinski <kuba@kernel.org>
This commit is contained in:
parent
f0c5827d07
commit
f7c7226592
1 changed files with 22 additions and 0 deletions
|
@ -1389,6 +1389,28 @@ static int vsock_do_ioctl(struct socket *sock, unsigned int cmd,
|
||||||
vsk = vsock_sk(sk);
|
vsk = vsock_sk(sk);
|
||||||
|
|
||||||
switch (cmd) {
|
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: {
|
case SIOCOUTQ: {
|
||||||
ssize_t n_bytes;
|
ssize_t n_bytes;
|
||||||
|
|
||||||
|
|
Loading…
Add table
Reference in a new issue