diff options
author | peter <peter@FreeBSD.org> | 1995-12-11 13:24:58 +0000 |
---|---|---|
committer | peter <peter@FreeBSD.org> | 1995-12-11 13:24:58 +0000 |
commit | 286d95551f8211bbe15b8be12c6eaf9325c1232f (patch) | |
tree | 63e57ac213a78a36778e0a60e506d9af6f437fbf | |
parent | 7a7fb14fa9b36f5a77f0861c85e6bb995aa6b757 (diff) | |
download | FreeBSD-src-286d95551f8211bbe15b8be12c6eaf9325c1232f.zip FreeBSD-src-286d95551f8211bbe15b8be12c6eaf9325c1232f.tar.gz |
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)
-rw-r--r-- | sys/net/if_tun.c | 8 |
1 files changed, 5 insertions, 3 deletions
diff --git a/sys/net/if_tun.c b/sys/net/if_tun.c index 675995f..a9db860 100644 --- a/sys/net/if_tun.c +++ b/sys/net/if_tun.c @@ -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; |