Index: tools/module/ptest.c
===================================================================
--- tools/module/ptest.c	(revision 210668)
+++ tools/module/ptest.c	(working copy)
@@ -25,9 +25,6 @@
  *
  */
 
-#include <sys/cdefs.h>
-__FBSDID("$FreeBSD$");
-
 #include <sys/param.h>
 #include <sys/systm.h>
 #include <sys/kernel.h>
Index: tools/fstool.c
===================================================================
--- tools/fstool.c	(revision 210668)
+++ tools/fstool.c	(working copy)
@@ -25,9 +25,6 @@
  *
  */
 
-#include <sys/cdefs.h>
-__FBSDID("$FreeBSD$");
-
 #include <sys/types.h>
 #include <sys/sysctl.h>
 #include <unistd.h>
Index: lib/main.c
===================================================================
--- lib/main.c	(revision 210668)
+++ lib/main.c	(working copy)
@@ -27,9 +27,6 @@
 
 /* Main program for all test programs */
 
-#include <sys/cdefs.h>
-__FBSDID("$FreeBSD$");
-
 #include <stdio.h>
 #include <signal.h>
 #include <unistd.h>
Index: lib/random_int.c
===================================================================
--- lib/random_int.c	(revision 210668)
+++ lib/random_int.c	(working copy)
@@ -25,9 +25,6 @@
  *
  */
 
-#include <sys/cdefs.h>
-__FBSDID("$FreeBSD$");
-
 #include <stdlib.h>
 
 int
Index: lib/resources.c
===================================================================
--- lib/resources.c	(revision 210668)
+++ lib/resources.c	(working copy)
@@ -27,9 +27,6 @@
 
 /* Get various resource limits for the tests */
 
-#include <sys/cdefs.h>
-__FBSDID("$FreeBSD$");
-
 #include <sys/types.h>
 #include <sys/sysctl.h>
 #include <unistd.h>
@@ -46,6 +43,7 @@
 #include <err.h>
 #include <stdarg.h>
 #include <libutil.h>
+#include <limits.h>
 
 #include "stress.h"
 
