diff options
| -rw-r--r-- | net/bluetooth/af_bluetooth.c | 23 |
1 files changed, 23 insertions, 0 deletions
diff --git a/net/bluetooth/af_bluetooth.c b/net/bluetooth/af_bluetooth.c index 88afe25003d8..77fe9b868fee 100644 --- a/net/bluetooth/af_bluetooth.c +++ b/net/bluetooth/af_bluetooth.c | |||
| @@ -335,11 +335,34 @@ EXPORT_SYMBOL(bt_sock_poll); | |||
| 335 | int bt_sock_ioctl(struct socket *sock, unsigned int cmd, unsigned long arg) | 335 | int bt_sock_ioctl(struct socket *sock, unsigned int cmd, unsigned long arg) |
| 336 | { | 336 | { |
| 337 | struct sock *sk = sock->sk; | 337 | struct sock *sk = sock->sk; |
| 338 | struct sk_buff *skb; | ||
| 339 | long amount; | ||
| 338 | int err; | 340 | int err; |
| 339 | 341 | ||
| 340 | BT_DBG("sk %p cmd %x arg %lx", sk, cmd, arg); | 342 | BT_DBG("sk %p cmd %x arg %lx", sk, cmd, arg); |
| 341 | 343 | ||
| 342 | switch (cmd) { | 344 | switch (cmd) { |
| 345 | case TIOCOUTQ: | ||
| 346 | if (sk->sk_state == BT_LISTEN) | ||
| 347 | return -EINVAL; | ||
| 348 | |||
| 349 | amount = sk->sk_sndbuf - atomic_read(&sk->sk_wmem_alloc); | ||
| 350 | if (amount < 0) | ||
| 351 | amount = 0; | ||
| 352 | err = put_user(amount, (int __user *) arg); | ||
| 353 | break; | ||
| 354 | |||
| 355 | case TIOCINQ: | ||
| 356 | if (sk->sk_state == BT_LISTEN) | ||
| 357 | return -EINVAL; | ||
| 358 | |||
| 359 | lock_sock(sk); | ||
| 360 | skb = skb_peek(&sk->sk_receive_queue); | ||
| 361 | amount = skb ? skb->len : 0; | ||
| 362 | release_sock(sk); | ||
| 363 | err = put_user(amount, (int __user *) arg); | ||
| 364 | break; | ||
| 365 | |||
| 343 | case SIOCGSTAMP: | 366 | case SIOCGSTAMP: |
| 344 | err = sock_get_timestamp(sk, (struct timeval __user *) arg); | 367 | err = sock_get_timestamp(sk, (struct timeval __user *) arg); |
| 345 | break; | 368 | break; |
