Module Name:    src
Committed By:   pgoyette
Date:           Tue Mar 13 09:10:31 UTC 2018

Modified Files:
        src/sys/compat/common [pgoyette-compat]: Makefile.sysio compat_mod.c
            files.common
        src/sys/uvm [pgoyette-compat]: uvm_swap.c uvm_swap.h
Added Files:
        src/sys/compat/common [pgoyette-compat]: uvm_stats_13.c uvm_stats_13.h
            uvm_stats_50.c uvm_stats_50.h

Log Message:
Move the swapstats compat code into the compat_netbsd module.

Without this, a kernel configured without COMPAT_13 and/or COMPAT_50
could not execute the compat swapstats code, even if the compat_netbsd
module had been loaded.


To generate a diff of this commit:
cvs rdiff -u -r1.7 -r1.7.18.1 src/sys/compat/common/Makefile.sysio
cvs rdiff -u -r1.24.14.4 -r1.24.14.5 src/sys/compat/common/compat_mod.c
cvs rdiff -u -r1.1.2.6 -r1.1.2.7 src/sys/compat/common/files.common
cvs rdiff -u -r0 -r1.1.2.1 src/sys/compat/common/uvm_stats_13.c \
    src/sys/compat/common/uvm_stats_13.h src/sys/compat/common/uvm_stats_50.c \
    src/sys/compat/common/uvm_stats_50.h
cvs rdiff -u -r1.175 -r1.175.2.1 src/sys/uvm/uvm_swap.c
cvs rdiff -u -r1.22 -r1.22.16.1 src/sys/uvm/uvm_swap.h

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/sys/compat/common/Makefile.sysio
diff -u src/sys/compat/common/Makefile.sysio:1.7 src/sys/compat/common/Makefile.sysio:1.7.18.1
--- src/sys/compat/common/Makefile.sysio:1.7	Sat Nov  5 23:30:22 2016
+++ src/sys/compat/common/Makefile.sysio	Tue Mar 13 09:10:31 2018
@@ -1,4 +1,4 @@
-#	$NetBSD: Makefile.sysio,v 1.7 2016/11/05 23:30:22 pgoyette Exp $
+#	$NetBSD: Makefile.sysio,v 1.7.18.1 2018/03/13 09:10:31 pgoyette Exp $
 
 # Sources for syscall and ioctl compatibility across the versions.
 
@@ -13,7 +13,7 @@ SRCS+=	kern_info_09.c
 SRCS+=	kern_xxx_12.c vfs_syscalls_12.c vm_12.c
 
 # Compatibility code for NetBSD 1.3
-SRCS+=	kern_sig_13.c
+SRCS+=	kern_sig_13.c uvm_stats_13.c
 
 # Compatibility code for NetBSD 1.6
 SRCS+=	kern_sig_16.c
@@ -31,8 +31,8 @@ SRCS+=	kern_time_30.c vfs_syscalls_30.c 
 SRCS+=	vfs_syscalls_40.c uipc_syscalls_40.c
 
 # Compatibility code for NetBSD 5.0
-SRCS+=	kern_50.c kern_time_50.c kern_select_50.c rndpseudo_50.c rtsock_50.c \
-	vfs_syscalls_50.c  uipc_syscalls_50.c
+SRCS+=	kern_50.c kern_time_50.c kern_select_50.c rndpseudo_50.c rtsock_50.c
+SRCS+=	vfs_syscalls_50.c  uipc_syscalls_50.c uvm_stats_50.c
 
 # Compatibility code for NetBSD 6.0
 SRCS+=	kern_sa_60.c tty_60.c kern_time_60.c