@@ -103,29 +101,23 @@
 int64_t
 swap(void)
 {
-	struct xswdev xsw;
-	size_t mibsize, size;
-	int mib[16], n;
-	int64_t sz;
+	kvm_t *kd;
+	struct kvm_swap kswap[16];
+	char *nlistf = NULL;
+	char *memf = NULL;
+	char buf[_POSIX2_LINE_MAX];
+	int i, n;
+	int64_t sz = 0;
 
-	mibsize = sizeof mib / sizeof mib[0];
-	sz = 0;
+	if ((kd = kvm_openfiles(nlistf, memf, NULL, O_RDONLY, buf)) == 0)
+		errx(1, "kvm_openfiles: %s", buf);
+	n = kvm_getswapinfo(kd, kswap, sizeof(kswap) / sizeof(kswap[0]),
+	    SWIF_DUMP_TREE);
+	kvm_close(kd);
 
-	if (sysctlnametomib("vm.swap_info", mib, &mibsize) == -1)
-		err(1, "sysctlnametomib()");
+	for (i = 0; i < n; i++)
+		sz += kswap[i].ksw_total - kswap[i].ksw_used;
 
-	for (n = 0; ; ++n) {
-		mib[mibsize] = n;
-		size = sizeof xsw;
-		if (sysctl(mib, mibsize + 1, &xsw, &size, NULL, 0) == -1)
-			break;
-		if (xsw.xsw_version != XSWDEV_VERSION)
-			errx(1, "xswdev version mismatch");
-		sz = sz + xsw.xsw_nblks - xsw.xsw_used;
-	}
-	if (errno != ENOENT)
-		err(1, "sysctl()");
-
 	if (op->verbose > 2)
 		printf("Total free swap space %jd Mb\n",
 			sz * getpagesize() / 1024 / 1024);
Index: lib/options.c
===================================================================
--- lib/options.c	(revision 210668)
+++ lib/options.c	(working copy)
@@ -25,9 +25,6 @@
  *
  */
 
-#include <sys/cdefs.h>
-__FBSDID("$FreeBSD$");
-
 #include <stdio.h>
 #include <stdlib.h>
 #include <unistd.h>
Index: misc/sem.sh
===================================================================
--- misc/sem.sh	(revision 210668)
+++ misc/sem.sh	(working copy)
@@ -53,9 +53,6 @@
 exit
 EOF
 
-#include <sys/cdefs.h>
-__FBSDID("$FreeBSD$");
-
 #include <stdio.h>
 #include <stdlib.h>
 #include <unistd.h>
Index: misc/syscall2.sh
===================================================================
--- misc/syscall2.sh	(revision 210668)
+++ misc/syscall2.sh	(working copy)
@@ -69,9 +69,6 @@
 
 /* Call random system calls with random arguments */
 
-#include <sys/cdefs.h>
-__FBSDID("$FreeBSD$");
-
 #include <stdio.h>
 #include <stdlib.h>
 #include <unistd.h>
Index: misc/namecache.sh
===================================================================
--- misc/namecache.sh	(revision 210668)
+++ misc/namecache.sh	(working copy)
@@ -94,9 +94,6 @@
 EOF
 /* Test scenario for possible name cache problem */
 
-#include <sys/cdefs.h>
-__FBSDID("$FreeBSD$");
-
 #include <sys/types.h>
 #include <dirent.h>
 #include <err.h>
Index: testcases/thr2/thr2.c
===================================================================
--- testcases/thr2/thr2.c	(revision 210668)
+++ testcases/thr2/thr2.c	(working copy)
@@ -25,9 +25,6 @@
  *
  */
 
-#include <sys/cdefs.h>
-__FBSDID("$FreeBSD$");
-
 #include <pthread.h>
 #include <stdio.h>
 #include <signal.h>
Index: testcases/lockf2/lockf2.c
===================================================================
--- testcases/lockf2/lockf2.c	(revision 210668)
+++ testcases/lockf2/lockf2.c	(working copy)
@@ -33,9 +33,6 @@
 	 2nd 0xc14710e8 system map (system map) @ vm/vm_kern.c:296
  */
 
-#include <sys/cdefs.h>
-__FBSDID("$FreeBSD$");
-
 #include <stdio.h>
 #include <stdlib.h>
 #include <unistd.h>
Index: testcases/sysctl/sysctl.c
===================================================================
--- testcases/sysctl/sysctl.c	(revision 210668)
+++ testcases/sysctl/sysctl.c	(working copy)
@@ -27,9 +27,6 @@
 
 /* Call sysctl(8) and fstat(1) a few times */
 
-#include <sys/cdefs.h>
-__FBSDID("$FreeBSD$");
-
 #include <stdio.h>
 #include <stdlib.h>
 #include <unistd.h>
Index: testcases/badcode/badcode.c
===================================================================
--- testcases/badcode/badcode.c	(revision 210668)
+++ testcases/badcode/badcode.c	(working copy)
@@ -23,9 +23,6 @@
 
 */
 
-#include <sys/cdefs.h>
-__FBSDID("$FreeBSD$");
-
 #include <sys/param.h>
 #include <sys/types.h>
 #include <sys/stat.h>
Index: testcases/Makefile.inc
===================================================================
--- testcases/Makefile.inc	(revision 210668)
+++ testcases/Makefile.inc	(working copy)
@@ -2,7 +2,7 @@
 
 NO_MAN=
 NO_OBJ=	noobj
-LDADD+= -L../../lib -lstress -lutil
+LDADD+= -L../../lib -lstress -lutil -lkvm
 DPADD+= ../../lib/libstress.a
 CFLAGS =-g -Wall -I../../include -I../include
 NOMAN=	sorry
Index: testcases/tcp/tcp.c
===================================================================
--- testcases/tcp/tcp.c	(revision 210668)
+++ testcases/tcp/tcp.c	(working copy)
@@ -25,9 +25,6 @@
  *
  */
 
-#include <sys/cdefs.h>
-__FBSDID("$FreeBSD$");
-
 #include <sys/param.h>
 #include <sys/socket.h>
 #include <netinet/in.h>
Index: testcases/symlink/symlink.c
===================================================================
--- testcases/symlink/symlink.c	(revision 210668)
+++ testcases/symlink/symlink.c	(working copy)
@@ -25,9 +25,6 @@
  *
  */
 
-#include <sys/cdefs.h>
-__FBSDID("$FreeBSD$");
-
 #include <unistd.h>
 #include <stdio.h>
 #include <stdlib.h>
Index: testcases/openat/openat.c
===================================================================
--- testcases/openat/openat.c	(revision 210668)
+++ testcases/openat/openat.c	(working copy)
@@ -25,9 +25,6 @@
  *
  */
 
-#include <sys/cdefs.h>
-__FBSDID("$FreeBSD$");
-
 #include <unistd.h>
 #include <stdio.h>
 #include <stdlib.h>
Index: testcases/openat/doat.c
===================================================================
--- testcases/openat/doat.c	(revision 210668)
+++ testcases/openat/doat.c	(working copy)
@@ -25,9 +25,6 @@
  *
  */
 
-#include <sys/cdefs.h>
-__FBSDID("$FreeBSD$");
-
 #include <errno.h>
 #include <fcntl.h>
 #include <stdbool.h>
Index: testcases/shm/shm.c
===================================================================
--- testcases/shm/shm.c	(revision 210668)
+++ testcases/shm/shm.c	(working copy)
@@ -27,9 +27,6 @@
 
 /* Test shared memory */
 
-#include <sys/cdefs.h>
-__FBSDID("$FreeBSD$");
-
 #include <stdio.h>
 #include <stdlib.h>
 #include <unistd.h>
Index: testcases/udp/udp.c
===================================================================
--- testcases/udp/udp.c	(revision 210668)
+++ testcases/udp/udp.c	(working copy)
@@ -25,9 +25,6 @@
  *
  */
 
-#include <sys/cdefs.h>
-__FBSDID("$FreeBSD$");
-
 #include <sys/types.h>
 #include <sys/socket.h>
 #include <netinet/in.h>
Index: testcases/socket/socket.c
===================================================================
--- testcases/socket/socket.c	(revision 210668)
+++ testcases/socket/socket.c	(working copy)
@@ -25,9 +25,6 @@
  *
  */
 
-#include <sys/cdefs.h>
-__FBSDID("$FreeBSD$");
-
 #include <sys/param.h>
 #include <sys/socket.h>
 #include <netinet/in.h>
Index: testcases/rw/rw.c
===================================================================
--- testcases/rw/rw.c	(revision 210668)
+++ testcases/rw/rw.c	(working copy)
@@ -27,9 +27,6 @@
 
 /* Write and check read a file */
 
-#include <sys/cdefs.h>
-__FBSDID("$FreeBSD$");
-
 #include <stdio.h>
 #include <stdlib.h>
 #include <unistd.h>
Index: testcases/mmap/mmap.c
===================================================================
--- testcases/mmap/mmap.c	(revision 210668)
+++ testcases/mmap/mmap.c	(working copy)
@@ -25,9 +25,6 @@
  *
  */
 
-#include <sys/cdefs.h>
-__FBSDID("$FreeBSD$");
-
 #include <unistd.h>
 #include <stdio.h>
 #include <stdlib.h>
Index: testcases/fts/fts.c
===================================================================
--- testcases/fts/fts.c	(revision 210668)
+++ testcases/fts/fts.c	(working copy)
@@ -27,9 +27,6 @@
 
 /* Directory scan */
 
-#include <sys/cdefs.h>
-__FBSDID("$FreeBSD$");
-
 #include <sys/param.h>
 #include <err.h>
 #include <errno.h>
Index: testcases/link/link.c
===================================================================
--- testcases/link/link.c	(revision 210668)
+++ testcases/link/link.c	(working copy)
@@ -25,9 +25,6 @@
  *
  */
 
-#include <sys/cdefs.h>
-__FBSDID("$FreeBSD$");
-
 #include <unistd.h>
 #include <stdio.h>
 #include <stdlib.h>
Index: testcases/lockf/lockf.c
===================================================================
--- testcases/lockf/lockf.c	(revision 210668)
+++ testcases/lockf/lockf.c	(working copy)
@@ -27,9 +27,6 @@
 
 /* Test lockf(3) */
 
-#include <sys/cdefs.h>
-__FBSDID("$FreeBSD$");
-
 #include <stdio.h>
 #include <stdlib.h>
 #include <unistd.h>
Index: testcases/creat/creat.c
===================================================================
--- testcases/creat/creat.c	(revision 210668)
+++ testcases/creat/creat.c	(working copy)
@@ -25,9 +25,6 @@
  *
  */
 
-#include <sys/cdefs.h>
-__FBSDID("$FreeBSD$");
-
 #include <unistd.h>
 #include <stdio.h>
 #include <stdlib.h>
Index: testcases/run/run.c
===================================================================
--- testcases/run/run.c	(revision 210668)
+++ testcases/run/run.c	(working copy)
@@ -27,9 +27,6 @@
 
 /* Control program to run all the other test cases */
 
-#include <sys/cdefs.h>
-__FBSDID("$FreeBSD$");
-
 #include <stdio.h>
 #include <stdlib.h>
 #include <unistd.h>
Index: testcases/mkdir/mkdir.c
===================================================================
--- testcases/mkdir/mkdir.c	(revision 210668)
+++ testcases/mkdir/mkdir.c	(working copy)
@@ -25,9 +25,6 @@
  *
  */
 
-#include <sys/cdefs.h>
-__FBSDID("$FreeBSD$");
-
 #include <sys/types.h>
 #include <sys/sysctl.h>
 #include <unistd.h>
Index: testcases/rename/rename.c
===================================================================
--- testcases/rename/rename.c	(revision 210668)
+++ testcases/rename/rename.c	(working copy)
@@ -25,9 +25,6 @@
  *
  */
 
-#include <sys/cdefs.h>
-__FBSDID("$FreeBSD$");
-
 #include <unistd.h>
 #include <stdio.h>
 #include <stdlib.h>
Index: testcases/swap/swap.c
===================================================================
--- testcases/swap/swap.c	(revision 210668)
+++ testcases/swap/swap.c	(working copy)
@@ -25,9 +25,6 @@
  *
  */
 
-#include <sys/cdefs.h>
-__FBSDID("$FreeBSD$");
-
 #include <sys/types.h>
 #include <sys/sysctl.h>
 #include <unistd.h>
Index: testcases/syscall/syscall.c
===================================================================
--- testcases/syscall/syscall.c	(revision 210668)
+++ testcases/syscall/syscall.c	(working copy)
@@ -27,9 +27,6 @@
 
 /* Call random system calls with random arguments */
 
-#include <sys/cdefs.h>
-__FBSDID("$FreeBSD$");
-
 #include <stdio.h>
 #include <stdlib.h>
 #include <unistd.h>
@@ -59,7 +56,7 @@
 	SYS___syscall,
 	SYS_rfork,
 	SYS_sigsuspend,
-	SYS_mac_syscall,
+//	SYS_mac_syscall,
 	SYS_sigtimedwait,
 	SYS_sigwaitinfo,
 };
Index: testcases/mkfifo/mkfifo.c
===================================================================
--- testcases/mkfifo/mkfifo.c	(revision 210668)
+++ testcases/mkfifo/mkfifo.c	(working copy)
@@ -25,9 +25,6 @@
  *
  */
 
-#include <sys/cdefs.h>
-__FBSDID("$FreeBSD$");
-
 #include <sys/param.h>
 #include <sys/types.h>
 #include <sys/stat.h>
Index: testcases/pty/pty.c
===================================================================
--- testcases/pty/pty.c	(revision 210668)
+++ testcases/pty/pty.c	(working copy)
@@ -27,9 +27,6 @@
 
 /* Test PTYs */
 
-#include <sys/cdefs.h>
-__FBSDID("$FreeBSD$");
-
 #include <stdio.h>
 #include <stdlib.h>
 #include <unistd.h>
Index: testcases/thr1/thr1.c
===================================================================
--- testcases/thr1/thr1.c	(revision 210668)
+++ testcases/thr1/thr1.c	(working copy)
@@ -25,9 +25,6 @@
  *
  */
 
-#include <sys/cdefs.h>
-__FBSDID("$FreeBSD$");
-
 #include <pthread.h>
 #include <stdio.h>
 #include <signal.h>
