+#include <sys/ioctl.h>
+#include <sys/map.h>
+#include <sys/stat.h>
+
+#include <kvm.h>
+#include <nlist.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include <unistd.h>
+
+#include "systat.h"
+#include "extern.h"
+
+extern char *devname __P((int, int));
+extern char *getbsize __P((int *headerlenp, long *blocksizep));
+void showspace __P((char *header, int hlen, long blocksize));
+
+kvm_t *kd;
+
+struct nlist syms[] = {
+ { "_swapmap" }, /* list of free swap areas */
+#define VM_SWAPMAP 0
+ { "_nswapmap" },/* size of the swap map */
+#define VM_NSWAPMAP 1
+ { "_swdevt" }, /* list of swap devices and sizes */
+#define VM_SWDEVT 2
+ { "_nswap" }, /* size of largest swap device */
+#define VM_NSWAP 3
+ { "_nswdev" }, /* number of swap devices */
+#define VM_NSWDEV 4
+ { "_dmmax" }, /* maximum size of a swap block */
+#define VM_DMMAX 5
+ 0
+};
+
+static int nswap, nswdev, dmmax, nswapmap;
+static struct swdevt *sw;
+static long *perdev, blocksize;
+static struct map *swapmap, *kswapmap;
+static struct mapent *mp;
+static int nfree, hlen;
+
+#define SVAR(var) __STRING(var) /* to force expansion */
+#define KGET(idx, var) \
+ KGET1(idx, &var, sizeof(var), SVAR(var))
+#define KGET1(idx, p, s, msg) \
+ KGET2(syms[idx].n_value, p, s, msg)
+#define KGET2(addr, p, s, msg) \
+ if (kvm_read(kd, addr, p, s) != s) { \
+ error("cannot read %s: %s", msg, kvm_geterr(kd)); \
+ return (0); \
+ }