Module Name:    src
Committed By:   pgoyette
Date:           Wed Mar 28 04:18:25 UTC 2018

Modified Files:
        src/distrib/sets/lists/modules [pgoyette-compat]: mi
        src/sys/compat/common [pgoyette-compat]: Makefile.sysio compat_mod.c
            compat_mod.h files.common kern_time_30.c uipc_syscalls_30.c
            vfs_syscalls_30.c
        src/sys/dev [pgoyette-compat]: bio.c
        src/sys/kern [pgoyette-compat]: compat_stub.c
        src/sys/modules [pgoyette-compat]: Makefile
        src/sys/sys [pgoyette-compat]: compat_stub.h
Added Files:
        src/sys/compat/common [pgoyette-compat]: bio_30.c compat_30_mod.c
        src/sys/modules/compat_30 [pgoyette-compat]: Makefile

Log Message:
Initial pass at a compat_30 module.

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


To generate a diff of this commit:
cvs rdiff -u -r1.114.2.7 -r1.114.2.8 src/distrib/sets/lists/modules/mi
cvs rdiff -u -r1.7.18.16 -r1.7.18.17 src/sys/compat/common/Makefile.sysio
cvs rdiff -u -r0 -r1.1.2.1 src/sys/compat/common/bio_30.c \
    src/sys/compat/common/compat_30_mod.c
cvs rdiff -u -r1.24.14.21 -r1.24.14.22 src/sys/compat/common/compat_mod.c
cvs rdiff -u -r1.1.42.9 -r1.1.42.10 src/sys/compat/common/compat_mod.h
cvs rdiff -u -r1.1.2.19 -r1.1.2.20 src/sys/compat/common/files.common
cvs rdiff -u -r1.5 -r1.5.14.1 src/sys/compat/common/kern_time_30.c
cvs rdiff -u -r1.3 -r1.3.96.1 src/sys/compat/common/uipc_syscalls_30.c
cvs rdiff -u -r1.36 -r1.36.18.1 src/sys/compat/common/vfs_syscalls_30.c
cvs rdiff -u -r1.13 -r1.13.16.1 src/sys/dev/bio.c
cvs rdiff -u -r1.1.2.8 -r1.1.2.9 src/sys/kern/compat_stub.c
cvs rdiff -u -r1.202.2.11 -r1.202.2.12 src/sys/modules/Makefile
cvs rdiff -u -r0 -r1.1.2.1 src/sys/modules/compat_30/Makefile
cvs rdiff -u -r1.1.2.8 -r1.1.2.9 src/sys/sys/compat_stub.h

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/distrib/sets/lists/modules/mi
diff -u src/distrib/sets/lists/modules/mi:1.114.2.7 src/distrib/sets/lists/modules/mi:1.114.2.8
--- src/distrib/sets/lists/modules/mi:1.114.2.7	Tue Mar 27 07:29:43 2018
+++ src/distrib/sets/lists/modules/mi	Wed Mar 28 04:18:24 2018
@@ -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

Index: src/sys/compat/common/Makefile.sysio
diff -u src/sys/compat/common/Makefile.sysio:1.7.18.16 src/sys/compat/common/Makefile.sysio:1.7.18.17
--- src/sys/compat/common/Makefile.sysio:1.7.18.16	Sun Mar 25 21:27:51 2018
+++ src/sys/compat/common/Makefile.sysio	Wed Mar 28 04:18:24 2018
@@ -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+=	rtsock_14.c
 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

