Module Name: src Committed By: pgoyette Date: Wed Mar 21 02:01:34 UTC 2018
Modified Files: src/sys/compat/common [pgoyette-compat]: rndpseudo_50.c src/sys/compat/netbsd32 [pgoyette-compat]: files.netbsd32 netbsd32_mod.c src/sys/compat/sys [pgoyette-compat]: rnd.h src/sys/kern [pgoyette-compat]: kern_rndq.c src/sys/modules/compat_netbsd32 [pgoyette-compat]: Makefile src/sys/sys [pgoyette-compat]: rnd.h Added Files: src/sys/compat/netbsd32 [pgoyette-compat]: netbsd32_rndpseudo_50.c Log Message: Split compat/rndpseudo_50.c into two pieces, one for native compat and a second piece for compat32. Update both modules accordingly. To generate a diff of this commit: cvs rdiff -u -r1.2 -r1.2.38.1 src/sys/compat/common/rndpseudo_50.c cvs rdiff -u -r1.39 -r1.39.14.1 src/sys/compat/netbsd32/files.netbsd32 cvs rdiff -u -r1.13.16.1 -r1.13.16.2 src/sys/compat/netbsd32/netbsd32_mod.c cvs rdiff -u -r0 -r1.1.2.1 src/sys/compat/netbsd32/netbsd32_rndpseudo_50.c cvs rdiff -u -r1.4 -r1.4.16.1 src/sys/compat/sys/rnd.h cvs rdiff -u -r1.89 -r1.89.16.1 src/sys/kern/kern_rndq.c cvs rdiff -u -r1.20 -r1.20.12.1 src/sys/modules/compat_netbsd32/Makefile cvs rdiff -u -r1.49 -r1.49.16.1 src/sys/sys/rnd.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/rndpseudo_50.c diff -u src/sys/compat/common/rndpseudo_50.c:1.2 src/sys/compat/common/rndpseudo_50.c:1.2.38.1 --- src/sys/compat/common/rndpseudo_50.c:1.2 Fri Aug 3 07:51:21 2012 +++ src/sys/compat/common/rndpseudo_50.c Wed Mar 21 02:01:34 2018 @@ -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 @@ rndsource_to_rndsource50(rndsource_t *r, 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 @@ compat_50_rnd_ioctl(struct file *fp, u_l 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 @@ compat_50_rnd_ioctl(struct file *fp, u_l 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; } Index: src/sys/compat/netbsd32/files.netbsd32 diff -u src/sys/compat/netbsd32/files.netbsd32:1.39 src/sys/compat/netbsd32/files.netbsd32:1.39.14.1 --- src/sys/compat/netbsd32/files.netbsd32:1.39 Wed Oct 19 09:44:01 2016 +++ src/sys/compat/netbsd32/files.netbsd32 Wed Mar 21 02:01:34 2018 @@ -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_20. 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 Index: src/sys/compat/netbsd32/netbsd32_mod.c diff -u src/sys/compat/netbsd32/netbsd32_mod.c:1.13.16.1 src/sys/compat/netbsd32/netbsd32_mod.c:1.13.16.2 --- src/sys/compat/netbsd32/netbsd32_mod.c:1.13.16.1 Sun Mar 11 23:50:18 2018 +++ src/sys/compat/netbsd32/netbsd32_mod.c Wed Mar 21 02:01:34 2018 @@ -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 @@ __KERNEL_RCSID(0, "$NetBSD: netbsd32_mod #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 @@ compat_netbsd32_modcmd(modcmd_t cmd, voi 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) Index: src/sys/compat/sys/rnd.h diff -u src/sys/compat/sys/rnd.h:1.4 src/sys/compat/sys/rnd.h:1.4.16.1 --- src/sys/compat/sys/rnd.h:1.4 Tue Apr 14 12:19:57 2015 +++ src/sys/compat/sys/rnd.h Wed Mar 21 02:01:34 2018 @@ -1,4 +1,4 @@ -/* $NetBSD: rnd.h,v 1.4 2015/04/14 12:19:57 riastradh Exp $ */ +/* $NetBSD: rnd.h,v 1.4.16.1 2018/03/21 02:01:34 pgoyette Exp $ */ /*- * Copyright (c) 1997,2011 The NetBSD Foundation, Inc. @@ -137,6 +137,7 @@ typedef struct { */ #ifdef _KERNEL int compat_50_rnd_ioctl(struct file *, u_long, void *); +int compat32_50_rnd_ioctl(struct file *, u_long, void *); #endif #define RNDGETSRCNUM50 _IOWR('R', 102, rndstat50_t) Index: src/sys/kern/kern_rndq.c diff -u src/sys/kern/kern_rndq.c:1.89 src/sys/kern/kern_rndq.c:1.89.16.1 --- src/sys/kern/kern_rndq.c:1.89 Sat May 21 15:27:15 2016 +++ src/sys/kern/kern_rndq.c Wed Mar 21 02:01:34 2018 @@ -1,4 +1,4 @@ -/* $NetBSD: kern_rndq.c,v 1.89 2016/05/21 15:27:15 riastradh Exp $ */ +/* $NetBSD: kern_rndq.c,v 1.89.16.1 2018/03/21 02:01:34 pgoyette Exp $ */ /*- * Copyright (c) 1997-2013 The NetBSD Foundation, Inc. @@ -32,7 +32,7 @@ */ #include <sys/cdefs.h> -__KERNEL_RCSID(0, "$NetBSD: kern_rndq.c,v 1.89 2016/05/21 15:27:15 riastradh Exp $"); +__KERNEL_RCSID(0, "$NetBSD: kern_rndq.c,v 1.89.16.1 2018/03/21 02:01:34 pgoyette Exp $"); #include <sys/param.h> #include <sys/atomic.h> @@ -51,6 +51,7 @@ __KERNEL_RCSID(0, "$NetBSD: kern_rndq.c, #include <sys/rndsink.h> #include <sys/rndsource.h> #include <sys/rngtest.h> +#include <sys/file.h> #include <sys/systm.h> #include <dev/rnd_private.h> @@ -176,6 +177,11 @@ static uint8_t rnd_testbits[sizeof(rnd_ static rndsave_t *boot_rsp; +int (*vec_compat_50_rnd_ioctl)(struct file *, u_long, void *) = + (void *)enosys; +int (*vec_compat32_50_rnd_ioctl)(struct file *, u_long, void *) = + (void *)enosys; + static inline void rnd_printf(const char *fmt, ...) { @@ -1481,11 +1487,14 @@ rnd_system_ioctl(struct file *fp, u_long break; default: -#ifdef COMPAT_50 - return compat_50_rnd_ioctl(fp, cmd, addr); -#else - return ENOTTY; + ret = (*vec_compat_50_rnd_ioctl)(fp, cmd, addr); +#if defined(_LP64) + if (ret == ENOSYS) + ret = (*vec_compat32_50_rnd_ioctl)(fp, cmd, addr); #endif + if (ret == ENOSYS) + ret = ENOTTY; + return ret; } switch (cmd) { Index: src/sys/modules/compat_netbsd32/Makefile diff -u src/sys/modules/compat_netbsd32/Makefile:1.20 src/sys/modules/compat_netbsd32/Makefile:1.20.12.1 --- src/sys/modules/compat_netbsd32/Makefile:1.20 Thu Jan 26 01:32:34 2017 +++ src/sys/modules/compat_netbsd32/Makefile Wed Mar 21 02:01:34 2018 @@ -1,4 +1,4 @@ -# $NetBSD: Makefile,v 1.20 2017/01/26 01:32:34 christos Exp $ +# $NetBSD: Makefile,v 1.20.12.1 2018/03/21 02:01:34 pgoyette Exp $ .include "../Makefile.inc" .include "../Makefile.assym" @@ -39,6 +39,7 @@ SRCS+= netbsd32_sem.c netbsd32_signal.c SRCS+= netbsd32_socket.c netbsd32_syscalls.c SRCS+= netbsd32_sysctl.c netbsd32_sysent.c SRCS+= netbsd32_time.c netbsd32_wait.c +SRCS+= netbsd32_rndpseudo_50.c SRCS+= netbsd32_mod.c netbsd32_module.c .if ${MACHINE_CPU} != "mips" && ${MACHINE_CPU} != "powerpc" Index: src/sys/sys/rnd.h diff -u src/sys/sys/rnd.h:1.49 src/sys/sys/rnd.h:1.49.16.1 --- src/sys/sys/rnd.h:1.49 Tue Apr 14 12:51:30 2015 +++ src/sys/sys/rnd.h Wed Mar 21 02:01:34 2018 @@ -1,4 +1,4 @@ -/* $NetBSD: rnd.h,v 1.49 2015/04/14 12:51:30 riastradh Exp $ */ +/* $NetBSD: rnd.h,v 1.49.16.1 2018/03/21 02:01:34 pgoyette Exp $ */ /*- * Copyright (c) 1997 The NetBSD Foundation, Inc. @@ -49,6 +49,9 @@ int rnd_system_ioctl(struct file *, u_l extern int rnd_initial_entropy; +extern int (*vec_compat_50_rnd_ioctl)(struct file *, u_long, void *); +extern int (*vec_compat32_50_rnd_ioctl)(struct file *, u_long, void *); + #endif /* _KERNEL */ #endif /* !_SYS_RND_H_ */ Added files: Index: src/sys/compat/netbsd32/netbsd32_rndpseudo_50.c diff -u /dev/null src/sys/compat/netbsd32/netbsd32_rndpseudo_50.c:1.1.2.1 --- /dev/null Wed Mar 21 02:01:34 2018 +++ src/sys/compat/netbsd32/netbsd32_rndpseudo_50.c Wed Mar 21 02:01:34 2018 @@ -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 <explo...@flame.org> 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; +}