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 [EMAIL PROTECTED]
with "unsubscribe freebsd-current" in the body of the message

Reply via email to