summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorPhil Davis <phil.davis@inf.org>2016-02-07 21:44:23 +0545
committerPhil Davis <phil.davis@inf.org>2016-02-07 21:44:23 +0545
commit4eac105ff088fde0eabfd792be8b1ec5e2901873 (patch)
tree68fcf4328590dbc0616f998061dab34dcb9b97d1 /src
parent1f97f2e6f6d7ea7c5212dc0a2a84df93a4124067 (diff)
downloadpfsense-4eac105ff088fde0eabfd792be8b1ec5e2901873.zip
pfsense-4eac105ff088fde0eabfd792be8b1ec5e2901873.tar.gz
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.
Diffstat (limited to 'src')
-rw-r--r--src/etc/inc/util.inc4
1 files changed, 3 insertions, 1 deletions
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);
OpenPOWER on IntegriCloud