Make FIONREAD return the actual that a read() would return, not just the

amount of data in the first mbuf.

Obtained from: Bob Smart <smart@mel.dit.csiro.au> (for NetBSD & SunOS)
This commit is contained in:
Peter Wemm 1995-12-11 13:24:58 +00:00
parent 6d41b96fd7
commit 8c1f170b90

View File

@ -431,9 +431,11 @@ tunioctl(dev, cmd, data, flag, p)
break;
case FIONREAD:
s = splimp();
if (tp->tun_if.if_snd.ifq_head)
*(int *)data = tp->tun_if.if_snd.ifq_head->m_len;
else
if (tp->tun_if.if_snd.ifq_head) {
struct mbuf *mb = tp->tun_if.if_snd.ifq_head;
for( *(int *)data = 0; mb != 0; mb = mb->m_next)
*(int *)data += mb->m_len;
} else
*(int *)data = 0;
splx(s);
break;