Module Name:    src
Committed By:   pgoyette
Date:           Wed Mar 28 07:51:09 UTC 2018

Modified Files:
        src/sys/compat/common [pgoyette-compat]: Makefile.sysio compat_30_mod.c
            compat_mod.h files.common
        src/sys/dev [pgoyette-compat]: vnd.c
        src/sys/kern [pgoyette-compat]: compat_stub.c
        src/sys/modules/compat_30 [pgoyette-compat]: Makefile
        src/sys/sys [pgoyette-compat]: compat_stub.h
Added Files:
        src/sys/compat/common [pgoyette-compat]: vnd_30.c

Log Message:
Split vnd compat_30 code out of the main driver and into the compat_30
module


To generate a diff of this commit:
cvs rdiff -u -r1.7.18.17 -r1.7.18.18 src/sys/compat/common/Makefile.sysio
cvs rdiff -u -r1.1.2.1 -r1.1.2.2 src/sys/compat/common/compat_30_mod.c
cvs rdiff -u -r1.1.42.10 -r1.1.42.11 src/sys/compat/common/compat_mod.h
cvs rdiff -u -r1.1.2.20 -r1.1.2.21 src/sys/compat/common/files.common
cvs rdiff -u -r0 -r1.1.2.1 src/sys/compat/common/vnd_30.c
cvs rdiff -u -r1.263 -r1.263.2.1 src/sys/dev/vnd.c
cvs rdiff -u -r1.1.2.9 -r1.1.2.10 src/sys/kern/compat_stub.c
cvs rdiff -u -r1.1.2.1 -r1.1.2.2 src/sys/modules/compat_30/Makefile
cvs rdiff -u -r1.1.2.9 -r1.1.2.10 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/sys/compat/common/Makefile.sysio
diff -u src/sys/compat/common/Makefile.sysio:1.7.18.17 src/sys/compat/common/Makefile.sysio:1.7.18.18
--- src/sys/compat/common/Makefile.sysio:1.7.18.17	Wed Mar 28 04:18:24 2018
+++ src/sys/compat/common/Makefile.sysio	Wed Mar 28 07:51:09 2018
@@ -1,4 +1,4 @@
-#	$NetBSD: Makefile.sysio,v 1.7.18.17 2018/03/28 04:18:24 pgoyette Exp $
+#	$NetBSD: Makefile.sysio,v 1.7.18.18 2018/03/28 07:51:09 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 bio_30.c
+SRCS+=	kern_time_30.c vfs_syscalls_30.c uipc_syscalls_30.c bio_30.c vnd_30.c
 
 # Compatibility code for NetBSD 4.0
 SRCS+=	vfs_syscalls_40.c uipc_syscalls_40.c

Index: src/sys/compat/common/compat_30_mod.c
diff -u src/sys/compat/common/compat_30_mod.c:1.1.2.1 src/sys/compat/common/compat_30_mod.c:1.1.2.2
--- src/sys/compat/common/compat_30_mod.c:1.1.2.1	Wed Mar 28 04:18:24 2018
+++ src/sys/compat/common/compat_30_mod.c	Wed Mar 28 07:51:09 2018
@@ -1,4 +1,4 @@
-/*	$NetBSD: compat_30_mod.c,v 1.1.2.1 2018/03/28 04:18:24 pgoyette Exp $	*/
+/*	$NetBSD: compat_30_mod.c,v 1.1.2.2 2018/03/28 07:51:09 pgoyette Exp $	*/
 
 /*-
  * Copyright (c) 2018 The NetBSD Foundation, Inc.
@@ -34,7 +34,7 @@
  */
 
 #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 $");
+__KERNEL_RCSID(0, "$NetBSD: compat_30_mod.c,v 1.1.2.2 2018/03/28 07:51:09 pgoyette Exp $");
 
 #include <sys/systm.h>
 #include <sys/module.h>
@@ -63,6 +63,7 @@ compat_30_init(void)
 		return error;
 	}
 	bio_30_init();
+	vnd_30_init();
 
 	return error;
 }
