Source-Changes-HG archive

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

[src/pgoyette-compat]: src/sys Split compat/rndpseudo_50.c into two pieces, o...



details:   https://anonhg.NetBSD.org/src/rev/734dbf9db6f4
branches:  pgoyette-compat
changeset: 321074:734dbf9db6f4
user:      pgoyette <pgoyette%NetBSD.org@localhost>
date:      Wed Mar 21 02:01:34 2018 +0000

description:
Split compat/rndpseudo_50.c into two pieces, one for native compat and
a second piece for compat32.  Update both modules accordingly.

diffstat:

 sys/compat/common/rndpseudo_50.c            |   68 +--------------
 sys/compat/netbsd32/files.netbsd32          |    3 +-
 sys/compat/netbsd32/netbsd32_mod.c          |   12 ++-
 sys/compat/netbsd32/netbsd32_rndpseudo_50.c |  124 ++++++++++++++++++++++++++++
 sys/compat/sys/rnd.h                        |    3 +-
 sys/kern/kern_rndq.c                        |   21 +++-
 sys/modules/compat_netbsd32/Makefile        |    3 +-
 sys/sys/rnd.h                               |    5 +-
 8 files changed, 160 insertions(+), 79 deletions(-)

diffs (truncated from 408 to 300 lines):

diff -r 1a720fc52300 -r 734dbf9db6f4 sys/compat/common/rndpseudo_50.c
--- a/sys/compat/common/rndpseudo_50.c  Tue Mar 20 08:11:25 2018 +0000
+++ b/sys/compat/common/rndpseudo_50.c  Wed Mar 21 02:01:34 2018 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: rndpseudo_50.c,v 1.2 2012/08/03 07:51:21 matt Exp $    */
+/*     $NetBSD: rndpseudo_50.c,v 1.2.38.1 2018/03/21 02:01:34 pgoyette Exp $   */
 
 /*-
  * Copyright (c) 1997-2011 The NetBSD Foundation, Inc.
@@ -30,11 +30,10 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: rndpseudo_50.c,v 1.2 2012/08/03 07:51:21 matt Exp $");
+__KERNEL_RCSID(0, "$NetBSD: rndpseudo_50.c,v 1.2.38.1 2018/03/21 02:01:34 pgoyette Exp $");
 
 #if defined(_KERNEL_OPT)
 #include "opt_compat_netbsd.h"
-#include "opt_compat_netbsd32.h"
 #endif
 
 #include <sys/param.h>
@@ -57,22 +56,6 @@
        r50->flags = r->flags;
 }
 
-#if defined(COMPAT_NETBSD32) && defined(_LP64)
-/*
- * Convert from rndsource_t to rndsource50_32_t, for the results from
- * RNDGETNUM50_32 and RNDGETNAME50_32.
- */
-static void
-rndsource_to_rndsource50_32(rndsource_t *r, rndsource50_32_t *r50_32)
-{
-       memset(r50_32, 0, sizeof(*r50_32));
-       strlcpy(r50_32->name, r->name, sizeof(r50_32->name));
-       r50_32->total = r->total;
-       r50_32->type = r->type;
-       r50_32->flags = r->flags;
-}
-#endif /* COMPAT_NETBSD32 */
-
 /*
  * COMPAT_50 handling for rnd_ioctl.  This is called from rnd_ioctl.
  *
@@ -110,33 +93,6 @@
                break;
        }
 
-#if defined(COMPAT_NETBSD32) && defined(_LP64)
-       case RNDGETSRCNUM50_32:
-       {
-               rndstat_t rstbuf = {.start = 0};
-               rndstat50_32_t *rst50_32 = (rndstat50_32_t *)addr;
-               int count;
-
-               if (rst50_32->count > RND_MAXSTATCOUNT50)
-                       return (EINVAL);
-
-               rstbuf.start = rst50_32->start;
-               rstbuf.count = rst50_32->count;
-
-               ret = (fp->f_ops->fo_ioctl)(fp, RNDGETSRCNUM, &rstbuf);
-               if (ret != 0)
-                       return ret;
-
-               for (count = 0; count < rst50_32->count; count++) {
-                       rndsource_to_rndsource50_32(&rstbuf.source[count],
-                           &rst50_32->source[count]);
-               }
-               rst50_32->count = rstbuf.count;
-
-               break;
-       }
-#endif /* COMPAT_NETBSD32 */
-
        case RNDGETSRCNAME50:
        {
                rndstat_name_t rstnmbuf = {.name[0] = 0};
@@ -154,26 +110,6 @@
                break;
        }
 
