2004-07-31 18:49:53 +00:00
|
|
|
.\" Copyright (C) 1999 Matthew Dillon. All rights reserved.
|
1999-01-22 10:36:04 +00:00
|
|
|
.\"
|
|
|
|
.\" Redistribution and use in source and binary forms, with or without
|
2004-07-31 18:49:53 +00:00
|
|
|
.\" modification, are permitted provided that the following conditions
|
|
|
|
.\" are met:
|
|
|
|
.\" 1. Redistributions of source code must retain the above copyright
|
|
|
|
.\" notice, this list of conditions and the following disclaimer.
|
|
|
|
.\" 2. Redistributions in binary form must reproduce the above copyright
|
|
|
|
.\" notice, this list of conditions and the following disclaimer in the
|
|
|
|
.\" documentation and/or other materials provided with the distribution.
|
|
|
|
.\"
|
|
|
|
.\" THIS SOFTWARE IS PROVIDED BY AUTHOR AND CONTRIBUTORS ``AS IS'' AND
|
|
|
|
.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
|
|
|
.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
|
|
|
.\" ARE DISCLAIMED. IN NO EVENT SHALL AUTHOR OR CONTRIBUTORS BE LIABLE
|
|
|
|
.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
|
|
|
.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
|
|
|
|
.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
|
|
|
|
.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
|
|
|
.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
|
|
|
|
.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
|
|
|
.\" SUCH DAMAGE.
|
1999-01-22 10:36:04 +00:00
|
|
|
.\"
|
1999-08-28 00:22:10 +00:00
|
|
|
.\" $FreeBSD$
|
1999-01-22 10:36:04 +00:00
|
|
|
.\"
|
2017-01-02 15:12:11 +00:00
|
|
|
.Dd January 2, 2017
|
1999-01-22 10:36:04 +00:00
|
|
|
.Dt KVM_SWAPINFO 3
|
|
|
|
.Os
|
|
|
|
.Sh NAME
|
1999-01-22 11:03:55 +00:00
|
|
|
.Nm kvm_getswapinfo
|
1999-01-22 10:36:04 +00:00
|
|
|
.Nd return swap summary statistics for the system
|
2000-04-22 16:10:12 +00:00
|
|
|
.Sh LIBRARY
|
|
|
|
.Lb libkvm
|
1999-01-22 10:36:04 +00:00
|
|
|
.Sh SYNOPSIS
|
2001-10-01 16:09:29 +00:00
|
|
|
.In kvm.h
|
1999-01-22 10:36:04 +00:00
|
|
|
.Ft int
|
1999-01-22 11:03:55 +00:00
|
|
|
.Fn kvm_getswapinfo "kvm_t *kd" "struct kvm_swap *" "int maxswap" "int flags"
|
1999-01-22 10:36:04 +00:00
|
|
|
.Sh DESCRIPTION
|
|
|
|
The
|
1999-01-22 11:03:55 +00:00
|
|
|
.Fn kvm_getswapinfo
|
2001-02-01 16:38:02 +00:00
|
|
|
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
|
2004-07-02 23:52:20 +00:00
|
|
|
\- 1, is returned.
|
|
|
|
A grand
|
2001-02-01 16:38:02 +00:00
|
|
|
total of all swap devices (including any devices that go beyond
|
|
|
|
.Fa maxswap
|
2004-07-02 23:52:20 +00:00
|
|
|
\- 1) is returned in one additional array entry.
|
|
|
|
This
|
2001-02-01 16:38:02 +00:00
|
|
|
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
|
2004-07-02 23:52:20 +00:00
|
|
|
the grand total over all swap devices.
|
|
|
|
The grand total is calculated
|
2001-07-15 07:53:42 +00:00
|
|
|
from all available swap devices whether or not you made room
|
1999-01-22 10:36:04 +00:00
|
|
|
for them all in the array.
|
2001-08-10 15:03:10 +00:00
|
|
|
The grand total is returned.
|
1999-01-22 10:36:04 +00:00
|
|
|
.Pp
|
|
|
|
The flags argument is currently unused and must be passed as 0.
|
|
|
|
.Pp
|
|
|
|
If an error occurs, -1 is returned.
|
|
|
|
.Pp
|
2001-02-01 16:38:02 +00:00
|
|
|
Each swap partition and the grand total is summarized in the
|
|
|
|
.Vt kvm_swap
|
2004-07-02 23:52:20 +00:00
|
|
|
structure.
|
|
|
|
This structure contains the following fields:
|
2001-02-01 16:38:02 +00:00
|
|
|
.Pp
|
|
|
|
.Bl -item -offset indent -compact
|
|
|
|
.It
|
|
|
|
.Va char ksw_devname[] ;
|
|
|
|
.It
|
2017-01-02 15:12:11 +00:00
|
|
|
.Va u_int ksw_total ;
|
2001-02-01 16:38:02 +00:00
|
|
|
.It
|
2017-01-02 15:12:11 +00:00
|
|
|
.Va u_int ksw_used ;
|
2001-02-01 16:38:02 +00:00
|
|
|
.It
|
|
|
|
.Va int ksw_flags ;
|
1999-01-22 10:36:04 +00:00
|
|
|
.El
|
|
|
|
.Pp
|
2001-02-01 16:38:02 +00:00
|
|
|
Values are in
|
|
|
|
.Dv PAGE_SIZE Ns 'd
|
|
|
|
chunks (see
|
|
|
|
.Xr getpagesize 3 ) .
|
|
|
|
.Va ksw_flags
|
|
|
|
contains
|
1999-01-22 10:36:04 +00:00
|
|
|
a copy of the swap device flags.
|
|
|
|
.Sh CACHING
|
|
|
|
This function caches the nlist values for various kernel variables which
|
2001-02-01 16:38:02 +00:00
|
|
|
it reuses in successive calls.
|
|
|
|
You may call the function with
|
|
|
|
.Fa kd
|
|
|
|
==
|
2001-07-15 07:53:42 +00:00
|
|
|
.Dv NULL
|
1999-01-22 10:36:04 +00:00
|
|
|
to clear the cache.
|
|
|
|
.Sh DIAGNOSTICS
|
2020-06-25 20:04:35 +00:00
|
|
|
If the swap summary information was unobtainable, \-1 is returned;
|
|
|
|
otherwise, the number of swap devices actually retrieved is returned.
|
1999-01-22 10:36:04 +00:00
|
|
|
.Pp
|
|
|
|
If the name of the swap device does not fit in the static char buffer
|
2004-07-02 23:52:20 +00:00
|
|
|
in the structure, it is truncated.
|
|
|
|
The buffer is always zero terminated.
|
1999-01-22 10:36:04 +00:00
|
|
|
.Sh SEE ALSO
|
|
|
|
.Xr kvm 3
|