@@ -72,17 +73,20 @@ compat_30_fini(void)
 {
 	int error = 0;
 
+	vnd_30_fini();
 	bio_30_fini();
 
 	error = kern_time_30_fini();
 	if (error != 0) {
 		bio_30_init();
+		vnd_30_init();
 		return error;
 	}
 
 	error = vfs_syscalls_30_fini();
 	if (error != 0) {
 		bio_30_init();
+		vnd_30_init();
 		kern_time_30_init();
 		return error;
 	}

Index: src/sys/compat/common/compat_mod.h
diff -u src/sys/compat/common/compat_mod.h:1.1.42.10 src/sys/compat/common/compat_mod.h:1.1.42.11
--- src/sys/compat/common/compat_mod.h:1.1.42.10	Wed Mar 28 04:18:24 2018
+++ src/sys/compat/common/compat_mod.h	Wed Mar 28 07:51:09 2018
@@ -1,4 +1,4 @@
-/*	$NetBSD: compat_mod.h,v 1.1.42.10 2018/03/28 04:18:24 pgoyette Exp $	*/
+/*	$NetBSD: compat_mod.h,v 1.1.42.11 2018/03/28 07:51:09 pgoyette Exp $	*/
 
 /*-
  * Copyright (c) 2013 The NetBSD Foundation, Inc.
@@ -99,6 +99,8 @@ int uipc_syscalls_30_init(void);
 int uipc_syscalls_30_fini(void);
 void bio_30_init(void);
 void bio_30_fini(void);
+void vnd_30_init(void);
+void vnd_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.20 src/sys/compat/common/files.common:1.1.2.21
--- src/sys/compat/common/files.common:1.1.2.20	Wed Mar 28 04:18:24 2018
+++ src/sys/compat/common/files.common	Wed Mar 28 07:51:09 2018
@@ -1,4 +1,4 @@
-#	$NetBSD: files.common,v 1.1.2.20 2018/03/28 04:18:24 pgoyette Exp $
+#	$NetBSD: files.common,v 1.1.2.21 2018/03/28 07:51:09 pgoyette Exp $
 
 #
 # Generic files, used by all compat options.
@@ -52,6 +52,7 @@ file	compat/common/kern_time_30.c		compa
 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
+file	compat/common/vnd_30.c			compat_30
 
 # Compatibility code for NetBSD 4.0
 file	compat/common/compat_40_mod.c		compat_40

Index: src/sys/dev/vnd.c
diff -u src/sys/dev/vnd.c:1.263 src/sys/dev/vnd.c:1.263.2.1
--- src/sys/dev/vnd.c:1.263	Sat Oct 28 03:47:24 2017
+++ src/sys/dev/vnd.c	Wed Mar 28 07:51:09 2018
@@ -1,4 +1,4 @@
-/*	$NetBSD: vnd.c,v 1.263 2017/10/28 03:47:24 riastradh Exp $	*/
+/*	$NetBSD: vnd.c,v 1.263.2.1 2018/03/28 07:51:09 pgoyette Exp $	*/
 
 /*-
  * Copyright (c) 1996, 1997, 1998, 2008 The NetBSD Foundation, Inc.
@@ -91,7 +91,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: vnd.c,v 1.263 2017/10/28 03:47:24 riastradh Exp $");
+__KERNEL_RCSID(0, "$NetBSD: vnd.c,v 1.263.2.1 2018/03/28 07:51:09 pgoyette Exp $");
 
 #if defined(_KERNEL_OPT)
 #include "opt_vnd.h"
@@ -119,6 +119,7 @@ __KERNEL_RCSID(0, "$NetBSD: vnd.c,v 1.26
 #include <sys/conf.h>
 #include <sys/kauth.h>
 #include <sys/module.h>
+#include <sys/compat_stub.h>
 
 #include <net/zlib.h>
 
@@ -1135,17 +1136,6 @@ vndioctl(dev_t dev, u_long cmd, void *da
 #endif
 	/* Do the get's first; they don't need initialization or verification */
 	switch (cmd) {
-#ifdef COMPAT_30
-	case VNDIOCGET30: {
-		if ((error = vndioctl_get(l, data, unit, &vattr)) != 0)
-			return error;
-
-		struct vnd_user30 *vnu = data;
-		vnu->vnu_dev = vattr.va_fsid;
-		vnu->vnu_ino = vattr.va_fileid;
-		return 0;
-	}
-#endif
 #ifdef COMPAT_50
 	case VNDIOCGET50: {
 		if ((error = vndioctl_get(l, data, unit, &vattr)) != 0)
@@ -1168,7 +1158,13 @@ vndioctl(dev_t dev, u_long cmd, void *da
 		return 0;
 	}
 	default:
-		break;
+		error = (*compat_vndioctl_30)(cmd, l, data, unit, &vattr,
+		    vndioctl_get);
+		if (error == ENOSYS) {
+			error = 0;
+			break;
+		}
+		return error;
 	}
 
 	vnd = device_lookup_private(&vnd_cd, unit);

Index: src/sys/kern/compat_stub.c
diff -u src/sys/kern/compat_stub.c:1.1.2.9 src/sys/kern/compat_stub.c:1.1.2.10
--- src/sys/kern/compat_stub.c:1.1.2.9	Wed Mar 28 04:18:24 2018
+++ src/sys/kern/compat_stub.c	Wed Mar 28 07:51:09 2018
@@ -1,4 +1,4 @@
-/* $NetBSD: compat_stub.c,v 1.1.2.9 2018/03/28 04:18:24 pgoyette Exp $	*/
+/* $NetBSD: compat_stub.c,v 1.1.2.10 2018/03/28 07:51:09 pgoyette Exp $	*/
 
 /*-
  * Copyright (c) 2018 The NetBSD Foundation, Inc.
@@ -106,3 +106,10 @@ void (*compat_sysmon_power_40)(struct po
 
 int (*compat_bio_30)(void *, u_long, void *, int(*)(void *, u_long, void *)) =
     (void *)enosys;
+
+/*
+ * vnd ioctl compatability
+ */
+int (*compat_vndioctl_30)(u_long cmd, struct lwp *l, void *data, int unit,
+    struct vattr *vattr_p, int (*get)(struct lwp *, void *, int,
+    struct vattr *)) = (void *)enosys;

Index: src/sys/modules/compat_30/Makefile
diff -u src/sys/modules/compat_30/Makefile:1.1.2.1 src/sys/modules/compat_30/Makefile:1.1.2.2
--- src/sys/modules/compat_30/Makefile:1.1.2.1	Wed Mar 28 04:18:25 2018
+++ src/sys/modules/compat_30/Makefile	Wed Mar 28 07:51:09 2018
@@ -1,4 +1,4 @@
-#	$NetBSD: Makefile,v 1.1.2.1 2018/03/28 04:18:25 pgoyette Exp $
+#	$NetBSD: Makefile,v 1.1.2.2 2018/03/28 07:51:09 pgoyette Exp $
 
 .include "../Makefile.inc"
 
@@ -10,6 +10,6 @@ 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
+SRCS+=	vfs_syscalls_30.c uipc_syscalls_30.c kern_time_30.c bio_30.c vnd_30.c
 
 .include <bsd.kmodule.mk>

Index: src/sys/sys/compat_stub.h
diff -u src/sys/sys/compat_stub.h:1.1.2.9 src/sys/sys/compat_stub.h:1.1.2.10
--- src/sys/sys/compat_stub.h:1.1.2.9	Wed Mar 28 04:18:25 2018
+++ src/sys/sys/compat_stub.h	Wed Mar 28 07:51:09 2018
@@ -1,4 +1,4 @@
-/* $NetBSD: compat_stub.h,v 1.1.2.9 2018/03/28 04:18:25 pgoyette Exp $	*/
+/* $NetBSD: compat_stub.h,v 1.1.2.10 2018/03/28 07:51:09 pgoyette Exp $	*/
 
 /*-
  * Copyright (c) 2018 The NetBSD Foundation, Inc.
@@ -116,4 +116,12 @@ extern void (*compat_sysmon_power_40)(st
 extern int (*compat_bio_30)(void *, u_long, void *,
     int(*)(void *, u_long, void *));
 
+/*
+ * vnd_30 ioctl compatability
+ */
+struct vattr;
+
+extern int (*compat_vndioctl_30)(u_long, struct lwp *, void *, int,
+    struct vattr *, int (*)(struct lwp *, void *, int, struct vattr *));
+
 #endif	/* _SYS_COMPAT_STUB_H */

Added files:

Index: src/sys/compat/common/vnd_30.c
diff -u /dev/null src/sys/compat/common/vnd_30.c:1.1.2.1
--- /dev/null	Wed Mar 28 07:51:09 2018
+++ src/sys/compat/common/vnd_30.c	Wed Mar 28 07:51:09 2018
@@ -0,0 +1,130 @@
+/*	$NetBSD: vnd_30.c,v 1.1.2.1 2018/03/28 07:51:09 pgoyette Exp $	*/
+
+/*-
+ * Copyright (c) 1996, 1997, 1998, 2008 The NetBSD Foundation, Inc.
+ * All rights reserved.
+ *
+ * This code is derived from software contributed to The NetBSD Foundation
+ * by Jason R. Thorpe.
+ *
+ * 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.
+ */
+
+/*
+ * Copyright (c) 1988 University of Utah.
+ * Copyright (c) 1990, 1993
+ *	The Regents of the University of California.  All rights reserved.
+ *
+ * This code is derived from software contributed to Berkeley by
+ * the Systems Programming Group of the University of Utah Computer
+ * Science Department.
+ *
+ * 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.
+ * 3. Neither the name of the University nor the names of its contributors
+ *    may be used to endorse or promote products derived from this software
+ *    without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE REGENTS 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 REGENTS 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.
+ *
+ * from: Utah $Hdr: vn.c 1.13 94/04/02$
+ *
+ *	@(#)vn.c	8.9 (Berkeley) 5/14/95
+ */
+
+#include <sys/cdefs.h>
+__KERNEL_RCSID(0, "$NetBSD: vnd_30.c,v 1.1.2.1 2018/03/28 07:51:09 pgoyette Exp $");
+
+#include <sys/param.h>
+#include <sys/systm.h>
+#include <sys/proc.h>
+#include <sys/errno.h>
+#include <sys/malloc.h>
+#include <sys/ioctl.h>
+#include <sys/device.h>
+#include <sys/disk.h>
+#include <sys/stat.h>
+#include <sys/vnode.h>
+#include <sys/file.h>
+#include <sys/uio.h>
+#include <sys/conf.h>
+#include <sys/vnode.h>
+#include <sys/compat_stub.h>
+
+#include <net/zlib.h>
+
+#include <dev/vndvar.h>
+
+#include <compat/common/compat_mod.h>
+
+static int compat_30_vndioctl(u_long, struct lwp *, void *, int, struct vattr *,
+    int (*)(struct lwp *, void *, int, struct vattr *));
+
+static int
+compat_30_vndioctl(u_long cmd, struct lwp *l, void *data, int unit,
+    struct vattr *vattr_p,
+    int (*get)(struct lwp *, void *, int, struct vattr *))
+{
+	struct vnd_user30 *vnu = data;
+	int error;
+
+	if (cmd != VNDIOCGET30)
+		return ENOSYS;
+
+	error = (*get)(l, data, unit, vattr_p);
+	if (error != 0)
+		return error;
+
+	vnu->vnu_dev = vattr_p->va_fsid;
+	vnu->vnu_ino = vattr_p->va_fileid;
+	return 0;
+}
+
+void
+vnd_30_init(void)
+{
+
+	compat_vndioctl_30 = compat_30_vndioctl;
+}
+
+void
+vnd_30_fini(void)
+{
+
+	compat_vndioctl_30 = (void *)enosys;
+}

Reply via email to