Skip site navigation (1)Skip section navigation (2)
Date:      Mon, 26 Nov 2001 19:33:05 +0100
From:      Emiel Kollof <coolvibe@hackerheaven.org>
To:        freebsd-current@freebsd.org
Subject:   kvm_getswapinfo() not backwards compatible?
Message-ID:  <20011126193305.C546@laptop.hackerheaven.org>

next in thread | raw e-mail | index | archive | help
Hey gang,

I have the following piece of code:

extern void
getswapload()
{
 
	struct kvm_swap swap[1];
	int pgsize,
	swapused, n;

	kd = kvm_open("/dev/null", "/dev/null", "/dev/null", O_RDONLY, "kvm_open"); 
	n = kvm_getswapinfo(kd, swap, 1, 0);
	if (n < 0 || swap[0].ksw_total == 0) { 
		perror("kvm_getswapinfo");
		exit(1);
	}
	pgsize = getpagesize(); 
	swapused = swap[0].ksw_used * pgsize  / 1024;
	snprintf(result, sizeof(result), "%d", swapused);
        kvm_close(kd);
	return;
}	

As you all can see, this puts the amount of swap used in KB in the
global variable result. It's not unlike the top(1) utility does it.

But... it doesn't seem to work on STABLE, but it does fine on CURRENT.
My STABLE machine yields the following:

kvm_open: short read
getinfo: cannot read nswdev: 
kvm_open: short read
getinfo: cannot read dmmax: 
kvm_open: short read
getinfo: cannot read sw: 
kvm_open: short read
getinfo: cannot read sw: 
kvm_open: short read
getinfo: cannot read swapblist: 
kvm_getswapinfo: Undefined error: 0

I checked the top(1) source on a STABLE machine for reference. No luck
there, It does it the same way. What am I doing wrong? In what way are
the two calls different on CURRENT and STABLE?

Cheers,
Emiel
-- 
Concept, n.:
	Any "idea" for which an outside consultant billed you more than
$25,000.

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




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