Thread (3 messages) flat view 3 messages, 2 authors, 2021-03-10

TIOCOUTQ implementation for sockets vs. tty

From: Henneberg - Systemdesign <hidden>
Date: 2021-03-10 18:17:34

Hi,

I have a question regarding the implementation of ioctl TIOCOUTQ for
various sockets compared to the tty implementation.

For several sockets, e. g. AF_BLUETOOTH it is done like this

af_bluetooth.c:
case TIOCOUTQ:
	if (sk->sk_state == BT_LISTEN)
		return -EINVAL;

	amount = sk->sk_sndbuf - sk_wmem_alloc_get(sk);
	if (amount < 0)
		amount = 0;
	err = put_user(amount, (int __user *)arg);
	break;

so the ioctl returns the available space in the send queue if I
understand the code correctly (this is also what I observed from tests).

The tty does this:

n_tty.c:
case TIOCOUTQ:
	return put_user(tty_chars_in_buffer(tty), (int __user *) arg);

so it returns the used space in the send queue. This is also what I
would expect from the manpage description.

Is this mismatch intentional?

Regards
-Jochen
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help