Redistribution and use in source and binary forms, with or without
modification, are permitted provided under the terms of the BSD
Copyright as found in /usr/src/COPYRIGHT in the FreeBSD source tree.
$FreeBSD: head/lib/libkvm/kvm_getswapinfo.3 79454 2001-07-09 09:54:33Z dd $
.Dd January 22, 1999 .Dt KVM_SWAPINFO 3 .Os .Sh NAME .Nm kvm_getswapinfo .Nd return swap summary statistics for the system .Sh LIBRARY .Lb libkvm .Sh SYNOPSIS .Fd #include <kvm.h> .Ft int .Fn kvm_getswapinfo "kvm_t *kd" "struct kvm_swap *" "int maxswap" "int flags" .Sh DESCRIPTION The .Fn kvm_getswapinfo function fills an array of .Vt kvm_swap structures with swap summary information for each swap device, for up to .Fa maxswap - 1 devices. The number of devices, up to .Fa maxswap - 1, is returned. A grand total of all swap devices (including any devices that go beyond .Fa maxswap - 1) is returned in one additional array entry. This entry is not counted in the return value. Thus, if you specify a .Fa maxswap value of 1, the function will typically return the value 0 and the single .Vt kvm_swap structure will be filled with the grand total over all swap devices. The grand total is calculated from all available swap devices whether or not you made room for them all in the array. the grant total is returned.
p The flags argument is currently unused and must be passed as 0.
p If an error occurs, -1 is returned.
p Each swap partition and the grand total is summarized in the .Vt kvm_swap structure. This structure contains the following fields:
p l -item -offset indent -compact t .Va char ksw_devname[] ; t .Va int ksw_total ; t .Va int ksw_used ; t .Va int ksw_flags ; .El
p Values are in .Dv PAGE_SIZE Ns 'd chunks (see .Xr getpagesize 3 ) . .Va ksw_flags contains a copy of the swap device flags. .Sh CACHING This function caches the nlist values for various kernel variables which it reuses in successive calls. You may call the function with .Fa kd == .Dv NULL to clear the cache. .Sh DIAGNOSTICS If the load average was unobtainable, -1 is returned; otherwise, the number of swap devices actually retrieved is returned.
p If the name of the swap device does not fit in the static char buffer in the structure, it is truncated. The buffer is always zero terminated. .Sh SEE ALSO .Xr kvm 3