xref: /freebsd/lib/libkvm/kvm_getswapinfo.3 (revision 6e8394b8baa7d5d9153ab90de6824bcd19b3b4e1)
1.\" Copyright (c) 1999, Matthew Dillon.  All rights reserved.
2.\"
3.\" Redistribution and use in source and binary forms, with or without
4.\" modification, are permitted provided under the terms of the BSD
5.\" Copyright as found in /usr/src/COPYRIGHT in the FreeBSD source tree.
6.\"
7.\"
8.Dd January 22, 1999
9.Dt KVM_SWAPINFO 3
10.Os
11.Sh NAME
12.Nm kvm_getswapinfo
13.Nd return swap summary statistics for the system
14.Sh SYNOPSIS
15.Fd #include <kvm.h>
16.Ft int
17.Fn kvm_getswapinfo "kvm_t *kd" "struct kvm_swap *" "int maxswap" "int flags"
18.Sh DESCRIPTION
19The
20.Fn kvm_getswapinfo
21function fills an array of kvm_swap structures with swap summary
22information for each swap device, for up to maxswap - 1 devices.
23The number of devices, up to maxswap - 1, is returned.  A grand
24total of all swap devices ( including any devices that go beyond
25maxswap - 1 ) is returned in one additional array entry.  This
26entry is not counted in the return value.  Thus, if you specify
27a maxswap value of 1, the function will typically return the
28value 0 and the single kvm_swap structure will be filled with
29the grand total over all swap devices.  The grand total is calculated
30from all available swap devices whether or not you made room
31for them all in the array.
32the grant total is returned.
33.Pp
34The flags argument is currently unused and must be passed as 0.
35.Pp
36If an error occurs, -1 is returned.
37.Pp
38Each swap partition and the grand total is summarized in the kvm_swap
39structure.  This structure contains the following fields:
40.Bl -inset -width indent
41.It char ksw_devname[];
42.It int ksw_total;
43.It int ksw_used;
44.It int ksw_flags;
45.El
46.Pp
47Values are in PAGE_SIZE'd chunks ( see getpagesize() ).  ksw_flags contains
48a copy of the swap device flags.
49.PP
50.Sh CACHING
51This function caches the nlist values for various kernel variables which
52it reuses in successive calls.  You may call the function with kd == NULL
53to clear the cache.
54.Sh DIAGNOSTICS
55If the load average was unobtainable, \-1 is returned; otherwise,
56the number of swap devices actually retrieved is returned.
57.Pp
58If the name of the swap device does not fit in the static char buffer
59in the structure, it is truncated.  The buffer is always zero terminated.
60.Sh SEE ALSO
61.Xr kvm 3
62