From bf81eec5f887fd4e0ef8d2b1444feb6172c66b83 Mon Sep 17 00:00:00 2001 From: jasper Date: Tue, 24 May 2011 08:48:22 +0000 Subject: [PATCH] - fix swap detection --- devel/libgtop2/Makefile | 4 ++-- devel/libgtop2/files/swap.c | 14 +++++++++++--- 2 files changed, 13 insertions(+), 5 deletions(-) diff --git a/devel/libgtop2/Makefile b/devel/libgtop2/Makefile index a77fd606cb7..d2394d12cc1 100644 --- a/devel/libgtop2/Makefile +++ b/devel/libgtop2/Makefile @@ -1,4 +1,4 @@ -# $OpenBSD: Makefile,v 1.61 2011/05/23 21:26:41 jasper Exp $ +# $OpenBSD: Makefile,v 1.62 2011/05/24 08:48:22 jasper Exp $ COMMENT= portable library for obtaining system information @@ -6,7 +6,7 @@ GNOME_VERSION= 2.28.3 GNOME_PROJECT= libgtop PKGNAME= libgtop2-${VERSION} -REVISION= 4 +REVISION= 5 SHARED_LIBS= gtop-2.0 9.0 # .9.0 diff --git a/devel/libgtop2/files/swap.c b/devel/libgtop2/files/swap.c index 8ed470525d4..e4bed9d33f9 100644 --- a/devel/libgtop2/files/swap.c +++ b/devel/libgtop2/files/swap.c @@ -1,4 +1,4 @@ -/* $OpenBSD: swap.c,v 1.4 2011/05/23 21:26:41 jasper Exp $ */ +/* $OpenBSD: swap.c,v 1.5 2011/05/24 08:48:22 jasper Exp $ */ /* Copyright (C) 1998-99 Martin Baulig This file is part of LibGTop 1.0. @@ -62,6 +62,9 @@ glibtop_get_swap_p (glibtop *server, glibtop_swap *buf) int nswap, i; int avail = 0, inuse = 0; + int blocksize = 512; /* Default blocksize, use getbize() ? */ + int blockdiv = blocksize / DEV_BSIZE; + struct uvmexp uvmexp; size_t length_uvmexp; static int swappgsin = -1; @@ -105,13 +108,18 @@ glibtop_get_swap_p (glibtop *server, glibtop_swap *buf) return; } + /* Total things up, returns in 512 bytes blocks! */ for (i = 0; i < nswap; i++) { if (swaplist[i].se_flags & SWF_ENABLE) { - avail += swaplist[i].se_nblks; - inuse += swaplist[i].se_inuse; + avail += (swaplist[i].se_nblks / blockdiv); + inuse += (swaplist[i].se_inuse / blockdiv); } } + /* Convert back to bytes, the libgtop2 is not clear about unites... */ + avail *= 512; + inuse *= 512; + g_free (swaplist); buf->flags = _glibtop_sysdeps_swap;