Module Name:    src
Committed By:   msaitoh
Date:           Tue Mar 18 08:09:46 UTC 2014

Modified Files:
        src/sys/compat/netbsd32 [netbsd-6]: netbsd32.h netbsd32_netbsd.c
        src/sys/uvm [netbsd-6]: uvm_swap.c uvm_swap.h

Log Message:
Pull up following revision(s) (requested by manu in ticket #1025):
        sys/compat/netbsd32/netbsd32_netbsd.c: revision 1.184
        sys/uvm/uvm_swap.c: revision 1.166
        sys/uvm/uvm_swap.h: revision 1.20
        sys/compat/netbsd32/netbsd32.h: revision 1.99
Properly translate struct swapent for COMPAT_NETBSD32
 Properly translate struct swapent for COMPAT_NETBSD32  (missing commit)


To generate a diff of this commit:
cvs rdiff -u -r1.92.2.2 -r1.92.2.3 src/sys/compat/netbsd32/netbsd32.h
cvs rdiff -u -r1.179 -r1.179.2.1 src/sys/compat/netbsd32/netbsd32_netbsd.c
cvs rdiff -u -r1.161 -r1.161.2.1 src/sys/uvm/uvm_swap.c
cvs rdiff -u -r1.18 -r1.18.10.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/netbsd32/netbsd32.h
diff -u src/sys/compat/netbsd32/netbsd32.h:1.92.2.2 src/sys/compat/netbsd32/netbsd32.h:1.92.2.3
--- src/sys/compat/netbsd32/netbsd32.h:1.92.2.2	Thu Dec 13 23:47:57 2012
+++ src/sys/compat/netbsd32/netbsd32.h	Tue Mar 18 08:09:46 2014
@@ -1,4 +1,4 @@
-/*	$NetBSD: netbsd32.h,v 1.92.2.2 2012/12/13 23:47:57 riz Exp $	*/
+/*	$NetBSD: netbsd32.h,v 1.92.2.3 2014/03/18 08:09:46 msaitoh Exp $	*/
 
 /*
  * Copyright (c) 1998, 2001, 2008 Matthew R. Green
@@ -383,6 +383,16 @@ struct netbsd32_loadavg {
 	netbsd32_long	fscale;
 };
 
+/* from <sys/swap.h> */
+struct netbsd32_swapent {
+	netbsd32_dev_t	se_dev;		/* device id */
+	int	se_flags;		/* flags */
+	int	se_nblks;		/* total blocks */
+	int	se_inuse;		/* blocks in use */
+	int	se_priority;		/* priority of this device */
+	char	se_path[PATH_MAX+1];	/* path	name */
+};
+
 /* from <sys/ipc.h> */
 typedef netbsd32_pointer_t netbsd32_ipc_permp_t;
 struct netbsd32_ipc_perm {

Index: src/sys/compat/netbsd32/netbsd32_netbsd.c
diff -u src/sys/compat/netbsd32/netbsd32_netbsd.c:1.179 src/sys/compat/netbsd32/netbsd32_netbsd.c:1.179.2.1
--- src/sys/compat/netbsd32/netbsd32_netbsd.c:1.179	Wed Feb  1 05:43:54 2012
+++ src/sys/compat/netbsd32/netbsd32_netbsd.c	Tue Mar 18 08:09:46 2014
@@ -1,4 +1,4 @@
-/*	$NetBSD: netbsd32_netbsd.c,v 1.179 2012/02/01 05:43:54 dholland Exp $	*/
+/*	$NetBSD: netbsd32_netbsd.c,v 1.179.2.1 2014/03/18 08:09:46 msaitoh Exp $	*/
 
 /*
  * Copyright (c) 1998, 2001, 2008 Matthew R. Green
@@ -27,7 +27,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: netbsd32_netbsd.c,v 1.179 2012/02/01 05:43:54 dholland Exp $");
+__KERNEL_RCSID(0, "$NetBSD: netbsd32_netbsd.c,v 1.179.2.1 2014/03/18 08:09:46 msaitoh Exp $");
 
 #if defined(_KERNEL_OPT)
 #include "opt_ddb.h"
@@ -56,6 +56,7 @@ __KERNEL_RCSID(0, "$NetBSD: netbsd32_net
 #include <sys/socketvar.h>
 #include <sys/mbuf.h>
 #include <sys/stat.h>
+#include <sys/swap.h>
 #include <sys/time.h>
 #include <sys/signalvar.h>
 #include <sys/ptrace.h>
@@ -73,6 +74,7 @@ __KERNEL_RCSID(0, "$NetBSD: netbsd32_net
 #include <sys/vfs_syscalls.h>
 
 #include <uvm/uvm_extern.h>
+#include <uvm/uvm_swap.h>
 
 #include <sys/sa.h>
 #include <sys/savar.h>
@@ -1728,6 +1730,51 @@ netbsd32___posix_rename(struct lwp *l, c
 	return (sys___posix_rename(l, &ua, retval));
 }
 
+static int
+netbsd32_swapctl_stats(struct lwp *l, struct sys_swapctl_args *uap, register_t *retval)
+{
+	struct swapent *ksep;
+	struct netbsd32_swapent *usep32;
+	struct netbsd32_swapent se32;
+	int count = SCARG(uap, misc);
+	int i, error = 0;
+	size_t ksep_len;
+
+	/* Make sure userland cannot exhaust kernel memory */
+	if ((size_t)count > (size_t)uvmexp.nswapdev)
+		count = uvmexp.nswapdev;
+
+	ksep_len = sizeof(*ksep) * count;
+	ksep = kmem_alloc(ksep_len, KM_SLEEP);
+	usep32 = (struct netbsd32_swapent *)SCARG(uap, arg);
+
+	uvm_swap_stats(SWAP_STATS, ksep, count, retval);
+	count = *retval;
+
+	if (count < 1)
+		goto out;
+
+	for (i = 0; i < count; i++) {
+		se32.se_dev = ksep[i].se_dev;
+		se32.se_flags = ksep[i].se_flags;
+		se32.se_nblks = ksep[i].se_nblks;
+		se32.se_inuse = ksep[i].se_inuse;
+		se32.se_priority = ksep[i].se_priority;
+		memcpy(se32.se_path, ksep[i].se_path,
+			sizeof(se32.se_path));
+
+		error = copyout(&se32, usep32 + i, sizeof(se32));
+		if (error)
+			break;
+	}
+
+	
+out:
+	kmem_free(ksep, ksep_len);
+
+	return error;
+}
+
 int
 netbsd32_swapctl(struct lwp *l, const struct netbsd32_swapctl_args *uap, register_t *retval)
 {
@@ -1741,6 +1788,11 @@ netbsd32_swapctl(struct lwp *l, const st
 	NETBSD32TO64_UAP(cmd);
 	NETBSD32TOP_UAP(arg, void);
 	NETBSD32TO64_UAP(misc);
+
+	/* SWAP_STATS50 and SWAP_STATS13 structures need no translation */
+	if (SCARG(&ua, cmd) == SWAP_STATS)
+		return netbsd32_swapctl_stats(l, &ua, retval);
+	
 	return (sys_swapctl(l, &ua, retval));
 }
 

Index: src/sys/uvm/uvm_swap.c
diff -u src/sys/uvm/uvm_swap.c:1.161 src/sys/uvm/uvm_swap.c:1.161.2.1
--- src/sys/uvm/uvm_swap.c:1.161	Sun Feb  5 16:08:28 2012
+++ src/sys/uvm/uvm_swap.c	Tue Mar 18 08:09:46 2014
@@ -1,4 +1,4 @@
-/*	$NetBSD: uvm_swap.c,v 1.161 2012/02/05 16:08:28 rmind Exp $	*/
+/*	$NetBSD: uvm_swap.c,v 1.161.2.1 2014/03/18 08:09:46 msaitoh 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.161 2012/02/05 16:08:28 rmind Exp $");
+__KERNEL_RCSID(0, "$NetBSD: uvm_swap.c,v 1.161.2.1 2014/03/18 08:09:46 msaitoh Exp $");
 
 #include "opt_uvmhist.h"
 #include "opt_compat_netbsd.h"
@@ -237,8 +237,6 @@ static void		 swaplist_trim(void);
 static int swap_on(struct lwp *, struct swapdev *);
 static int swap_off(struct lwp *, struct swapdev *);
 
-static void uvm_swap_stats(int, struct swapent *, int, register_t *);
-
 static void sw_reg_strategy(struct swapdev *, struct buf *, int);
 static void sw_reg_biodone(struct buf *);
 static void sw_reg_iodone(struct work *wk, void *dummy);
@@ -734,7 +732,7 @@ out:
  * is not known at build time. Hence it would not be possible to
  * ensure it would fit in the stackgap in any case.
  */
-static void
+void
 uvm_swap_stats(int cmd, struct swapent *sep, int sec, register_t *retval)
 {
 	struct swappri *spp;

Index: src/sys/uvm/uvm_swap.h
diff -u src/sys/uvm/uvm_swap.h:1.18 src/sys/uvm/uvm_swap.h:1.18.10.1
--- src/sys/uvm/uvm_swap.h:1.18	Wed Apr 27 00:35:52 2011
+++ src/sys/uvm/uvm_swap.h	Tue Mar 18 08:09:46 2014
@@ -1,4 +1,4 @@
-/*	$NetBSD: uvm_swap.h,v 1.18 2011/04/27 00:35:52 rmind Exp $	*/
+/*	$NetBSD: uvm_swap.h,v 1.18.10.1 2014/03/18 08:09:46 msaitoh Exp $	*/
 
 /*
  * Copyright (c) 1997 Matthew R. Green
@@ -47,8 +47,10 @@ int	uvm_swap_alloc(int *, bool);
 void	uvm_swap_free(int, int);
 void	uvm_swap_markbad(int, int);
 bool	uvm_swapisfull(void);
+void	uvm_swap_stats(int, struct swapent *, int, register_t *);
 #else /* defined(VMSWAP) */
 #define	uvm_swapisfull()	true
+#define uvm_swap_stats(c, sep, count, retval) { *retval = 0; }
 #endif /* defined(VMSWAP) */
 
 #endif /* _KERNEL */

Reply via email to