Index: src/sys/compat/common/compat_mod.c
diff -u src/sys/compat/common/compat_mod.c:1.24.14.4 src/sys/compat/common/compat_mod.c:1.24.14.5
--- src/sys/compat/common/compat_mod.c:1.24.14.4	Thu Mar  8 01:07:13 2018
+++ src/sys/compat/common/compat_mod.c	Tue Mar 13 09:10:31 2018
@@ -1,4 +1,4 @@
-/*	$NetBSD: compat_mod.c,v 1.24.14.4 2018/03/08 01:07:13 pgoyette Exp $	*/
+/*	$NetBSD: compat_mod.c,v 1.24.14.5 2018/03/13 09:10:31 pgoyette Exp $	*/
 
 /*-
  * Copyright (c) 2008 The NetBSD Foundation, Inc.
@@ -34,7 +34,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: compat_mod.c,v 1.24.14.4 2018/03/08 01:07:13 pgoyette Exp $");
+__KERNEL_RCSID(0, "$NetBSD: compat_mod.c,v 1.24.14.5 2018/03/13 09:10:31 pgoyette Exp $");
 
 #ifdef _KERNEL_OPT
 #include "opt_compat_netbsd.h"
@@ -62,6 +62,8 @@ __KERNEL_RCSID(0, "$NetBSD: compat_mod.c
 #include <compat/common/compat_util.h>
 #include <compat/common/compat_mod.h>
 #include <compat/common/if_43.h>
+#include <compat/common/uvm_stats_13.h>
+#include <compat/common/uvm_stats_50.h>
 #include <compat/sys/sockio.h>
 
 
@@ -251,11 +253,15 @@ compat_modcmd(modcmd_t cmd, void *arg)
 		ttcompatvec = ttcompat;
 		if_43_init();
 #endif
+#ifdef COMPAT_13
+		swapstats_13_init();
+#endif
 #ifdef COMPAT_40
 		if_40_init();
 #endif
 #ifdef COMPAT_50
 		if_50_init();
+		swapstats_50_init();
 #endif
 #ifdef COMPAT_16
 #if defined(COMPAT_SIGCONTEXT)
@@ -326,6 +332,16 @@ compat_modcmd(modcmd_t cmd, void *arg)
 		rw_exit(&exec_lock);
 #endif
 #endif	/* COMPAT_16 */
+#ifdef COMPAT_13
+		swapstats_13_fini();
+#endif
+#ifdef COMPAT_40
+		if_40_fini();
+#endif
+#ifdef COMPAT_50
+		if_50_fini();
+		swapstats_50_fini();
+#endif
 		compat_sysctl_fini();
 		return 0;
 

Index: src/sys/compat/common/files.common
diff -u src/sys/compat/common/files.common:1.1.2.6 src/sys/compat/common/files.common:1.1.2.7
--- src/sys/compat/common/files.common:1.1.2.6	Mon Mar 12 01:59:31 2018
+++ src/sys/compat/common/files.common	Tue Mar 13 09:10:31 2018
@@ -1,4 +1,4 @@
-#	$NetBSD: files.common,v 1.1.2.6 2018/03/12 01:59:31 pgoyette Exp $
+#	$NetBSD: files.common,v 1.1.2.7 2018/03/13 09:10:31 pgoyette Exp $
 
 #
 # Generic files, used by all compat options.
@@ -32,6 +32,7 @@ file	compat/common/vm_12.c			compat_netb
 
 # Compatibility code for NetBSD 1.3
 file	compat/common/kern_sig_13.c		compat_netbsd
+file	compat/common/uvm_stats_13.c		compat_netbsd
 
 # Compatibility code for NetBSD 1.4
 file	compat/common/rtsock_14.c		compat_netbsd
@@ -59,6 +60,7 @@ file	compat/common/rndpseudo_50.c		compa
 file	compat/common/rtsock_50.c		compat_netbsd
 file	compat/common/vfs_syscalls_50.c		compat_netbsd
 file	compat/common/uipc_syscalls_50.c	compat_netbsd
+file	compat/common/uvm_stats_50.c		compat_netbsd
 
 # Compatibility code for NetBSD 6.0
 file	compat/common/kern_sa_60.c		compat_netbsd

