Source-Changes-HG archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

[src/netbsd-6]: src/sys Pull up following revision(s) (requested by manu in t...



details:   https://anonhg.NetBSD.org/src/rev/d98a84c1d28f
branches:  netbsd-6
changeset: 776584:d98a84c1d28f
user:      msaitoh <msaitoh%NetBSD.org@localhost>
date:      Tue Mar 18 08:09:46 2014 +0000

description:
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)

diffstat:

 sys/compat/netbsd32/netbsd32.h        |  12 ++++++-
 sys/compat/netbsd32/netbsd32_netbsd.c |  56 +++++++++++++++++++++++++++++++++-
 sys/uvm/uvm_swap.c                    |   8 +---
 sys/uvm/uvm_swap.h                    |   4 +-
 4 files changed, 71 insertions(+), 9 deletions(-)

diffs (180 lines):

diff -r 6be3f6ed3997 -r d98a84c1d28f sys/compat/netbsd32/netbsd32.h
--- a/sys/compat/netbsd32/netbsd32.h    Tue Mar 18 08:01:34 2014 +0000
+++ b/sys/compat/netbsd32/netbsd32.h    Tue Mar 18 08:09:46 2014 +0000
@@ -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 @@
        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 {
diff -r 6be3f6ed3997 -r d98a84c1d28f sys/compat/netbsd32/netbsd32_netbsd.c
--- a/sys/compat/netbsd32/netbsd32_netbsd.c     Tue Mar 18 08:01:34 2014 +0000
+++ b/sys/compat/netbsd32/netbsd32_netbsd.c     Tue Mar 18 08:09:46 2014 +0000
@@ -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 @@
 #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 @@
 #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 @@
        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 @@
        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));
 }
 
diff -r 6be3f6ed3997 -r d98a84c1d28f sys/uvm/uvm_swap.c
--- a/sys/uvm/uvm_swap.c        Tue Mar 18 08:01:34 2014 +0000
+++ b/sys/uvm/uvm_swap.c        Tue Mar 18 08:09:46 2014 +0000
@@ -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 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 @@
  * 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;
diff -r 6be3f6ed3997 -r d98a84c1d28f sys/uvm/uvm_swap.h
--- a/sys/uvm/uvm_swap.h        Tue Mar 18 08:01:34 2014 +0000
+++ b/sys/uvm/uvm_swap.h        Tue Mar 18 08:09:46 2014 +0000
@@ -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 @@
 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 */



Home | Main Index | Thread Index | Old Index