Skip site navigation (1)Skip section navigation (2)
Date:      Mon, 26 Aug 2002 20:33:17 +1000 (EST)
From:      Edwin Groothuis <edwin@mavetju.org>
To:        FreeBSD-gnats-submit@FreeBSD.org
Cc:        maintainer of devel/libgtop2 <gnome@FreeBSD.org>
Subject:   ports/42028: [patch] devel/libgtop2 displays wrong swap-info
Message-ID:  <20020826103317.4547C6A7124@k7.mavetju>

next in thread | raw e-mail | index | archive | help

>Number:         42028
>Category:       ports
>Synopsis:       [patch] devel/libgtop2 displays wrong swap-info
>Confidential:   no
>Severity:       non-critical
>Priority:       low
>Responsible:    freebsd-ports
>State:          open
>Quarter:        
>Keywords:       
>Date-Required:
>Class:          change-request
>Submitter-Id:   current-users
>Arrival-Date:   Mon Aug 26 03:40:04 PDT 2002
>Closed-Date:
>Last-Modified:
>Originator:     Edwin Groothuis
>Release:        FreeBSD 4.5-RELEASE i386
>Organization:
-
>Environment:
System: FreeBSD k7.mavetju 4.5-RELEASE FreeBSD 4.5-RELEASE #3: Mon Mar 11 13:32:05 EST 2002 edwin@k7.mavetju.org:/usr/src/sys/compile/k7 i386



>Description:

libgtop2 provides an API between GTK+ applications and the kernel-structures.
It returns swap-information, but forgets to multiple it by getpagesize().

>How-To-Repeat:

Install sysutils/gnomesystemsmonitor and check the swap-size.
Or run this:

#include <stdio.h>
#include <glibtop.h>
#include <glibtop/swap.h>

void swap(void) {
        glibtop_swap swap;

	glibtop_get_swap(&swap);
	printf("SWAP\n");
	printf("total: %lld\n",swap.total);
	printf("used : %lld\n",swap.used );
	printf("free : %lld\n",swap.free );
}

int main(void) {
        glibtop_init();
	swap();
}

gcc -Wall -I/usr/local/include/libgtop-2.0 -L/usr/local/lib -o a a.c -lgtop-2.0 -lgtop_common-2.0 -lgtop_suid_common-2.0 -lgtop_sysdeps-2.0 -lgtop_names-2.0 -lgtop_sysdeps_suid-2.0 && ./a


>Fix:

Add this file as files/patch-sysdeps::freebsd::swap.c

--- sysdeps/freebsd/swap.c-old	Mon Aug 26 20:18:07 2002
+++ sysdeps/freebsd/swap.c	Mon Aug 26 20:19:18 2002
@@ -369,8 +369,8 @@
 
 	buf->flags = _glibtop_sysdeps_swap;
 
-	buf->used = kvmsw[nswdev].ksw_used;
-	buf->total = kvmsw[nswdev].ksw_total;
+	buf->used = kvmsw[nswdev].ksw_used * getpagesize();
+	buf->total = kvmsw[nswdev].ksw_total * getpagesize();
 
 	buf->free = buf->total - buf->used;
 
And bump the revision of the port:

--- Makefile.old	Mon Aug 26 20:24:24 2002
+++ Makefile	Mon Aug 26 20:24:33 2002
@@ -7,6 +7,7 @@
 
 PORTNAME=	libgtop2
 PORTVERSION=	2.0.0
+PORTREVISION=	1
 CATEGORIES=	devel gnome
 MASTER_SITES=	${MASTER_SITE_GNOME}
 MASTER_SITE_SUBDIR=	2.0.0/releases/gnome-2.0-desktop-final
>Release-Note:
>Audit-Trail:
>Unformatted:

To Unsubscribe: send mail to majordomo@FreeBSD.org
with "unsubscribe freebsd-ports" in the body of the message




Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?20020826103317.4547C6A7124>