-#if defined(COMPAT_NETBSD32) && defined(_LP64)
-       case RNDGETSRCNAME50_32:
-       {
-               rndstat_name_t rstnmbuf = {.name[0] = 0};
-               rndstat_name50_32_t *rstnm50_32;
-               rstnm50_32 = (rndstat_name50_32_t *)addr;
-
-               strlcpy(rstnmbuf.name, rstnm50_32->name, sizeof(rstnmbuf.name));
-
-               ret = (fp->f_ops->fo_ioctl)(fp, RNDGETSRCNAME, &rstnmbuf);
-               if (ret != 0)
-                       return ret;
-
-               rndsource_to_rndsource50_32(&rstnmbuf.source,
-                   &rstnm50_32->source);
-
-               break;
-       }
-#endif
-
        default:
                return ENOTTY;
        }
diff -r 1a720fc52300 -r 734dbf9db6f4 sys/compat/netbsd32/files.netbsd32
--- a/sys/compat/netbsd32/files.netbsd32        Tue Mar 20 08:11:25 2018 +0000
+++ b/sys/compat/netbsd32/files.netbsd32        Wed Mar 21 02:01:34 2018 +0000
@@ -1,4 +1,4 @@
-#      $NetBSD: files.netbsd32,v 1.39 2016/10/19 09:44:01 skrll Exp $
+#      $NetBSD: files.netbsd32,v 1.39.14.1 2018/03/21 02:01:34 pgoyette Exp $
 #
 # config file description for machine-independent netbsd32 compat code.
 # included by ports that need it.
@@ -41,6 +41,7 @@
 file   compat/netbsd32/netbsd32_compat_30.c    compat_netbsd32 & compat_30
 file   compat/netbsd32/netbsd32_compat_43.c    compat_netbsd32 & (compat_43 | compat_sunos | compat_linux32)
 file   compat/netbsd32/netbsd32_compat_50.c    compat_netbsd32 & compat_50
+file   compat/netbsd32/netbsd32_rndpseudo_50.c compat_netbsd32 & compat_50
 file   compat/netbsd32/netbsd32_compat_50_sysv.c compat_netbsd32 & compat_50 &
                                                (sysvmsg | sysvsem | sysvshm)
 file   compat/netbsd32/netbsd32_compat_60.c    compat_netbsd32 & compat_60
