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