components/net-snmp-57/patches/058.15372155.hr_storage.patch
author Gowtham Thommandra <Gowtham.Thommandra@Oracle.COM>
Fri, 11 Dec 2015 03:49:26 -0800
changeset 5867 445e2cf1c845
parent 4711 components/net-snmp/patches/058.15372155.hr_storage.patch@c2328acb8517
permissions -rw-r--r--
PSARC/2014/169 Net-snmp upgrade to version 5.7.2.1 15685782 SUNBT7005330 NET-SNMP upgrade to 5.7.2.1 15705167 SUNBT7030994 find memory leaks for snmp-notify after doing libfmnotif

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;