Index: src/sys/compat/common/compat_mod.c
diff -u src/sys/compat/common/compat_mod.c:1.24.14.21 src/sys/compat/common/compat_mod.c:1.24.14.22
--- src/sys/compat/common/compat_mod.c:1.24.14.21	Tue Mar 27 07:29:43 2018
+++ src/sys/compat/common/compat_mod.c	Wed Mar 28 04:18:24 2018
@@ -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 @@ static const struct syscall_package comp
 	{ 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 @@ struct compat_init_fini {
 #ifdef COMPAT_40
 	{ compat_40_init, compat_40_fini },
 #endif
-#if 0	/* NOT YET */
 #ifdef COMPAT_30
 	{ compat_30_init, compat_30_fini },
 #endif
+#if 0	/* NOT YET */
 #ifdef COMPAT_20
 	{ compat_20_init, compat_20_fini },
 #endif

Index: src/sys/compat/common/compat_mod.h
diff -u src/sys/compat/common/compat_mod.h:1.1.42.9 src/sys/compat/common/compat_mod.h:1.1.42.10
--- src/sys/compat/common/compat_mod.h:1.1.42.9	Tue Mar 27 07:29:44 2018
+++ src/sys/compat/common/compat_mod.h	Wed Mar 28 04:18:24 2018
@@ -1,4 +1,4 @@
-/*	$NetBSD: compat_mod.h,v 1.1.42.9 2018/03/27 07:29:44 pgoyette Exp $	*/
+/*	$NetBSD: compat_mod.h,v 1.1.42.10 2018/03/28 04:18:24 pgoyette Exp $	*/
 
 /*-
  * Copyright (c) 2013 The NetBSD Foundation, Inc.
@@ -88,4 +88,17 @@ void sysmon_power_40_init(void);
 void sysmon_power_40_fini(void);
 #endif
 
+#ifdef COMPAT_30
+int compat_30_init(void);
+int compat_30_fini(void);
+int kern_time_30_init(void);
+int kern_time_30_fini(void);
+int vfs_syscalls_30_init(void);
+int vfs_syscalls_30_fini(void);
+int uipc_syscalls_30_init(void);
+int uipc_syscalls_30_fini(void);
+void bio_30_init(void);
+void bio_30_fini(void);
+#endif
+
 #endif /* !_COMPAT_MOD_H_ */

Index: src/sys/compat/common/files.common
diff -u src/sys/compat/common/files.common:1.1.2.19 src/sys/compat/common/files.common:1.1.2.20
--- src/sys/compat/common/files.common:1.1.2.19	Tue Mar 27 07:29:44 2018
+++ src/sys/compat/common/files.common	Wed Mar 28 04:18:24 2018
@@ -1,4 +1,4 @@
-#	$NetBSD: files.common,v 1.1.2.19 2018/03/27 07:29:44 pgoyette Exp $
+#	$NetBSD: files.common,v 1.1.2.20 2018/03/28 04:18:24 pgoyette Exp $
 
 #
 # Generic files, used by all compat options.
@@ -47,9 +47,11 @@ file	compat/common/kern_sig_16.c		compat
 file	compat/common/vfs_syscalls_20.c		compat_20
 
 # Compatibility code for NetBSD 3.0
+file	compat/common/compat_30_mod.c		compat_30
 file	compat/common/kern_time_30.c		compat_30
 file	compat/common/vfs_syscalls_30.c		compat_30
 file	compat/common/uipc_syscalls_30.c	compat_30
+file	compat/common/bio_30.c			compat_30
 
 # Compatibility code for NetBSD 4.0
 file	compat/common/compat_40_mod.c		compat_40

Index: src/sys/compat/common/kern_time_30.c
diff -u src/sys/compat/common/kern_time_30.c:1.5 src/sys/compat/common/kern_time_30.c:1.5.14.1
--- src/sys/compat/common/kern_time_30.c:1.5	Thu Nov  3 03:37:06 2016
+++ src/sys/compat/common/kern_time_30.c	Wed Mar 28 04:18:24 2018
@@ -1,4 +1,4 @@
-/*	$NetBSD: kern_time_30.c,v 1.5 2016/11/03 03:37:06 riastradh Exp $	*/
+/*	$NetBSD: kern_time_30.c,v 1.5.14.1 2018/03/28 04:18:24 pgoyette Exp $	*/
 
 /*-
  * Copyright (c) 2008 The NetBSD Foundation, Inc.
@@ -36,7 +36,7 @@
  * POSSIBILITY OF SUCH DAMAGE.
  */
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: kern_time_30.c,v 1.5 2016/11/03 03:37:06 riastradh Exp $");
+__KERNEL_RCSID(0, "$NetBSD: kern_time_30.c,v 1.5.14.1 2018/03/28 04:18:24 pgoyette Exp $");
 
 #ifdef _KERNEL_OPT
 #include "opt_ntp.h"
@@ -46,18 +46,26 @@ __KERNEL_RCSID(0, "$NetBSD: kern_time_30
 #include <sys/systm.h>
 #include <sys/time.h>
 #include <sys/timex.h>
+#include <sys/syscall.h>
+#include <sys/syscallvar.h>
+#include <sys/syscallargs.h>
+#include <sys/compat_stub.h>
 
+#include <compat/common/compat_mod.h>
 #include <compat/common/compat_util.h>
 #include <compat/sys/time.h>
 #include <compat/sys/timex.h>
 
-#include <sys/syscallargs.h>
+static const struct syscall_package kern_time_30_syscalls[] = {
+        { SYS_compat_30_ntp_gettime, 0,
+	    (sy_call_t *)compat_30_sys_ntp_gettime },
+	{ 0, 0, NULL }
+};
 
 int
 compat_30_sys_ntp_gettime(struct lwp *l,
     const struct compat_30_sys_ntp_gettime_args *uap, register_t *retval)
 {
-#ifdef NTP
 	/* {
 		syscallarg(struct ntptimeval30 *) ontvp;
 	} */
@@ -66,8 +74,11 @@ compat_30_sys_ntp_gettime(struct lwp *l,
 	struct timeval tv;
 	int error;
 
+	if (vec_ntp_gettime == NULL)
+		return ENOSYS;
+
 	if (SCARG(uap, ntvp)) {
-		ntp_gettime(&ntv);
+		(*vec_ntp_gettime)(&ntv);
 		TIMESPEC_TO_TIMEVAL(&tv, &ntv.time);
 		timeval_to_timeval50(&tv, &ntv30.time);
 		ntv30.maxerror = ntv.maxerror;
@@ -77,9 +88,20 @@ compat_30_sys_ntp_gettime(struct lwp *l,
 		if (error)
 			return error;
  	}
-	*retval = ntp_timestatus();
+	*retval = (*vec_ntp_timestatus)();
 	return 0;
-#else
-	return ENOSYS;
-#endif
+}
+
+int
+kern_time_30_init(void)
+{
+
+	return syscall_establish(NULL, kern_time_30_syscalls);
+}
+
+int
+kern_time_30_fini(void)
+{
+
+	return syscall_disestablish(NULL, kern_time_30_syscalls);
 }

Index: src/sys/compat/common/uipc_syscalls_30.c
diff -u src/sys/compat/common/uipc_syscalls_30.c:1.3 src/sys/compat/common/uipc_syscalls_30.c:1.3.96.1
--- src/sys/compat/common/uipc_syscalls_30.c:1.3	Thu Dec 20 23:02:45 2007
+++ src/sys/compat/common/uipc_syscalls_30.c	Wed Mar 28 04:18:24 2018
@@ -1,9 +1,9 @@
-/*	$NetBSD: uipc_syscalls_30.c,v 1.3 2007/12/20 23:02:45 dsl Exp $	*/
+/*	$NetBSD: uipc_syscalls_30.c,v 1.3.96.1 2018/03/28 04:18:24 pgoyette Exp $	*/
 
 /* written by Pavel Cahyna, 2006. Public domain. */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: uipc_syscalls_30.c,v 1.3 2007/12/20 23:02:45 dsl Exp $");
+__KERNEL_RCSID(0, "$NetBSD: uipc_syscalls_30.c,v 1.3.96.1 2018/03/28 04:18:24 pgoyette Exp $");
 
 /*
  * System call interface to the socket abstraction.
@@ -14,11 +14,21 @@ __KERNEL_RCSID(0, "$NetBSD: uipc_syscall
 #include <sys/msg.h>
 #include <sys/sysctl.h>
 #include <sys/mount.h>
+#include <sys/syscall.h>
+#include <sys/syscallvar.h>
 #include <sys/syscallargs.h>
 #include <sys/errno.h>
 
+#include <compat/common/compat_mod.h>
+
+static const struct syscall_package uipc_syscalls_30_syscalls[] = {
+	{ SYS_compat_30_socket, 0, (sy_call_t *)compat_30_sys_socket },
+	{ 0, 0, NULL}
+};
+
 int
-compat_30_sys_socket(struct lwp *l, const struct compat_30_sys_socket_args *uap, register_t *retval)
+compat_30_sys_socket(struct lwp *l,
+    const struct compat_30_sys_socket_args *uap, register_t *retval)
 {
 	int	error;
 
@@ -28,3 +38,17 @@ compat_30_sys_socket(struct lwp *l, cons
 
 	return (error);
 }
+
+int
+uipc_syscalls_30_init(void)
+{
+
+	return syscall_establish(NULL, uipc_syscalls_30_syscalls);
+}
+
+int
+uipc_syscalls_30_fini(void)
+{
+
+	return syscall_disestablish(NULL, uipc_syscalls_30_syscalls);
+}

Index: src/sys/compat/common/vfs_syscalls_30.c
diff -u src/sys/compat/common/vfs_syscalls_30.c:1.36 src/sys/compat/common/vfs_syscalls_30.c:1.36.18.1
--- src/sys/compat/common/vfs_syscalls_30.c:1.36	Mon Oct 20 11:58:01 2014
+++ src/sys/compat/common/vfs_syscalls_30.c	Wed Mar 28 04:18:24 2018
@@ -1,4 +1,4 @@
-/*	$NetBSD: vfs_syscalls_30.c,v 1.36 2014/10/20 11:58:01 christos Exp $	*/
+/*	$NetBSD: vfs_syscalls_30.c,v 1.36.18.1 2018/03/28 04:18:24 pgoyette Exp $	*/
 
 /*-
  * Copyright (c) 2005, 2008 The NetBSD Foundation, Inc.
@@ -29,7 +29,7 @@
  * POSSIBILITY OF SUCH DAMAGE.
  */
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: vfs_syscalls_30.c,v 1.36 2014/10/20 11:58:01 christos Exp $");
+__KERNEL_RCSID(0, "$NetBSD: vfs_syscalls_30.c,v 1.36.18.1 2018/03/28 04:18:24 pgoyette Exp $");
 
 #include <sys/param.h>
 #include <sys/systm.h>
@@ -47,9 +47,11 @@ __KERNEL_RCSID(0, "$NetBSD: vfs_syscalls
 #include <sys/malloc.h>
 #include <sys/kauth.h>
 #include <sys/vfs_syscalls.h>
-
+#include <sys/syscall.h>
+#include <sys/syscallvar.h>
 #include <sys/syscallargs.h>
 
+#include <compat/common/compat_mod.h>
 #include <compat/common/compat_util.h>
 #include <compat/sys/stat.h>
 #include <compat/sys/dirent.h>
@@ -57,6 +59,19 @@ __KERNEL_RCSID(0, "$NetBSD: vfs_syscalls
 
 static void cvtstat(struct stat13 *, const struct stat *);
 
+static const struct syscall_package vfs_syscalls_30_syscalls[] = {
+	{ 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 },
+	{ 0,0, NULL }
+};
+
 /*
  * Convert from a new to an old stat structure.
  */
@@ -87,7 +102,8 @@ cvtstat(struct stat13 *ost, const struct
  */
 /* ARGSUSED */
 int
-compat_30_sys___stat13(struct lwp *l, const struct compat_30_sys___stat13_args *uap, register_t *retval)
+compat_30_sys___stat13(struct lwp *l,
+    const struct compat_30_sys___stat13_args *uap, register_t *retval)
 {
 	/* {
 		syscallarg(const char *) path;
@@ -111,7 +127,8 @@ compat_30_sys___stat13(struct lwp *l, co
  */
 /* ARGSUSED */
 int
-compat_30_sys___lstat13(struct lwp *l, const struct compat_30_sys___lstat13_args *uap, register_t *retval)
+compat_30_sys___lstat13(struct lwp *l,
+    const struct compat_30_sys___lstat13_args *uap, register_t *retval)
 {
 	/* {
 		syscallarg(const char *) path;
@@ -131,7 +148,8 @@ compat_30_sys___lstat13(struct lwp *l, c
 
 /* ARGSUSED */
 int
-compat_30_sys_fhstat(struct lwp *l, const struct compat_30_sys_fhstat_args *uap, register_t *retval)
+compat_30_sys_fhstat(struct lwp *l,
+    const struct compat_30_sys_fhstat_args *uap, register_t *retval)
 {
 	/* {
 		syscallarg(const struct compat_30_fhandle *) fhp;
@@ -174,7 +192,8 @@ compat_30_sys_fhstat(struct lwp *l, cons
  */
 /* ARGSUSED */
 int
-compat_30_sys___fstat13(struct lwp *l, const struct compat_30_sys___fstat13_args *uap, register_t *retval)
+compat_30_sys___fstat13(struct lwp *l,
+    const struct compat_30_sys___fstat13_args *uap, register_t *retval)
 {
 	/* {
 		syscallarg(int) fd;
@@ -196,7 +215,8 @@ compat_30_sys___fstat13(struct lwp *l, c
  * Read a block of directory entries in a file system independent format.
  */
 int
-compat_30_sys_getdents(struct lwp *l, const struct compat_30_sys_getdents_args *uap, register_t *retval)
+compat_30_sys_getdents(struct lwp *l,
+    const struct compat_30_sys_getdents_args *uap, register_t *retval)
 {
 	/* {
 		syscallarg(int) fd;
@@ -329,7 +349,8 @@ out1:
  * Get file handle system call
  */
 int
-compat_30_sys_getfh(struct lwp *l, const struct compat_30_sys_getfh_args *uap, register_t *retval)
+compat_30_sys_getfh(struct lwp *l, const struct compat_30_sys_getfh_args *uap,
+    register_t *retval)
 {
 	/* {
 		syscallarg(char *) fname;
@@ -380,7 +401,8 @@ compat_30_sys_getfh(struct lwp *l, const
  * and call the device open routine if any.
  */
 int
-compat_30_sys_fhopen(struct lwp *l, const struct compat_30_sys_fhopen_args *uap, register_t *retval)
+compat_30_sys_fhopen(struct lwp *l,
+    const struct compat_30_sys_fhopen_args *uap, register_t *retval)
 {
 	/* {
 		syscallarg(const fhandle_t *) fhp;
@@ -393,7 +415,8 @@ compat_30_sys_fhopen(struct lwp *l, cons
 
 /* ARGSUSED */
 int
-compat_30_sys___fhstat30(struct lwp *l, const struct compat_30_sys___fhstat30_args *uap_30, register_t *retval)
+compat_30_sys___fhstat30(struct lwp *l,
+    const struct compat_30_sys___fhstat30_args *uap_30, register_t *retval)
 {
 	/* {
 		syscallarg(const fhandle_t *) fhp;
@@ -413,7 +436,8 @@ compat_30_sys___fhstat30(struct lwp *l, 
 
 /* ARGSUSED */
 int
-compat_30_sys_fhstatvfs1(struct lwp *l, const struct compat_30_sys_fhstatvfs1_args *uap_30, register_t *retval)
+compat_30_sys_fhstatvfs1(struct lwp *l,
+    const struct compat_30_sys_fhstatvfs1_args *uap_30, register_t *retval)
 {
 	/* {
 		syscallarg(const fhandle_t *) fhp;
@@ -429,3 +453,17 @@ compat_30_sys_fhstatvfs1(struct lwp *l, 
 
 	return sys___fhstatvfs140(l, &uap, retval);
 }
+
+int
+vfs_syscalls_30_init(void)
+{
+
+	return syscall_establish(NULL, vfs_syscalls_30_syscalls);
+}
+
+int
+vfs_syscalls_30_fini(void)
+{
+
+	return syscall_disestablish(NULL, vfs_syscalls_30_syscalls);
+}

Index: src/sys/dev/bio.c
diff -u src/sys/dev/bio.c:1.13 src/sys/dev/bio.c:1.13.16.1
--- src/sys/dev/bio.c:1.13	Thu Aug 20 14:40:17 2015
+++ src/sys/dev/bio.c	Wed Mar 28 04:18:24 2018
@@ -1,4 +1,4 @@
-/*	$NetBSD: bio.c,v 1.13 2015/08/20 14:40:17 christos Exp $ */
+/*	$NetBSD: bio.c,v 1.13.16.1 2018/03/28 04:18:24 pgoyette Exp $ */
 /*	$OpenBSD: bio.c,v 1.9 2007/03/20 02:35:55 marco Exp $	*/
 
 /*
@@ -28,7 +28,7 @@
 /* A device controller ioctl tunnelling device.  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: bio.c,v 1.13 2015/08/20 14:40:17 christos Exp $");
+__KERNEL_RCSID(0, "$NetBSD: bio.c,v 1.13.16.1 2018/03/28 04:18:24 pgoyette Exp $");
 
 #include "opt_compat_netbsd.h"
 
@@ -43,6 +43,7 @@ __KERNEL_RCSID(0, "$NetBSD: bio.c,v 1.13
 #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>
@@ -127,10 +128,8 @@ bioioctl(dev_t dev, u_long cmd, void *ad
 	case BIOCDISK:
 	case BIOCDISK_NOVOL:
 	case BIOCVOL:
-#ifdef COMPAT_30
 	case OBIOCDISK:
 	case OBIOCVOL:
-#endif
 		error = kauth_authorize_device_passthru(l->l_cred, dev,
 		    KAUTH_REQ_DEVICE_RAWIO_PASSTHRU_READCONF, addr);
 		if (error)
@@ -190,43 +189,11 @@ bioioctl(dev_t dev, u_long cmd, void *ad
 			return ENOENT;
 		}
 		mutex_exit(&bio_lock);
-#ifdef COMPAT_30
-		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 = bio_delegate_ioctl(common->bc_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 = bio_delegate_ioctl(common->bc_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;
-		}
-		}
-#endif
-		error = bio_delegate_ioctl(common->bc_cookie, cmd, addr);
+		error = (*compat_bio_30)(common->bc_cookie, cmd, addr,
+		    bio_delegate_ioctl);
+		if (error == ENOSYS)
+			error = bio_delegate_ioctl(common->bc_cookie, cmd,
+			    addr);
 		return error;
 	}
 	return 0;

Index: src/sys/kern/compat_stub.c
diff -u src/sys/kern/compat_stub.c:1.1.2.8 src/sys/kern/compat_stub.c:1.1.2.9
--- src/sys/kern/compat_stub.c:1.1.2.8	Tue Mar 27 07:29:44 2018
+++ src/sys/kern/compat_stub.c	Wed Mar 28 04:18:24 2018
@@ -1,4 +1,4 @@
-/* $NetBSD: compat_stub.c,v 1.1.2.8 2018/03/27 07:29:44 pgoyette Exp $	*/
+/* $NetBSD: compat_stub.c,v 1.1.2.9 2018/03/28 04:18:24 pgoyette Exp $	*/
 
 /*-
  * Copyright (c) 2018 The NetBSD Foundation, Inc.
@@ -99,3 +99,10 @@ int (*wsevent_50_copyout_events)(const s
  */
 void (*compat_sysmon_power_40)(struct power_event *, struct sysmon_pswitch *,
     int) = (void *)voidop;
+
+/*
+ * bio compatability
+ */
+
+int (*compat_bio_30)(void *, u_long, void *, int(*)(void *, u_long, void *)) =
+    (void *)enosys;

Index: src/sys/modules/Makefile
diff -u src/sys/modules/Makefile:1.202.2.11 src/sys/modules/Makefile:1.202.2.12
--- src/sys/modules/Makefile:1.202.2.11	Tue Mar 27 07:29:44 2018
+++ src/sys/modules/Makefile	Wed Mar 28 04:18:25 2018
@@ -1,4 +1,4 @@
-#	$NetBSD: Makefile,v 1.202.2.11 2018/03/27 07:29:44 pgoyette Exp $
+#	$NetBSD: Makefile,v 1.202.2.12 2018/03/28 04:18:25 pgoyette Exp $
 
 .include <bsd.own.mk>
 
@@ -7,7 +7,7 @@
 # Modules for compatability with earlier versions of NetBSD
 
 SUBDIR+=	compat    compat_80 compat_70 compat_60 compat_50
-SUBDIR+=	compat_40 #compat_30 compat_20 compat_16 compat_14
+SUBDIR+=	compat_40 compat_30 #compat_20 compat_16 compat_14
 #SUBDIR+=	compat_13 compat_12 compat_10 compat_09
 SUBDIR+=	compat_ossaudio
 SUBDIR+=	compat_sysv

Index: src/sys/sys/compat_stub.h
diff -u src/sys/sys/compat_stub.h:1.1.2.8 src/sys/sys/compat_stub.h:1.1.2.9
--- src/sys/sys/compat_stub.h:1.1.2.8	Tue Mar 27 07:29:44 2018
+++ src/sys/sys/compat_stub.h	Wed Mar 28 04:18:25 2018
@@ -1,4 +1,4 @@
-/* $NetBSD: compat_stub.h,v 1.1.2.8 2018/03/27 07:29:44 pgoyette Exp $	*/
+/* $NetBSD: compat_stub.h,v 1.1.2.9 2018/03/28 04:18:25 pgoyette Exp $	*/
 
 /*-
  * Copyright (c) 2018 The NetBSD Foundation, Inc.
@@ -107,7 +107,13 @@ extern int (*wsevent_50_copyout_events)(
 struct power_event;
 struct sysmon_pswitch;
 
-extern void (*compat_sysmon_power_40)(struct power_event
-    *, struct sysmon_pswitch *, int);
+extern void (*compat_sysmon_power_40)(struct power_event *,
+    struct sysmon_pswitch *, int);
+
+/*
+ * compat_30 indirect function pointer
+ */
+extern int (*compat_bio_30)(void *, u_long, void *,
+    int(*)(void *, u_long, void *));
 
 #endif	/* _SYS_COMPAT_STUB_H */

Added files:

Index: src/sys/compat/common/bio_30.c
diff -u /dev/null src/sys/compat/common/bio_30.c:1.1.2.1
--- /dev/null	Wed Mar 28 04:18:25 2018
+++ src/sys/compat/common/bio_30.c	Wed Mar 28 04:18:24 2018
@@ -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;
+}
Index: src/sys/compat/common/compat_30_mod.c
diff -u /dev/null src/sys/compat/common/compat_30_mod.c:1.1.2.1
--- /dev/null	Wed Mar 28 04:18:25 2018
+++ src/sys/compat/common/compat_30_mod.c	Wed Mar 28 04:18:24 2018
@@ -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

Index: src/sys/modules/compat_30/Makefile
diff -u /dev/null src/sys/modules/compat_30/Makefile:1.1.2.1
--- /dev/null	Wed Mar 28 04:18:25 2018
+++ src/sys/modules/compat_30/Makefile	Wed Mar 28 04:18:25 2018
@@ -0,0 +1,15 @@
+#	$NetBSD: Makefile,v 1.1.2.1 2018/03/28 04:18:25 pgoyette Exp $
+
+.include "../Makefile.inc"
+
+.PATH:	${S}/compat/common
+
+KMOD=	compat_30
+
+CPPFLAGS+=	-DCOMPAT_30
+CPPFLAGS+=	-DCOMPAT_40 -DCOMPAT_50 -DCOMPAT_60 -DCOMPAT_70 -DCOMPAT_80
+
+SRCS+=	compat_30_mod.c
+SRCS+=	vfs_syscalls_30.c uipc_syscalls_30.c kern_time_30.c bio_30.c
+
+.include <bsd.kmodule.mk>

Reply via email to