components/net-snmp-57/patches/058.15372155.hr_storage.patch
author Danek Duvall <danek.duvall@oracle.com>
Thu, 15 Sep 2016 14:25:24 -0700
changeset 6951 deaf66c90a34
parent 5867 445e2cf1c845
permissions -rw-r--r--
24676059 {GIT,HG}_HASH lines not replaced properly

This patch fixes an issue where snmpdf was not returning the 
correct total disk size and available disk size when the size 
of the filesystem is larger than 1TB.This bug is already fixed 
in the community and the fix is available from the net-snmp 
version 5.6 onwards.The fix here slightly differs from the community 
since the patch in the community is applied on net-snmp version 5.6 .
This patch is taken from the below link.

https://bugs.launchpad.net/ubuntu/+source/net-snmp/+bug/865268


--- net-snmp-5.4.1/agent/mibgroup/host/hr_storage.c	Thu May 21 23:47:45 2015
+++ net-snmp-5.4.1/agent/mibgroup/host/hr_storage.c	Thu May 21 23:55:59 2015
@@ -505,6 +505,7 @@
             int exact, size_t * var_len, WriteMethod ** write_method)
 {
     int             store_idx = 0;
+    int             factor = 0;
     static char     string[1024];
     struct HRFS_statfs stat_buf;
     void                *ptr;
@@ -558,6 +558,12 @@
 	    mem = (netsnmp_memory_info*)ptr;
         }
 
+/* Scaling factor for large filesystems */
+    if (store_idx > NETSNMP_MEM_TYPE_MAX) {
+        unsigned long long tmp = stat_buf.f_blocks;
+        while (tmp > 0x7fffffff)
+            tmp >>= 1, factor++;
+    }
 
 
     switch (vp->magic) {
@@ -593,9 +599,9 @@
     case HRSTORE_UNITS:
         if (store_idx > NETSNMP_MEM_TYPE_MAX)
 #if HRFS_HAS_FRSIZE
-            long_return = stat_buf.f_frsize;
+            long_return = stat_buf.f_frsize << factor;
 #else
-            long_return = stat_buf.f_bsize;
+            long_return = stat_buf.f_bsize << factor;
 #endif
         else {
             if ( !mem || mem->units == -1 )
@@ -605,7 +611,7 @@
         return (u_char *) & long_return;
     case HRSTORE_SIZE:
         if (store_idx > NETSNMP_MEM_TYPE_MAX)
-            long_return = stat_buf.f_blocks;
+            long_return = stat_buf.f_blocks >> factor;
         else {
             if ( !mem || mem->size == -1 )
                 goto try_next;
@@ -614,7 +620,7 @@
         return (u_char *) & long_return;
     case HRSTORE_USED:
         if (store_idx > NETSNMP_MEM_TYPE_MAX)
-            long_return = (stat_buf.f_blocks - stat_buf.f_bfree);
+            long_return = (stat_buf.f_blocks - stat_buf.f_bfree) >> factor;
         else {
             if ( !mem || mem->size == -1 || mem->free == -1 )
                 goto try_next;