Applied another patch from Jeremy Lea to make it work with
1999-02-24 Martin Baulig <martin@home-of-linux.org> * swap.c: Applied another patch from Jeremy Lea to make it work with FreeBSD-current.
This commit is contained in:
committed by
Martin Baulig
parent
f33814d409
commit
8f4bb6c9c4
@@ -1,3 +1,8 @@
|
||||
1999-02-24 Martin Baulig <martin@home-of-linux.org>
|
||||
|
||||
* swap.c: Applied another patch from Jeremy Lea to
|
||||
make it work with FreeBSD-current.
|
||||
|
||||
1999-02-21 Martin Baulig <martin@home-of-linux.org>
|
||||
|
||||
* procmap.c, procmem.c: Applied patch from Jeremy Lea.
|
||||
|
||||
@@ -40,6 +40,8 @@ static const unsigned long _glibtop_sysdeps_swap =
|
||||
#include <sys/rlist.h>
|
||||
#include <sys/vmmeter.h>
|
||||
|
||||
#if __FreeBSD__ < 4
|
||||
|
||||
/* nlist structure for kernel access */
|
||||
static struct nlist nlst [] = {
|
||||
#define VM_SWAPLIST 0
|
||||
@@ -55,6 +57,8 @@ static struct nlist nlst [] = {
|
||||
{ 0 }
|
||||
};
|
||||
|
||||
#endif
|
||||
|
||||
#elif (defined __NetBSD__)
|
||||
|
||||
#include <vm/vm_swap.h>
|
||||
@@ -73,10 +77,18 @@ void
|
||||
glibtop_init_swap_p (glibtop *server)
|
||||
{
|
||||
#ifdef __FreeBSD__
|
||||
#if __FreeBSD__ < 4
|
||||
if (kvm_nlist (server->machine.kd, nlst) != 0) {
|
||||
glibtop_warn_io_r (server, "kvm_nlist (swap)");
|
||||
return;
|
||||
}
|
||||
#else
|
||||
struct kvm_swap dummy;
|
||||
|
||||
if (kvm_getswapinfo (server->machine.kd, &dummy, 1, 0) != 0) {
|
||||
glibtop_warn_io_r (server, "kvm_nlist (swap)");
|
||||
return;
|
||||
}
|
||||
#endif
|
||||
|
||||
if (kvm_nlist (server->machine.kd, nlst2) != 0) {
|
||||
@@ -98,6 +110,7 @@ void
|
||||
glibtop_get_swap_p (glibtop *server, glibtop_swap *buf)
|
||||
{
|
||||
#ifdef __FreeBSD__
|
||||
#if __FreeBSD__ < 4
|
||||
char *header;
|
||||
int hlen, nswdev, dmmax;
|
||||
int div, nfree, npfree;
|
||||
@@ -108,6 +121,10 @@ glibtop_get_swap_p (glibtop *server, glibtop_swap *buf)
|
||||
struct rlist *swapptr;
|
||||
size_t sw_size;
|
||||
u_long ptr;
|
||||
#else
|
||||
int nswdev;
|
||||
struct kvm_swap kvmsw[16];
|
||||
#endif
|
||||
#elif (defined __NetBSD__)
|
||||
struct swapent *swaplist;
|
||||
#endif
|
||||
@@ -158,6 +175,8 @@ glibtop_get_swap_p (glibtop *server, glibtop_swap *buf)
|
||||
|
||||
#ifdef __FreeBSD__
|
||||
|
||||
#if __FreeBSD__ < 4
|
||||
|
||||
/* Size of largest swap device. */
|
||||
|
||||
if (kvm_read (server->machine.kd, nlst[VM_NSWAP].n_value,
|
||||
@@ -295,6 +314,19 @@ glibtop_get_swap_p (glibtop *server, glibtop_swap *buf)
|
||||
|
||||
buf->total = inuse + avail;
|
||||
|
||||
#else
|
||||
|
||||
nswdev = kvm_getswapinfo(server->machine.kd, kvmsw, 16, 0);
|
||||
|
||||
buf->flags = _glibtop_sysdeps_swap;
|
||||
|
||||
buf->used = kvmsw[nswdev].ksw_used;
|
||||
buf->total = kvmsw[nswdev].ksw_total;
|
||||
|
||||
buf->free = buf->total - buf->used;
|
||||
|
||||
#endif
|
||||
|
||||
#elif (defined __NetBSD__)
|
||||
|
||||
nswap = swapctl (SWAP_NSWAP, NULL, 0);
|
||||
|
||||
Reference in New Issue
Block a user