Source-Changes-HG archive

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

[src/pgoyette-compat]: src Initial pass at a compat_30 module.



details:   https://anonhg.NetBSD.org/src/rev/2275f4557ec7
branches:  pgoyette-compat
changeset: 321114:2275f4557ec7
user:      pgoyette <pgoyette%NetBSD.org@localhost>
date:      Wed Mar 28 04:18:24 2018 +0000

description:
Initial pass at a compat_30 module.

Still needs some work for dev/vnd and various dev/usb/*

diffstat:

 distrib/sets/lists/modules/mi        |    4 +-
 sys/compat/common/Makefile.sysio     |    4 +-
 sys/compat/common/bio_30.c           |  103 ++++++++++++++++++++++++++++++++
 sys/compat/common/compat_30_mod.c    |  112 +++++++++++++++++++++++++++++++++++
 sys/compat/common/compat_mod.c       |   19 +-----
 sys/compat/common/compat_mod.h       |   15 ++++-
 sys/compat/common/files.common       |    4 +-
 sys/compat/common/kern_time_30.c     |   40 +++++++++--
 sys/compat/common/uipc_syscalls_30.c |   30 ++++++++-
 sys/compat/common/vfs_syscalls_30.c  |   62 +++++++++++++++---
 sys/dev/bio.c                        |   49 ++------------
 sys/kern/compat_stub.c               |    9 ++-
 sys/modules/Makefile                 |    4 +-
 sys/modules/compat_30/Makefile       |   15 ++++
 sys/sys/compat_stub.h                |   12 ++-
 15 files changed, 390 insertions(+), 92 deletions(-)

diffs (truncated from 825 to 300 lines):

diff -r 236c2dda7ce0 -r 2275f4557ec7 distrib/sets/lists/modules/mi
--- a/distrib/sets/lists/modules/mi     Wed Mar 28 03:41:26 2018 +0000
+++ b/distrib/sets/lists/modules/mi     Wed Mar 28 04:18:24 2018 +0000
@@ -1,4 +1,4 @@
-# $NetBSD: mi,v 1.114.2.7 2018/03/27 07:29:43 pgoyette Exp $
+# $NetBSD: mi,v 1.114.2.8 2018/03/28 04:18:24 pgoyette Exp $
 #
 # Note: don't delete entries from here - mark them as "obsolete" instead.
 #
@@ -68,6 +68,8 @@
 ./@MODULEDIR@/coda5/coda5.kmod                 base-kernel-modules     kmod
 ./@MODULEDIR@/compat                           base-kernel-modules     kmod
 ./@MODULEDIR@/compat/compat.kmod               base-kernel-modules     kmod
+./@MODULEDIR@/compat_30                                base-kernel-modules     kmod
+./@MODULEDIR@/compat_30/compat_30.kmod         base-kernel-modules     kmod
 ./@MODULEDIR@/compat_40                                base-kernel-modules     kmod
 ./@MODULEDIR@/compat_40/compat_40.kmod         base-kernel-modules     kmod
 ./@MODULEDIR@/compat_50                                base-kernel-modules     kmod
diff -r 236c2dda7ce0 -r 2275f4557ec7 sys/compat/common/Makefile.sysio
--- a/sys/compat/common/Makefile.sysio  Wed Mar 28 03:41:26 2018 +0000
+++ b/sys/compat/common/Makefile.sysio  Wed Mar 28 04:18:24 2018 +0000
@@ -1,4 +1,4 @@
-#      $NetBSD: Makefile.sysio,v 1.7.18.16 2018/03/25 21:27:51 pgoyette Exp $
+#      $NetBSD: Makefile.sysio,v 1.7.18.17 2018/03/28 04:18:24 pgoyette Exp $
 
 # Sources for syscall and ioctl compatibility across the versions.
 
@@ -28,7 +28,7 @@
 SRCS+= vfs_syscalls_20.c
 
 # Compatibility code for NetBSD 3.0
-SRCS+= kern_time_30.c vfs_syscalls_30.c uipc_syscalls_30.c
+SRCS+= kern_time_30.c vfs_syscalls_30.c uipc_syscalls_30.c bio_30.c
 
 # Compatibility code for NetBSD 4.0
 SRCS+= vfs_syscalls_40.c uipc_syscalls_40.c
diff -r 236c2dda7ce0 -r 2275f4557ec7 sys/compat/common/bio_30.c
--- /dev/null   Thu Jan 01 00:00:00 1970 +0000
+++ b/sys/compat/common/bio_30.c        Wed Mar 28 04:18:24 2018 +0000
@@ -0,0 +1,103 @@
+/*     $NetBSD: bio_30.c,v 1.1.2.1 2018/03/28 04:18:24 pgoyette Exp $ */
+/*     $OpenBSD: bio.c,v 1.9 2007/03/20 02:35:55 marco Exp $   */
+
+/*
+ * Copyright (c) 2002 Niklas Hallqvist.  All rights reserved.
+ *
+ * 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 AUTHOR ``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 AUTHOR 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: bio_30.c,v 1.1.2.1 2018/03/28 04:18:24 pgoyette Exp $");
+
+#include <sys/param.h>
+#include <sys/conf.h>
+#include <sys/device.h>
+#include <sys/event.h>
+#include <sys/ioctl.h>
+#include <sys/malloc.h>
+#include <sys/queue.h>
+#include <sys/systm.h>
+#include <sys/mutex.h>
+#include <sys/proc.h>
+#include <sys/kauth.h>
+#include <sys/compat_stub.h>
+
+#include <dev/biovar.h>
+#include <dev/sysmon/sysmonvar.h>
+
+#include <compat/common/compat_mod.h>
+
+static int
+compat_30_bio(void *cookie, u_long cmd, void *addr,
+    int (*delegate)(void *, u_long, void *))
+{
+       int error;
+
+       switch (cmd) {
+       case OBIOCDISK: {
+               struct bioc_disk *bd =
+                   malloc(sizeof(*bd), M_DEVBUF, M_WAITOK|M_ZERO);
+
+               (void)memcpy(bd, addr, sizeof(struct obioc_disk));
+               error = (*delegate)(cookie, BIOCDISK, bd);
+               if (error) {
+                       free(bd, M_DEVBUF);
+                       return error;
+               }
+
+               (void)memcpy(addr, bd, sizeof(struct obioc_disk));
+               free(bd, M_DEVBUF);
+               return 0;
+       }
+       case OBIOCVOL: {
+               struct bioc_vol *bv =
+                   malloc(sizeof(*bv), M_DEVBUF, M_WAITOK|M_ZERO);
+
+               (void)memcpy(bv, addr, sizeof(struct obioc_vol));
+               error = (*delegate)(cookie, BIOCVOL, bv);
+               if (error) {
+                       free(bv, M_DEVBUF);
+                       return error;
+               }
+
+               (void)memcpy(addr, bv, sizeof(struct obioc_vol));
+               free(bv, M_DEVBUF);
+               return 0;
+       }
+       default:
+               return ENOSYS;
+       }
+}
+
+void
+bio_30_init(void)
+{
+
+       compat_bio_30 = compat_30_bio;
+}
+
+void
+bio_30_fini(void)
+{
+
+       compat_bio_30 = (void *)enosys;
+}
diff -r 236c2dda7ce0 -r 2275f4557ec7 sys/compat/common/compat_30_mod.c
--- /dev/null   Thu Jan 01 00:00:00 1970 +0000
+++ b/sys/compat/common/compat_30_mod.c Wed Mar 28 04:18:24 2018 +0000
@@ -0,0 +1,112 @@
+/*     $NetBSD: compat_30_mod.c,v 1.1.2.1 2018/03/28 04:18:24 pgoyette Exp $   */
+
+/*-
+ * Copyright (c) 2018 The NetBSD Foundation, Inc.
+ * All rights reserved.
+ *
+ * This code is derived from software developed for The NetBSD Foundation
+ * by Paul Goyette
+ *
+ * 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.
+ */
+
+/*
+ * Linkage for the compat module: spaghetti.
+ */
+
+#include <sys/cdefs.h>
+__KERNEL_RCSID(0, "$NetBSD: compat_30_mod.c,v 1.1.2.1 2018/03/28 04:18:24 pgoyette Exp $");
+
+#include <sys/systm.h>
+#include <sys/module.h>
+#include <sys/sysctl.h>
+#include <sys/syscall.h>
+#include <sys/syscallvar.h>
+#include <sys/syscallargs.h>
+
+#include <dev/biovar.h>
+
+#include <compat/common/compat_util.h>
+#include <compat/common/compat_mod.h>
+
+int
+compat_30_init(void)
+{
+       int error = 0;
+
+       error = vfs_syscalls_30_init();
+       if (error != 0)
+               return error;
+
+       error = kern_time_30_init();
+       if (error != 0) {
+               vfs_syscalls_30_fini();
+               return error;
+       }
+       bio_30_init();
+
+       return error;
+}
+
+int
+compat_30_fini(void)
+{
+       int error = 0;
+
+       bio_30_fini();
+
+       error = kern_time_30_fini();
+       if (error != 0) {
+               bio_30_init();
+               return error;
+       }
+
+       error = vfs_syscalls_30_fini();
+       if (error != 0) {
+               bio_30_init();
+               kern_time_30_init();
+               return error;
+       }
+
+       return error;
+}
+
+#ifdef _MODULE
+
+#define REQD_30        "compat_80,compat_70,compat_60,compat_50,compat_40"
+
+MODULE(MODULE_CLASS_EXEC, compat_30, REQD_30);
+
+static int
+compat_30_modcmd(modcmd_t cmd, void *arg)
+{
+
+       switch (cmd) {
+       case MODULE_CMD_INIT:
+               return compat_30_init();
+       case MODULE_CMD_FINI:
+               return compat_30_init();
+       default:
+               return ENOTTY;
+       }
+}
+#endif
diff -r 236c2dda7ce0 -r 2275f4557ec7 sys/compat/common/compat_mod.c
--- a/sys/compat/common/compat_mod.c    Wed Mar 28 03:41:26 2018 +0000
+++ b/sys/compat/common/compat_mod.c    Wed Mar 28 04:18:24 2018 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: compat_mod.c,v 1.24.14.21 2018/03/27 07:29:43 pgoyette Exp $   */
+/*     $NetBSD: compat_mod.c,v 1.24.14.22 2018/03/28 04:18:24 pgoyette 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.14.21 2018/03/27 07:29:43 pgoyette Exp $");
+__KERNEL_RCSID(0, "$NetBSD: compat_mod.c,v 1.24.14.22 2018/03/28 04:18:24 pgoyette Exp $");
 
 #ifdef _KERNEL_OPT
 #include "opt_compat_netbsd.h"
@@ -172,19 +172,6 @@
        { SYS_compat_20_getfsstat, 0, (sy_call_t *)compat_20_sys_getfsstat },
        { SYS_compat_20_statfs, 0, (sy_call_t *)compat_20_sys_statfs },
 #endif
-
-#if defined(COMPAT_30)
-       { SYS_compat_30___fhstat30, 0, (sy_call_t *)compat_30_sys___fhstat30 },
-       { SYS_compat_30___fstat13, 0, (sy_call_t *)compat_30_sys___fstat13 },
-       { SYS_compat_30___lstat13, 0, (sy_call_t *)compat_30_sys___lstat13 },
-       { SYS_compat_30___stat13, 0, (sy_call_t *)compat_30_sys___stat13 },
-       { SYS_compat_30_fhopen, 0, (sy_call_t *)compat_30_sys_fhopen },
-       { SYS_compat_30_fhstat, 0, (sy_call_t *)compat_30_sys_fhstat },
-       { SYS_compat_30_fhstatvfs1, 0, (sy_call_t *)compat_30_sys_fhstatvfs1 },
-       { SYS_compat_30_getdents, 0, (sy_call_t *)compat_30_sys_getdents },
-       { SYS_compat_30_getfh, 0, (sy_call_t *)compat_30_sys_getfh },
-       { SYS_compat_30_socket, 0, (sy_call_t *)compat_30_sys_socket },
-#endif
        { 0, 0, NULL },
 };
 
@@ -204,10 +191,10 @@
 #ifdef COMPAT_40
        { compat_40_init, compat_40_fini },



Home | Main Index | Thread Index | Old Index