From owner-svn-src-all@FreeBSD.ORG Mon Apr 8 19:50:16 2013 Return-Path: Delivered-To: svn-src-all@freebsd.org Received: from mx1.freebsd.org (mx1.FreeBSD.org [8.8.178.115]) by hub.freebsd.org (Postfix) with ESMTP id 827C6133; Mon, 8 Apr 2013 19:50:16 +0000 (UTC) (envelope-from trociny@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:1900:2254:2068::e6a:0]) by mx1.freebsd.org (Postfix) with ESMTP id 5B559763; Mon, 8 Apr 2013 19:50:16 +0000 (UTC) Received: from svn.freebsd.org ([127.0.1.70]) by svn.freebsd.org (8.14.6/8.14.6) with ESMTP id r38JoGl4098208; Mon, 8 Apr 2013 19:50:16 GMT (envelope-from trociny@svn.freebsd.org) Received: (from trociny@localhost) by svn.freebsd.org (8.14.6/8.14.5/Submit) id r38JoGGv098207; Mon, 8 Apr 2013 19:50:16 GMT (envelope-from trociny@svn.freebsd.org) Message-Id: <201304081950.r38JoGGv098207@svn.freebsd.org> From: Mikolaj Golub Date: Mon, 8 Apr 2013 19:50:16 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-8@freebsd.org Subject: svn commit: r249272 - stable/8/usr.sbin/bsnmpd/modules/snmp_hostres X-SVN-Group: stable-8 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 08 Apr 2013 19:50:16 -0000 Author: trociny Date: Mon Apr 8 19:50:15 2013 New Revision: 249272 URL: http://svnweb.freebsd.org/changeset/base/249272 Log: MFC r248707: hrStorageSize and hrStorageUsed are 32 bit integers, reporting a fs size and usage in hrStorageAllocationUnits. If the file system has more than 2^31 allocations it can not be shown correctly and the meters are useless. In such cases follow net-snmp behaviour and increase hrStorageAllocationUnits so the values fit under INT_MAX. PR: bin/177183 Submitted by: Eugene Grosbein egrosbein rdtc.ru Modified: stable/8/usr.sbin/bsnmpd/modules/snmp_hostres/hostres_storage_tbl.c Directory Properties: stable/8/usr.sbin/bsnmpd/ (props changed) Modified: stable/8/usr.sbin/bsnmpd/modules/snmp_hostres/hostres_storage_tbl.c ============================================================================== --- stable/8/usr.sbin/bsnmpd/modules/snmp_hostres/hostres_storage_tbl.c Mon Apr 8 19:48:40 2013 (r249271) +++ stable/8/usr.sbin/bsnmpd/modules/snmp_hostres/hostres_storage_tbl.c Mon Apr 8 19:50:15 2013 (r249272) @@ -442,10 +442,9 @@ static void 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,22 +487,17 @@ storage_OS_get_fs(void) 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; - - 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; + 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; entry->allocationFailures = 0;