[Midnightbsd-cvs] src [9060] trunk/usr.sbin/bsnmpd/modules/snmp_hostres/hostres_storage_tbl.c: hrStorageSize and hrStorageUsed are 32bit ints.this is a problem for large sizes.
laffer1 at midnightbsd.org
laffer1 at midnightbsd.org
Sat Oct 1 06:09:53 EDT 2016
Revision: 9060
http://svnweb.midnightbsd.org/src/?rev=9060
Author: laffer1
Date: 2016-10-01 06:09:53 -0400 (Sat, 01 Oct 2016)
Log Message:
-----------
hrStorageSize and hrStorageUsed are 32bit ints.this is a problem for large sizes.
Modified Paths:
--------------
trunk/usr.sbin/bsnmpd/modules/snmp_hostres/hostres_storage_tbl.c
Modified: trunk/usr.sbin/bsnmpd/modules/snmp_hostres/hostres_storage_tbl.c
===================================================================
--- trunk/usr.sbin/bsnmpd/modules/snmp_hostres/hostres_storage_tbl.c 2016-10-01 10:07:23 UTC (rev 9059)
+++ trunk/usr.sbin/bsnmpd/modules/snmp_hostres/hostres_storage_tbl.c 2016-10-01 10:09:53 UTC (rev 9060)
@@ -442,10 +442,9 @@
storage_OS_get_fs(void)
{
struct storage_entry *entry;
- uint64_t used_blocks_count = 0;
+ uint64_t size, used;
+ int i, mounted_fs_count, units;
char fs_string[SE_DESC_MLEN];
- int mounted_fs_count;
- int i = 0;
if ((mounted_fs_count = getfsstat(NULL, 0, MNT_NOWAIT)) < 0) {
syslog(LOG_ERR, "hrStorageTable: getfsstat() failed: %m");
@@ -488,23 +487,18 @@
entry->flags |= HR_STORAGE_FOUND;
entry->type = fs_get_type(&fs_buf[i]); /*XXX - This is wrong*/
- if (fs_buf[i].f_bsize > INT_MAX)
- entry->allocationUnits = INT_MAX;
- else
- entry->allocationUnits = fs_buf[i].f_bsize;
+ units = fs_buf[i].f_bsize;
+ size = fs_buf[i].f_blocks;
+ used = fs_buf[i].f_blocks - fs_buf[i].f_bfree;
+ while (size > INT_MAX) {
+ units <<= 1;
+ size >>= 1;
+ used >>= 1;
+ }
+ entry->allocationUnits = units;
+ entry->size = size;
+ entry->used = used;
- if (fs_buf[i].f_blocks > INT_MAX)
- entry->size = INT_MAX;
- else
- entry->size = fs_buf[i].f_blocks;
-
- used_blocks_count = fs_buf[i].f_blocks - fs_buf[i].f_bfree;
-
- if (used_blocks_count > INT_MAX)
- entry->used = INT_MAX;
- else
- entry->used = used_blocks_count;
-
entry->allocationFailures = 0;
/* take care of hrFSTable */
More information about the Midnightbsd-cvs
mailing list