From 23a38374fcb4e8fa0199d0ad6c21c67837368aa9 Mon Sep 17 00:00:00 2001 From: ecki Date: Mon, 12 Nov 2001 01:36:48 +0000 Subject: [PATCH] added SI unit patch from adam@cfar.umd.edu to output of ifconfig byte counters --- lib/interface.c | 35 ++++++++++++++++++++++++++--------- 1 file changed, 26 insertions(+), 9 deletions(-) diff --git a/lib/interface.c b/lib/interface.c index 94cae607b..72fc45e2e 100644 --- a/lib/interface.c +++ b/lib/interface.c @@ -7,7 +7,7 @@ 8/2000 Andi Kleen make the list operations a bit more efficient. People are crazy enough to use thousands of aliases now. - $Id: interface.c,v 1.18 2001/11/10 17:10:01 ecki Exp $ + $Id: interface.c,v 1.19 2001/11/12 01:36:48 ecki Exp $ */ #include "config.h" @@ -843,20 +843,37 @@ void ife_print_long(struct interface *ptr) tx = ptr->stats.tx_bytes; short_rx = rx * 10; short_tx = tx * 10; - if (rx > 1048576) { + if (rx > 1125899906842624) { + short_rx /= 1125899906842624; + Rext = "PiB"; + } else if (rx > 1099511627776) { + short_rx /= 1099511627776; + Rext = "TiB"; + } else if (rx > 1073741824) { + short_rx /= 1073741824; + Rext = "GiB"; + } else if (rx > 1048576) { short_rx /= 1048576; - Rext = "MB"; + Rext = "MiB"; } else if (rx > 1024) { short_rx /= 1024; - Rext = "kB"; + Rext = "KiB"; } - if (tx > 1048576) { + if (tx > 1125899906842624) { + short_tx /= 1125899906842624; + Text = "PiB"; + } else if (tx > 1099511627776) { + short_tx /= 1099511627776; + Text = "TiB"; + } else if (tx > 1073741824) { + short_tx /= 1073741824; + Text = "GiB"; + } else if (tx > 1048576) { short_tx /= 1048576; - Text = "MB"; - } - else if (tx > 1024) { + Text = "MiB"; + } else if (tx > 1024) { short_tx /= 1024; - Text = "kB"; + Text = "KiB"; } printf(" "); -- 2.11.4.GIT