- fix swap detection

This commit is contained in:
jasper 2011-05-24 08:48:22 +00:00
parent 59c57a27dc
commit bf81eec5f8
2 changed files with 13 additions and 5 deletions

View File

@ -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

View File

@ -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;