Module Name: src
Committed By: christos
Date: Thu Mar 15 03:13:51 UTC 2018
Modified Files:
src/sys/compat/common: Makefile.sysio compat_mod.c
Added Files:
src/sys/compat/common: uvm_13.c uvm_50.c
src/sys/compat/sys: uvm.h
Log Message:
add uvm swap compat code.
To generate a diff of this commit:
cvs rdiff -u -r1.7 -r1.8 src/sys/compat/common/Makefile.sysio
cvs rdiff -u -r1.24 -r1.25 src/sys/compat/common/compat_mod.c
cvs rdiff -u -r0 -r1.1 src/sys/compat/common/uvm_13.c \
src/sys/compat/common/uvm_50.c
cvs rdiff -u -r0 -r1.1 src/sys/compat/sys/uvm.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.8
--- src/sys/compat/common/Makefile.sysio:1.7 Sat Nov 5 19:30:22 2016
+++ src/sys/compat/common/Makefile.sysio Wed Mar 14 23:13:51 2018
@@ -1,4 +1,4 @@
-# $NetBSD: Makefile.sysio,v 1.7 2016/11/05 23:30:22 pgoyette Exp $
+# $NetBSD: Makefile.sysio,v 1.8 2018/03/15 03:13:51 christos 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_13.c
# Compatibility code for NetBSD 1.6
SRCS+= kern_sig_16.c
@@ -32,7 +32,7 @@ SRCS+= vfs_syscalls_40.c uipc_syscalls_4
# 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
+ vfs_syscalls_50.c uipc_syscalls_50.c uvm_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 src/sys/compat/common/compat_mod.c:1.25
--- src/sys/compat/common/compat_mod.c:1.24 Sat Nov 5 19:30:22 2016
+++ src/sys/compat/common/compat_mod.c Wed Mar 14 23:13:51 2018
@@ -1,4 +1,4 @@
-/* $NetBSD: compat_mod.c,v 1.24 2016/11/05 23:30:22 pgoyette Exp $ */
+/* $NetBSD: compat_mod.c,v 1.25 2018/03/15 03:13:51 christos 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 2016/11/05 23:30:22 pgoyette Exp $");
+__KERNEL_RCSID(0, "$NetBSD: compat_mod.c,v 1.25 2018/03/15 03:13:51 christos Exp $");
#ifdef _KERNEL_OPT
#include "opt_compat_netbsd.h"
@@ -60,6 +60,7 @@ __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/sys/uvm.h>
#if defined(COMPAT_09) || defined(COMPAT_43) || defined(COMPAT_50)
static struct sysctllog *compat_clog = NULL;
@@ -238,6 +239,9 @@ compat_modcmd(modcmd_t cmd, void *arg)
ttcompatvec = ttcompat;
if_43_init();
#endif
+#ifdef COMPAT_13
+ uvm_13_init();
+#endif
#ifdef COMPAT_16
#if defined(COMPAT_SIGCONTEXT)
KASSERT(emul_netbsd.e_sigobject == NULL);
@@ -251,9 +255,15 @@ compat_modcmd(modcmd_t cmd, void *arg)
#endif
#endif
compat_sysctl_init();
+#ifdef COMPAT_50
+ uvm_50_init();
+#endif
return 0;
case MODULE_CMD_FINI:
+#ifdef COMPAT_13
+ uvm_13_fini();
+#endif
#ifdef COMPAT_16
/*
* Ensure sendsig_sigcontext() is not being used.
@@ -308,6 +318,9 @@ compat_modcmd(modcmd_t cmd, void *arg)
#endif
#endif /* COMPAT_16 */
compat_sysctl_fini();
+#ifdef COMPAT_50
+ uvm_50_fini();
+#endif
return 0;
default:
Added files:
Index: src/sys/compat/common/uvm_13.c
diff -u /dev/null src/sys/compat/common/uvm_13.c:1.1
--- /dev/null Wed Mar 14 23:13:51 2018
+++ src/sys/compat/common/uvm_13.c Wed Mar 14 23:13:51 2018
@@ -0,0 +1,84 @@
+/* $NetBSD: uvm_13.c,v 1.1 2018/03/15 03:13:51 christos Exp $ */
+
+/*-
+ * Copyright (c) 2018 The NetBSD Foundation, Inc.
+ * All rights reserved.
+ *
+ * This code is derived from software contributed to The NetBSD Foundation
+ * by Christos Zoulas.
+ *
+ * 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 NETBSD FOUNDATION, INC. AND CONTRIBUTORS
+ * ``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 FOUNDATION OR CONTRIBUTORS
+ * 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.
+ */
+
+#include <sys/cdefs.h>
+__KERNEL_RCSID(0, "$NetBSD: uvm_13.c,v 1.1 2018/03/15 03:13:51 christos Exp $");
+
+#if defined(_KERNEL) || defined(_MODULE)
+#if defined(_KERNEL_OPT)
+#include "opt_vmswap.h"
+#else
+#define VMSWAP /* XXX */
+#endif
+#endif
+
+#include <sys/param.h>
+#include <sys/types.h>
+#include <sys/systm.h>
+#include <sys/syscallargs.h>
+#include <sys/swap.h>
+#include <uvm/uvm.h>
+#include <uvm/uvm_swap.h>
+
+#include <compat/sys/uvm.h>
+
+static void
+swapent13_cvt(void *p, const struct swapent *se)
+{
+ struct swapent13 *sep13 = p;
+
+ sep13->se13_dev = se->se_dev;
+ sep13->se13_flags = se->se_flags;
+ sep13->se13_nblks = se->se_nblks;
+ sep13->se13_inuse = se->se_inuse;
+ sep13->se13_priority = se->se_priority;
+}
+
+
+static int
+compat_uvm_swap_stats13(const struct sys_swapctl_args *uap, register_t *retval)
+{
+ return uvm_swap_stats(SCARG(uap, arg), SCARG(uap, misc),
+ swapent13_cvt, sizeof(struct swapent13), retval);
+
+}
+
+void
+uvm_13_init(void)
+{
+ uvm_swap_stats13 = compat_uvm_swap_stats13;
+}
+
+void
+uvm_13_fini(void)
+{
+ uvm_swap_stats13 = (void *)enosys;
+}
Index: src/sys/compat/common/uvm_50.c
diff -u /dev/null src/sys/compat/common/uvm_50.c:1.1
--- /dev/null Wed Mar 14 23:13:51 2018
+++ src/sys/compat/common/uvm_50.c Wed Mar 14 23:13:51 2018
@@ -0,0 +1,85 @@
+/* $NetBSD: uvm_50.c,v 1.1 2018/03/15 03:13:51 christos Exp $ */
+
+/*-
+ * Copyright (c) 2018 The NetBSD Foundation, Inc.
+ * All rights reserved.
+ *
+ * This code is derived from software contributed to The NetBSD Foundation
+ * by Christos Zoulas.
+ *
+ * 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 NETBSD FOUNDATION, INC. AND CONTRIBUTORS
+ * ``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 FOUNDATION OR CONTRIBUTORS
+ * 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.
+ */
+
+#include <sys/cdefs.h>
+__KERNEL_RCSID(0, "$NetBSD: uvm_50.c,v 1.1 2018/03/15 03:13:51 christos Exp $");
+
+#if defined(_KERNEL) || defined(_MODULE)
+#if defined(_KERNEL_OPT)
+#include "opt_vmswap.h"
+#else
+#define VMSWAP /* XXX */
+#endif
+#endif
+
+#include <sys/param.h>
+#include <sys/types.h>
+#include <sys/systm.h>
+#include <sys/syscallargs.h>
+#include <sys/swap.h>
+#include <uvm/uvm.h>
+
+#include <compat/sys/uvm.h>
+
+static void
+swapent50_cvt(void *p, const struct swapent *se)
+{
+ struct swapent50 *sep50 = p;
+
+ sep50->se50_dev = se->se_dev;
+ sep50->se50_flags = se->se_flags;
+ sep50->se50_nblks = se->se_nblks;
+ sep50->se50_inuse = se->se_inuse;
+ sep50->se50_priority = se->se_priority;
+ KASSERT(sizeof(se->se_path) <= sizeof(sep50->se50_path));
+ strcpy(sep50->se50_path, se->se_path);
+}
+
+
+static int
+compat_uvm_swap_stats50(const struct sys_swapctl_args *uap, register_t *retval)
+{
+ return uvm_swap_stats(SCARG(uap, arg), SCARG(uap, misc),
+ swapent50_cvt, sizeof(struct swapent50), retval);
+
+}
+
+void
+uvm_50_init(void)
+{
+ uvm_swap_stats50 = compat_uvm_swap_stats50;
+}
+
+void
+uvm_50_fini(void)
+{
+ uvm_swap_stats50 = (void *)enosys;
+}
Index: src/sys/compat/sys/uvm.h
diff -u /dev/null src/sys/compat/sys/uvm.h:1.1
--- /dev/null Wed Mar 14 23:13:51 2018
+++ src/sys/compat/sys/uvm.h Wed Mar 14 23:13:51 2018
@@ -0,0 +1,69 @@
+/* $NetBSD: uvm.h,v 1.1 2018/03/15 03:13:51 christos Exp $ */
+
+/*-
+ * Copyright (c) 2018 The NetBSD Foundation, Inc.
+ * All rights reserved.
+ *
+ * This code is derived from software contributed to The NetBSD Foundation
+ * by Christos Zoulas.
+ *
+ * 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 NETBSD FOUNDATION, INC. AND CONTRIBUTORS
+ * ``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 FOUNDATION OR CONTRIBUTORS
+ * 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.
+ */
+
+#ifndef _COMPAT_SYS_UVM_H_
+#define _COMPAT_SYS_UVM_H_
+
+void uvm_13_init(void);
+void uvm_50_init(void);
+void uvm_13_fini(void);
+void uvm_50_fini(void);
+
+struct sys_swapctl_args;
+
+int (*uvm_swap_stats13)(const struct sys_swapctl_args *, register_t *);
+int (*uvm_swap_stats50)(const struct sys_swapctl_args *, register_t *);
+
+#endif /* _COMPAT_SYS_UVM_H_ */
+/*
+ * NetBSD 1.3 swapctl(SWAP_STATS, ...) swapent structure; uses 32 bit
+ * dev_t and has no se_path[] member.
+ */
+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 */
+};
+
+/*
+ * NetBSD 5.0 swapctl(SWAP_STATS, ...) swapent structure; uses 32 bit
+ * dev_t.
+ */
+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 */
+};