From 4eac105ff088fde0eabfd792be8b1ec5e2901873 Mon Sep 17 00:00:00 2001 From: Phil Davis Date: Sun, 7 Feb 2016 21:44:23 +0545 Subject: Add support for TB when reporting bytes Forum: https://forum.pfsense.org/index.php?topic=106470.0 I believe that this should work OK on both 32 and 64 bit systems. A 32-bit system will convert big values of $bytes and big numbers like 1099511627776 to float first, then do the comparison. 64-bit systems will do (int) comparisons. Either way, in the end, the value is sprintf() into a float anyway. I have tested on a 64-bit system. I don't have access to a 32-bit system right now, so somebody should check that to make sure my theory works in practice. --- src/etc/inc/util.inc | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) (limited to 'src') diff --git a/src/etc/inc/util.inc b/src/etc/inc/util.inc index 274b73c..84e525d 100644 --- a/src/etc/inc/util.inc +++ b/src/etc/inc/util.inc @@ -1753,7 +1753,9 @@ function resolve_retry($hostname, $retries = 5) { } function format_bytes($bytes) { - if ($bytes >= 1073741824) { + if ($bytes >= 1099511627776) { + return sprintf("%.2f TB", $bytes/1099511627776); + } else if ($bytes >= 1073741824) { return sprintf("%.2f GB", $bytes/1073741824); } else if ($bytes >= 1048576) { return sprintf("%.2f MB", $bytes/1048576); -- cgit v1.1