diff -r 1a720fc52300 -r 734dbf9db6f4 sys/compat/netbsd32/netbsd32_mod.c
--- a/sys/compat/netbsd32/netbsd32_mod.c        Tue Mar 20 08:11:25 2018 +0000
+++ b/sys/compat/netbsd32/netbsd32_mod.c        Wed Mar 21 02:01:34 2018 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: netbsd32_mod.c,v 1.13.16.1 2018/03/11 23:50:18 pgoyette Exp $  */
+/*     $NetBSD: netbsd32_mod.c,v 1.13.16.2 2018/03/21 02:01:34 pgoyette Exp $  */
 
 /*-
  * Copyright (c) 2008 The NetBSD Foundation, Inc.
@@ -30,7 +30,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: netbsd32_mod.c,v 1.13.16.1 2018/03/11 23:50:18 pgoyette Exp $");
+__KERNEL_RCSID(0, "$NetBSD: netbsd32_mod.c,v 1.13.16.2 2018/03/21 02:01:34 pgoyette Exp $");
 
 #ifdef _KERNEL_OPT
 #include "opt_execfmt.h"
@@ -44,9 +44,11 @@
 #include <sys/module.h>
 #include <sys/exec.h>
 #include <sys/exec_elf.h>
+#include <sys/rnd.h>
 
 #include <compat/netbsd32/netbsd32_sysctl.h>
 #include <compat/netbsd32/netbsd32_exec.h>
+#include <compat/sys/rnd.h>
 
 # define       DEPS1   "compat,ksem"
 
@@ -106,11 +108,15 @@
                netbsd32_sysctl_init();
                error = exec_add(netbsd32_execsw,
                    __arraycount(netbsd32_execsw));
-               if (error != 0)
+               vec_compat32_50_rnd_ioctl = compat32_50_rnd_ioctl;
+               if (error != 0) {
+                       vec_compat32_50_rnd_ioctl = (void *)enosys;
                        netbsd32_sysctl_fini();
+               }
                return error;
 
        case MODULE_CMD_FINI:
+               vec_compat32_50_rnd_ioctl = (void *)enosys;
                error = exec_remove(netbsd32_execsw,
                    __arraycount(netbsd32_execsw));
                if (error == 0)
diff -r 1a720fc52300 -r 734dbf9db6f4 sys/compat/netbsd32/netbsd32_rndpseudo_50.c
--- /dev/null   Thu Jan 01 00:00:00 1970 +0000
+++ b/sys/compat/netbsd32/netbsd32_rndpseudo_50.c       Wed Mar 21 02:01:34 2018 +0000
@@ -0,0 +1,124 @@
+/*     $NetBSD: netbsd32_rndpseudo_50.c,v 1.1.2.1 2018/03/21 02:01:34 pgoyette Exp $   */
+
+/*-
+ * Copyright (c) 1997-2011 The NetBSD Foundation, Inc.
+ * All rights reserved.
+ *
+ * This code is derived from software contributed to The NetBSD Foundation
+ * by Michael Graff <explorer%flame.org@localhost> and Thor Lancelot Simon.
+ *
+ * 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: netbsd32_rndpseudo_50.c,v 1.1.2.1 2018/03/21 02:01:34 pgoyette Exp $");
+
+#if defined(_KERNEL_OPT)
+#include "opt_compat_netbsd.h"
+#include "opt_compat_netbsd32.h"
+#endif
+
+#include <sys/param.h>
+#include <sys/file.h>
+
+#include <sys/rnd.h>
+#include <compat/sys/rnd.h>
+
+/*
+ * Convert from rndsource_t to rndsource50_t, for the results from
+ * RNDGETNUM50 and RNDGETNAME50.
+ */
+
+/*
+ * Convert from rndsource_t to rndsource50_32_t, for the results from
+ * RNDGETNUM50_32 and RNDGETNAME50_32.
+ */
+static void
+rndsource_to_rndsource50_32(rndsource_t *r, rndsource50_32_t *r50_32)
+{
+       memset(r50_32, 0, sizeof(*r50_32));
+       strlcpy(r50_32->name, r->name, sizeof(r50_32->name));
+       r50_32->total = r->total;
+       r50_32->type = r->type;
+       r50_32->flags = r->flags;
+}
+
+/* 
+ * COMPAT32_50 handling for rnd_ioctl.  This is called from rnd_ioctl.
+ * 
+ * It also handles the case of (COMPAT_50 && COMPAT_NETBSD32).
+ */
+int
+compat32_50_rnd_ioctl(struct file *fp, u_long cmd, void *addr)
+{ 
+       int ret = 0;
+
+       switch (cmd) {
+       case RNDGETSRCNUM50_32:
+       {
+               rndstat_t rstbuf = {.start = 0};
+               rndstat50_32_t *rst50_32 = (rndstat50_32_t *)addr;
+               int count;
+
+               if (rst50_32->count > RND_MAXSTATCOUNT50)
+                       return (EINVAL);
+
+               rstbuf.start = rst50_32->start;
+               rstbuf.count = rst50_32->count;
+
+               ret = (fp->f_ops->fo_ioctl)(fp, RNDGETSRCNUM, &rstbuf);
+               if (ret != 0)
+                       return ret;
+
+               for (count = 0; count < rst50_32->count; count++) {
+                       rndsource_to_rndsource50_32(&rstbuf.source[count],
+                           &rst50_32->source[count]);
+               }
+               rst50_32->count = rstbuf.count;
+
+               break;
+       }
+
+       case RNDGETSRCNAME50_32:
+       {
+               rndstat_name_t rstnmbuf = {.name[0] = 0};
+               rndstat_name50_32_t *rstnm50_32;
+               rstnm50_32 = (rndstat_name50_32_t *)addr;
+
+               strlcpy(rstnmbuf.name, rstnm50_32->name, sizeof(rstnmbuf.name));
+
+               ret = (fp->f_ops->fo_ioctl)(fp, RNDGETSRCNAME, &rstnmbuf);
+               if (ret != 0)
+                       return ret;
+
+               rndsource_to_rndsource50_32(&rstnmbuf.source,
+                   &rstnm50_32->source);
+
+               break;
+       }
+
+       default:
+               return ENOTTY;
+       }
+
+       return ret;
+}
diff -r 1a720fc52300 -r 734dbf9db6f4 sys/compat/sys/rnd.h
--- a/sys/compat/sys/rnd.h      Tue Mar 20 08:11:25 2018 +0000



Home | Main Index | Thread Index | Old Index