Index: src/sys/uvm/uvm_swap.c
diff -u src/sys/uvm/uvm_swap.c:1.175 src/sys/uvm/uvm_swap.c:1.175.2.1
--- src/sys/uvm/uvm_swap.c:1.175	Sat Oct 28 00:37:13 2017
+++ src/sys/uvm/uvm_swap.c	Tue Mar 13 09:10:31 2018
@@ -1,4 +1,4 @@
-/*	$NetBSD: uvm_swap.c,v 1.175 2017/10/28 00:37:13 pgoyette Exp $	*/
+/*	$NetBSD: uvm_swap.c,v 1.175.2.1 2018/03/13 09:10:31 pgoyette Exp $	*/
 
 /*
  * Copyright (c) 1995, 1996, 1997, 2009 Matthew R. Green
@@ -30,7 +30,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: uvm_swap.c,v 1.175 2017/10/28 00:37:13 pgoyette Exp $");
+__KERNEL_RCSID(0, "$NetBSD: uvm_swap.c,v 1.175.2.1 2018/03/13 09:10:31 pgoyette Exp $");
 
 #include "opt_uvmhist.h"
 #include "opt_compat_netbsd.h"
@@ -116,35 +116,6 @@ __KERNEL_RCSID(0, "$NetBSD: uvm_swap.c,v
  */
 
 /*
- * swapdev: describes a single swap partition/file
- *
- * note the following should be true:
- * swd_inuse <= swd_nblks  [number of blocks in use is <= total blocks]
- * swd_nblks <= swd_mapsize [because mapsize includes miniroot+disklabel]
- */
-struct swapdev {
-	dev_t			swd_dev;	/* device id */
-	int			swd_flags;	/* flags:inuse/enable/fake */
-	int			swd_priority;	/* our priority */
-	int			swd_nblks;	/* blocks in this device */
-	char			*swd_path;	/* saved pathname of device */
-	int			swd_pathlen;	/* length of pathname */
-	int			swd_npages;	/* #pages we can use */
-	int			swd_npginuse;	/* #pages in use */
-	int			swd_npgbad;	/* #pages bad */
-	int			swd_drumoffset;	/* page0 offset in drum */
-	int			swd_drumsize;	/* #pages in drum */
-	blist_t			swd_blist;	/* blist for this swapdev */
-	struct vnode		*swd_vp;	/* backing vnode */
-	TAILQ_ENTRY(swapdev)	swd_next;	/* priority tailq */
-
-	int			swd_bsize;	/* blocksize (bytes) */
-	int			swd_maxactive;	/* max active i/o reqs */
-	struct bufq_state	*swd_tab;	/* buffer list */
-	int			swd_active;	/* number of active buffers */
-};
-
-/*
  * swap device priority entry; the list is kept sorted on `spi_priority'.
  */
 struct swappri {
@@ -245,6 +216,40 @@ static void sw_reg_start(struct swapdev 
 static int uvm_swap_io(struct vm_page **, int, int, int);
 
 /*
+ * vectored routines for COMPAT_13 and COMPAT_50
+ */
+
+size_t swapstats_len_13 = 0;
+
+static void stub_swapstats13_copy(int, int, struct swapdev *,
+    struct swapent13 *);
+void (*vec_swapstats_copy_13)(int, int, struct swapdev *, struct swapent13 *) =
+    stub_swapstats13_copy;
+
+size_t swapstats_len_50 = 0;
+
+static void stub_swapstats50_copy(int, int, struct swapdev *,
+    struct swapent50 *);
+void (*vec_swapstats_copy_50)(int, int, struct swapdev *, struct swapent50 *) =
+    stub_swapstats50_copy;
+
+static void
+stub_swapstats13_copy(int cmd, int inuse, struct swapdev *sdp,
+    struct swapent13 *sep13)
+{
+
+	/* nothing */
+}
+
+static void
+stub_swapstats50_copy(int cmd, int inuse, struct swapdev *sdp,
+    struct swapent50 *sep50)
+{
+
+	/* nothing */
+}
+
+/*
  * uvm_swap_init: init the swap system data structures and locks
  *
  * => called at boot time from init_main.c after the filesystems
@@ -494,14 +499,18 @@ sys_swapctl(struct lwp *l, const struct 
 	 * to grab the uvm_swap_data_lock because we may fault&sleep during
 	 * copyout() and we don't want to be holding that lock then!
 	 */
-	if (SCARG(uap, cmd) == SWAP_STATS
-#if defined(COMPAT_50)
-	    || SCARG(uap, cmd) == SWAP_STATS50
-#endif
-#if defined(COMPAT_13)
-	    || SCARG(uap, cmd) == SWAP_STATS13
-#endif
-	    ) {
+	len = 0;
+	if (SCARG(uap, cmd) == SWAP_STATS)
+		len = sizeof(struct swapent);
+	else if (SCARG(uap, cmd) == SWAP_STATS13)
+		len = swapstats_len_13;
+	else if (SCARG(uap, cmd) == SWAP_STATS50)
+		len = swapstats_len_50;
+	/*
+	 * If the compat_* code isn't loaded, len will still be zero
+	 * and we'll just fall through and return EINVAL
+	 */
+	if (len > 0) {
 		if (misc < 0) {
 			error = EINVAL;
 			goto out;
@@ -514,17 +523,7 @@ sys_swapctl(struct lwp *l, const struct 
 		if ((size_t)misc > (size_t)uvmexp.nswapdev)
 			misc = uvmexp.nswapdev;
 		KASSERT(misc > 0);
-#if defined(COMPAT_13)
-		if (SCARG(uap, cmd) == SWAP_STATS13)
-			len = sizeof(struct swapent13) * misc;
-		else
-#endif
-#if defined(COMPAT_50)
-		if (SCARG(uap, cmd) == SWAP_STATS50)
-			len = sizeof(struct swapent50) * misc;
-		else
-#endif
-			len = sizeof(struct swapent) * misc;
+		len *= misc;
 		sep = (struct swapent *)kmem_alloc(len, KM_SLEEP);
 
 		uvm_swap_stats(SCARG(uap, cmd), sep, misc, retval);
@@ -769,9 +768,7 @@ uvm_swap_stats(int cmd, struct swapent *
 			inuse = btodb((uint64_t)sdp->swd_npginuse <<
 			    PAGE_SHIFT);
 
-#if defined(COMPAT_13) || defined(COMPAT_50)
 			if (cmd == SWAP_STATS) {
-#endif
 				sep->se_dev = sdp->swd_dev;
 				sep->se_flags = sdp->swd_flags;
 				sep->se_nblks = sdp->swd_nblks;
@@ -781,36 +778,21 @@ uvm_swap_stats(int cmd, struct swapent *
 				    sizeof(sep->se_path));
 				strcpy(sep->se_path, sdp->swd_path);
 				sep++;
-#if defined(COMPAT_13)
 			} else if (cmd == SWAP_STATS13) {
 				struct swapent13 *sep13 =
 				    (struct swapent13 *)sep;
 
-				sep13->se13_dev = sdp->swd_dev;
-				sep13->se13_flags = sdp->swd_flags;
-				sep13->se13_nblks = sdp->swd_nblks;
-				sep13->se13_inuse = inuse;
-				sep13->se13_priority = sdp->swd_priority;
+				(*vec_swapstats_copy_13)(cmd, inuse, sdp,
+				    sep13);
 				sep = (struct swapent *)(sep13 + 1);
-#endif
-#if defined(COMPAT_50)
 			} else if (cmd == SWAP_STATS50) {
 				struct swapent50 *sep50 =
 				    (struct swapent50 *)sep;
 
-				sep50->se50_dev = sdp->swd_dev;
-				sep50->se50_flags = sdp->swd_flags;
-				sep50->se50_nblks = sdp->swd_nblks;
-				sep50->se50_inuse = inuse;
-				sep50->se50_priority = sdp->swd_priority;
-				KASSERT(sdp->swd_pathlen <
-				    sizeof(sep50->se50_path));
-				strcpy(sep50->se50_path, sdp->swd_path);
+				(*vec_swapstats_copy_50)(cmd, inuse, sdp,
+				    sep50);
 				sep = (struct swapent *)(sep50 + 1);
-#endif
-#if defined(COMPAT_13) || defined(COMPAT_50)
 			}
-#endif
 			count++;
 		}
 	}

Index: src/sys/uvm/uvm_swap.h
diff -u src/sys/uvm/uvm_swap.h:1.22 src/sys/uvm/uvm_swap.h:1.22.16.1
--- src/sys/uvm/uvm_swap.h:1.22	Thu Jul 30 10:25:49 2015
+++ src/sys/uvm/uvm_swap.h	Tue Mar 13 09:10:31 2018
@@ -1,4 +1,4 @@
-/*	$NetBSD: uvm_swap.h,v 1.22 2015/07/30 10:25:49 christos Exp $	*/
+/*	$NetBSD: uvm_swap.h,v 1.22.16.1 2018/03/13 09:10:31 pgoyette Exp $	*/
 
 /*
  * Copyright (c) 1997 Matthew R. Green
@@ -38,9 +38,40 @@
 #include "opt_vmswap.h"
 #endif
 
+#include <sys/blist.h>
+
 struct swapent;
 struct lwp;
 
+/*
+ * swapdev: describes a single swap partition/file
+ *
+ * note the following should be true:
+ * swd_inuse <= swd_nblks  [number of blocks in use is <= total blocks]
+ * swd_nblks <= swd_mapsize [because mapsize includes miniroot+disklabel]
+ */   
+struct swapdev {
+	dev_t			swd_dev;	/* device id */
+	int			swd_flags;	/* flags:inuse/enable/fake */
+	int			swd_priority;	/* our priority */ 
+	int			swd_nblks;	/* blocks in this device */
+	char			*swd_path;	/* saved pathname of device */
+	int			swd_pathlen;	/* length of pathname */
+	int			swd_npages;	/* #pages we can use */
+	int			swd_npginuse;	/* #pages in use */
+	int			swd_npgbad;	/* #pages bad */
+	int			swd_drumoffset;	/* page0 offset in drum */
+	int			swd_drumsize;	/* #pages in drum */
+	blist_t			swd_blist;	/* blist for this swapdev */
+	struct vnode		*swd_vp;	/* backing vnode */
+	TAILQ_ENTRY(swapdev)	swd_next;	/* priority tailq */
+ 
+	int			swd_bsize;	/* blocksize (bytes) */ 
+	int			swd_maxactive;	/* max active i/o reqs */
+	struct bufq_state	*swd_tab;	/* buffer list */
+	int			swd_active;	/* number of active buffers */
+};      
+
 #if defined(VMSWAP)
 int	uvm_swap_get(struct vm_page *, int, int);
 int	uvm_swap_put(int, struct vm_page **, int, int);

Added files:

Index: src/sys/compat/common/uvm_stats_13.c
diff -u /dev/null src/sys/compat/common/uvm_stats_13.c:1.1.2.1
--- /dev/null	Tue Mar 13 09:10:31 2018
+++ src/sys/compat/common/uvm_stats_13.c	Tue Mar 13 09:10:31 2018
@@ -0,0 +1,80 @@
+/*	$NetBSD: uvm_stats_13.c,v 1.1.2.1 2018/03/13 09:10:31 pgoyette Exp $	*/
+
+/*
+ * Copyright (c) 1995, 1996, 1997, 2009 Matthew R. Green
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * 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 THE AUTHOR ``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 THE AUTHOR 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.
+ *
+ * from: NetBSD: uvm_swap.c,v 1.175 2017/10/28 00:37:13 pgoyette Exp
+ * from: NetBSD: vm_swap.c,v 1.52 1997/12/02 13:47:37 pk Exp
+ * from: Id: uvm_swap.c,v 1.1.2.42 1998/02/02 20:38:06 chuck Exp
+ */
+
+#include <sys/cdefs.h>
+__KERNEL_RCSID(0, "$NetBSD: uvm_stats_13.c,v 1.1.2.1 2018/03/13 09:10:31 pgoyette Exp $");
+
+#include <sys/param.h>
+#include <sys/systm.h>
+#include <sys/errno.h>
+#include <sys/swap.h>
+
+#include <uvm/uvm.h>
+
+#include <compat/common/uvm_stats_13.h>
+
+static void (*orig_swapstats_copy_13)(int, int, struct swapdev *,
+    struct swapent13 *);
+
+static void swapstats_copy_13(int, int, struct swapdev *, struct swapent13 *);
+
+void
+swapstats_13_init(void)
+{
+
+	swapstats_len_13 = sizeof(struct swapent13);
+
+	orig_swapstats_copy_13 = vec_swapstats_copy_13;
+	vec_swapstats_copy_13 = swapstats_copy_13;
+}
+
+void
+swapstats_13_fini(void)
+{
+
+	swapstats_len_13 = 0;
+	vec_swapstats_copy_13 = orig_swapstats_copy_13;
+}
+
+static void
+swapstats_copy_13(int cmd, int inuse, struct swapdev *sdp,
+    struct swapent13 *sep13)
+{
+
+	if (cmd == SWAP_STATS13) {
+		sep13->se13_dev = sdp->swd_dev;
+		sep13->se13_flags = sdp->swd_flags;
+		sep13->se13_nblks = sdp->swd_nblks;
+		sep13->se13_inuse = inuse;
+		sep13->se13_priority = sdp->swd_priority;
+	}
+}
Index: src/sys/compat/common/uvm_stats_13.h
diff -u /dev/null src/sys/compat/common/uvm_stats_13.h:1.1.2.1
--- /dev/null	Tue Mar 13 09:10:31 2018
+++ src/sys/compat/common/uvm_stats_13.h	Tue Mar 13 09:10:31 2018
@@ -0,0 +1,51 @@
+/*	$NetBSD: uvm_stats_13.h,v 1.1.2.1 2018/03/13 09:10:31 pgoyette Exp $	*/
+
+/*
+ * Copyright (c) 1997 Matthew R. Green
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * 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 THE AUTHOR ``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 THE AUTHOR 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.
+ *
+ * from: Id: uvm_swap.h,v 1.1.2.6 1997/12/15 05:39:31 mrg Exp
+ */
+
+#ifndef _COMPAT_COMMON_UVM_STATS_13_H
+#define _COMPAT_COMMON_UVM_STATS_13_H
+
+struct swapent13 {
+	int32_t	se13_dev;		/* device id */
+	int	se13_flags;		/* flags */
+	int	se13_nblks;		/* total blocks */ 
+	int	se13_inuse;		/* blocks in use */
+	int	se13_priority;		/* priority of this device */  
+};
+
+struct swapdev;
+
+void swapstats_13_init(void);
+void swapstats_13_fini(void);
+
+extern size_t swapstats_len_13;
+extern void (*vec_swapstats_copy_13)(int, int, struct swapdev *,
+    struct swapent13 *);
+
+#endif /* _COMPAT_COMMON_UVM_STATS_13_H */
Index: src/sys/compat/common/uvm_stats_50.c
diff -u /dev/null src/sys/compat/common/uvm_stats_50.c:1.1.2.1
--- /dev/null	Tue Mar 13 09:10:31 2018
+++ src/sys/compat/common/uvm_stats_50.c	Tue Mar 13 09:10:31 2018
@@ -0,0 +1,83 @@
+/*	$NetBSD: uvm_stats_50.c,v 1.1.2.1 2018/03/13 09:10:31 pgoyette Exp $	*/
+
+/*
+ * Copyright (c) 1995, 1996, 1997, 2009 Matthew R. Green
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * 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 THE AUTHOR ``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 THE AUTHOR 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.
+ *
+ * from: NetBSD: uvm_swap.c,v 1.175 2017/10/28 00:37:13 pgoyette Exp
+ * from: NetBSD: vm_swap.c,v 1.52 1997/12/02 13:47:37 pk Exp
+ * from: Id: uvm_swap.c,v 1.1.2.42 1998/02/02 20:38:06 chuck Exp
+ */
+
+#include <sys/cdefs.h>
+__KERNEL_RCSID(0, "$NetBSD: uvm_stats_50.c,v 1.1.2.1 2018/03/13 09:10:31 pgoyette Exp $");
+
+#include <sys/param.h>
+#include <sys/systm.h>
+#include <sys/errno.h>
+#include <sys/kernel.h>
+#include <sys/swap.h>
+
+#include <uvm/uvm.h>
+
+#include <compat/common/uvm_stats_50.h>
+
+static void (*orig_swapstats_copy_50)(int, int, struct swapdev *,
+    struct swapent50 *);
+
+static void swapstats_copy_50(int, int, struct swapdev *, struct swapent50 *);
+ 
+void
+swapstats_50_init(void)
+{
+  
+	swapstats_len_50 = sizeof(struct swapent50);
+  
+	orig_swapstats_copy_50 = vec_swapstats_copy_50;
+	vec_swapstats_copy_50 = swapstats_copy_50;
+}
+
+void
+swapstats_50_fini(void)
+{
+
+	swapstats_len_50 = 0;
+	vec_swapstats_copy_50 = orig_swapstats_copy_50;
+}
+
+static void
+swapstats_copy_50(int cmd, int inuse, struct swapdev *sdp,
+    struct swapent50 *sep50)
+{
+
+	if (cmd == SWAP_STATS50) {
+		sep50->se50_dev = sdp->swd_dev;
+		sep50->se50_flags = sdp->swd_flags;
+		sep50->se50_nblks = sdp->swd_nblks;
+		sep50->se50_inuse = inuse;
+		sep50->se50_priority = sdp->swd_priority;
+		KASSERT(sdp->swd_pathlen < sizeof(sep50->se50_path));
+		strcpy(sep50->se50_path, sdp->swd_path);
+	}
+}
Index: src/sys/compat/common/uvm_stats_50.h
diff -u /dev/null src/sys/compat/common/uvm_stats_50.h:1.1.2.1
--- /dev/null	Tue Mar 13 09:10:31 2018
+++ src/sys/compat/common/uvm_stats_50.h	Tue Mar 13 09:10:31 2018
@@ -0,0 +1,52 @@
+/*	$NetBSD: uvm_stats_50.h,v 1.1.2.1 2018/03/13 09:10:31 pgoyette Exp $	*/
+
+/*
+ * Copyright (c) 1997 Matthew R. Green
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * 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 THE AUTHOR ``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 THE AUTHOR 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.
+ *
+ * from: Id: uvm_swap.h,v 1.1.2.6 1997/12/15 05:39:31 mrg Exp
+ */
+
+#ifndef _COMPAT_COMMON_UVM_STATS_50_H
+#define _COMPAT_COMMON_UVM_STATS_50_H
+
+struct swapent50 {
+	int32_t	se50_dev;		/* device id */
+	int	se50_flags;		/* flags */
+	int	se50_nblks;		/* total blocks */
+	int	se50_inuse;		/* blocks in use */
+	int	se50_priority;		/* priority of this device */
+	char	se50_path[PATH_MAX+1];	/* path name */
+};
+
+struct swapdev;
+
+void swapstats_50_init(void);
+void swapstats_50_fini(void);
+
+extern size_t swapstats_len_50;
+extern void (*vec_swapstats_copy_50)(int, int, struct swapdev *,
+    struct swapent50 *);
+
+#endif /* _COMPAT_COMMON_UVM_STATS_50_H */

Reply via email to