Module Name:    src
Committed By:   pgoyette
Date:           Wed Sep 19 04:12:43 UTC 2018

Modified Files:
        src/sys/compat/common [pgoyette-compat]: compat_50_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_50 [pgoyette-compat]: Makefile
        src/sys/sys [pgoyette-compat]: compat_stub.h
Added Files:
        src/sys/compat/common [pgoyette-compat]: vnd_50.c

Log Message:
Split out the vnd COMPAT_50 code


To generate a diff of this commit:
cvs rdiff -u -r1.1.2.11 -r1.1.2.12 src/sys/compat/common/compat_50_mod.c
cvs rdiff -u -r1.1.42.21 -r1.1.42.22 src/sys/compat/common/compat_mod.h
cvs rdiff -u -r1.1.2.35 -r1.1.2.36 src/sys/compat/common/files.common
cvs rdiff -u -r0 -r1.1.2.1 src/sys/compat/common/vnd_50.c
cvs rdiff -u -r1.263.2.5 -r1.263.2.6 src/sys/dev/vnd.c
cvs rdiff -u -r1.1.2.19 -r1.1.2.20 src/sys/kern/compat_stub.c
cvs rdiff -u -r1.1.2.8 -r1.1.2.9 src/sys/modules/compat_50/Makefile
cvs rdiff -u -r1.1.2.28 -r1.1.2.29 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/compat_50_mod.c
diff -u src/sys/compat/common/compat_50_mod.c:1.1.2.11 src/sys/compat/common/compat_50_mod.c:1.1.2.12
--- src/sys/compat/common/compat_50_mod.c:1.1.2.11	Sat Sep 15 02:14:39 2018
+++ src/sys/compat/common/compat_50_mod.c	Wed Sep 19 04:12:43 2018
@@ -1,4 +1,4 @@
-/*	$NetBSD: compat_50_mod.c,v 1.1.2.11 2018/09/15 02:14:39 pgoyette Exp $	*/
+/*	$NetBSD: compat_50_mod.c,v 1.1.2.12 2018/09/19 04:12:43 pgoyette Exp $	*/
 
 /*-
  * Copyright (c) 2018 The NetBSD Foundation, Inc.
@@ -34,7 +34,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: compat_50_mod.c,v 1.1.2.11 2018/09/15 02:14:39 pgoyette Exp $");
+__KERNEL_RCSID(0, "$NetBSD: compat_50_mod.c,v 1.1.2.12 2018/09/19 04:12:43 pgoyette Exp $");
 
 #include <sys/systm.h>
 #include <sys/module.h>
@@ -86,6 +86,7 @@ compat_50_init(void)
 	raidframe_50_init();
 	puffs_50_init();
 	wsevent_50_init();
+	vnd_50_init();
 
 	return error;
 
@@ -106,6 +107,7 @@ compat_50_fini(void)
 {
 	int error = 0;
 
+	vnd_50_fini();
 	wsevent_50_fini();
 	puffs_50_fini();
 	raidframe_50_fini();
@@ -149,6 +151,7 @@ compat_50_fini(void)
 	raidframe_50_init();
 	puffs_50_init();
 	wsevent_50_init();
+	vnd_50_init();
 
 	return error;
 }

Index: src/sys/compat/common/compat_mod.h
diff -u src/sys/compat/common/compat_mod.h:1.1.42.21 src/sys/compat/common/compat_mod.h:1.1.42.22
--- src/sys/compat/common/compat_mod.h:1.1.42.21	Tue Apr 17 07:24:55 2018
+++ src/sys/compat/common/compat_mod.h	Wed Sep 19 04:12:43 2018
@@ -1,4 +1,4 @@
-/*	$NetBSD: compat_mod.h,v 1.1.42.21 2018/04/17 07:24:55 pgoyette Exp $	*/
+/*	$NetBSD: compat_mod.h,v 1.1.42.22 2018/09/19 04:12:43 pgoyette Exp $	*/
 
 /*-
  * Copyright (c) 2013 The NetBSD Foundation, Inc.
@@ -70,6 +70,8 @@ int vfs_syscalls_50_init(void);
 int vfs_syscalls_50_fini(void);
 void uipc_syscalls_50_init(void);
 void uipc_syscalls_50_fini(void);
+void vnd_50_init(void);
+void vnd_50_fini(void);
 #endif
 
 #ifdef COMPAT_40

Index: src/sys/compat/common/files.common
diff -u src/sys/compat/common/files.common:1.1.2.35 src/sys/compat/common/files.common:1.1.2.36
--- src/sys/compat/common/files.common:1.1.2.35	Wed Sep 12 21:46:09 2018
+++ src/sys/compat/common/files.common	Wed Sep 19 04:12:43 2018
@@ -1,4 +1,4 @@
-#	$NetBSD: files.common,v 1.1.2.35 2018/09/12 21:46:09 pgoyette Exp $
+#	$NetBSD: files.common,v 1.1.2.36 2018/09/19 04:12:43 pgoyette Exp $
 
 #
 # Generic files, used by all compat options.
@@ -81,6 +81,7 @@ file	compat/common/rndpseudo_50.c		compa
 file	compat/common/rtsock_50.c		compat_50
 file	compat/common/vfs_syscalls_50.c		compat_50
 file	compat/common/uipc_syscalls_50.c	compat_50
+file	compat/common/vnd_50.c			compat_50
 file	compat/common/clockctl_50.c		compat_50 & clockctl
 file	compat/common/if_spppsubr50.c		compat_50 & sppp
 file	compat/common/uvm_50.c			compat_50

Index: src/sys/dev/vnd.c
diff -u src/sys/dev/vnd.c:1.263.2.5 src/sys/dev/vnd.c:1.263.2.6
--- src/sys/dev/vnd.c:1.263.2.5	Tue Sep 18 23:03:54 2018
+++ src/sys/dev/vnd.c	Wed Sep 19 04:12:43 2018
@@ -1,4 +1,4 @@
-/*	$NetBSD: vnd.c,v 1.263.2.5 2018/09/18 23:03:54 pgoyette Exp $	*/
+/*	$NetBSD: vnd.c,v 1.263.2.6 2018/09/19 04:12:43 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.2.5 2018/09/18 23:03:54 pgoyette Exp $");
+__KERNEL_RCSID(0, "$NetBSD: vnd.c,v 1.263.2.6 2018/09/19 04:12:43 pgoyette Exp $");
 
 #if defined(_KERNEL_OPT)
 #include "opt_vnd.h"
@@ -1122,6 +1122,17 @@ MODULE_CALL_HOOK(compat_vndioctl_30_hook
     (cmd, l, data, unit, vattr, ff),
     enosys());
 
+MODULE_CALL_HOOK_DECL(compat_vndioctl_50_hook, f,
+    (u_long cmd, struct lwp *l, void *data, int unit, struct vattr *vattr,
+     int (*ff)(struct lwp *, void *, int, struct vattr *)),
+    (cmd, l, data, unit, vattr, ff),
+    enosys());
+MODULE_CALL_HOOK(compat_vndioctl_50_hook, f,
+    (u_long cmd, struct lwp *l, void *data, int unit, struct vattr *vattr,
+     int (*ff)(struct lwp *, void *, int, struct vattr *)),
+    (cmd, l, data, unit, vattr, ff),
+    enosys());
+
 /* ARGSUSED */
 static int
 vndioctl(dev_t dev, u_long cmd, void *data, int flag, struct lwp *l)
@@ -1147,19 +1158,7 @@ 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_50
-	case VNDIOCGET50: {
-		if ((error = vndioctl_get(l, data, unit, &vattr)) != 0)
-			return error;
-
-		struct vnd_user50 *vnu = data;
-		vnu->vnu_dev = vattr.va_fsid;
-		vnu->vnu_ino = vattr.va_fileid;
-		return 0;
-	}
-#endif
-
-	case VNDIOCGET: {
+	case VNDIOCGET:
 		if ((error = vndioctl_get(l, data, unit, &vattr)) != 0)
 			return error;
 
@@ -1167,15 +1166,33 @@ vndioctl(dev_t dev, u_long cmd, void *da
 		vnu->vnu_dev = vattr.va_fsid;
 		vnu->vnu_ino = vattr.va_fileid;
 		return 0;
-	}
+
 	default:
-		error = compat_vndioctl_30_hook_f_call(cmd, l, data, unit,
+		/* First check for COMPAT_50 hook */
+		error = compat_vndioctl_50_hook_f_call(cmd, l, data, unit,
 		    &vattr, vndioctl_get);
-		if (error == ENOSYS)
-			error = EINVAL;
-		if (error != EPASSTHROUGH) {
-			return error;
+
+		/*
+		 * If not present, then COMPAT_30 hook also not
+		 * present, so just continue with checks for the
+		 * "write" commands
+		 */
+		if (error == ENOSYS) {
+			error = 0;
+			break;
 		}
+
+		/* If not already handled, try the COMPAT_30 hook */
+		if (error == EPASSTHROUGH)
+			error = compat_vndioctl_30_hook_f_call(cmd, l, data,
+			    unit, &vattr, vndioctl_get);
+
+		/* If no COMPAT_30 module, or not handled, check writes */
+		if (error == ENOSYS || error == EPASSTHROUGH) {
+			error = 0;
+			break;
+		}
+		return error;
 	}
 
 	vnd = device_lookup_private(&vnd_cd, unit);
@@ -1185,12 +1202,13 @@ vndioctl(dev_t dev, u_long cmd, void *da
 
 	/* Must be open for writes for these commands... */
 	switch (cmd) {
-	case VNDIOCSET:
-	case VNDIOCCLR:
-#ifdef COMPAT_50
 	case VNDIOCSET50:
 	case VNDIOCCLR50:
-#endif
+		if (!compat_vndioctl_50_hook.hooked)
+			return EINVAL;
+		/* FALLTHROUGH */
+	case VNDIOCSET:
+	case VNDIOCCLR:
 	case DIOCSDINFO:
 	case DIOCWDINFO:
 #ifdef __HAVE_OLD_DISKLABEL
@@ -1206,9 +1224,7 @@ vndioctl(dev_t dev, u_long cmd, void *da
 	/* Must be initialized for these... */
 	switch (cmd) {
 	case VNDIOCCLR:
-#ifdef VNDIOCCLR50
 	case VNDIOCCLR50:
-#endif
 	case DIOCGDINFO:
 	case DIOCSDINFO:
 	case DIOCWDINFO:
@@ -1233,9 +1249,7 @@ vndioctl(dev_t dev, u_long cmd, void *da
 
 
 	switch (cmd) {
-#ifdef VNDIOCSET50
 	case VNDIOCSET50:
-#endif
 	case VNDIOCSET:
 		if (vnd->sc_flags & VNF_INITED)
 			return EBUSY;
@@ -1472,9 +1486,7 @@ vndioctl(dev_t dev, u_long cmd, void *da
 
 		vndthrottle(vnd, vnd->sc_vp);
 		vio->vnd_osize = dbtob(vnd->sc_size);
-#ifdef VNDIOCSET50
 		if (cmd != VNDIOCSET50)
-#endif
 			vio->vnd_size = dbtob(vnd->sc_size);
 		vnd->sc_flags |= VNF_INITED;
 
@@ -1534,9 +1546,7 @@ unlock_and_exit:
 		vndunlock(vnd);
 		return error;
 
-#ifdef VNDIOCCLR50
 	case VNDIOCCLR50:
-#endif
 	case VNDIOCCLR:
 		part = DISKPART(dev);
 		pmask = (1 << part);

Index: src/sys/kern/compat_stub.c
diff -u src/sys/kern/compat_stub.c:1.1.2.19 src/sys/kern/compat_stub.c:1.1.2.20
--- src/sys/kern/compat_stub.c:1.1.2.19	Tue Sep 18 01:15:58 2018
+++ src/sys/kern/compat_stub.c	Wed Sep 19 04:12:43 2018
@@ -1,4 +1,4 @@
-/* $NetBSD: compat_stub.c,v 1.1.2.19 2018/09/18 01:15:58 pgoyette Exp $	*/
+/* $NetBSD: compat_stub.c,v 1.1.2.20 2018/09/19 04:12:43 pgoyette Exp $	*/
 
 /*-
  * Copyright (c) 2018 The NetBSD Foundation, Inc.
@@ -122,6 +122,7 @@ struct compat_bio_30_hook_t compat_bio_3
  * vnd ioctl compatability
  */
 struct compat_vndioctl_30_hook_t compat_vndioctl_30_hook;
+struct compat_vndioctl_50_hook_t compat_vndioctl_50_hook;
 
 /*
  * ieee80211 ioctl compatability

Index: src/sys/modules/compat_50/Makefile
diff -u src/sys/modules/compat_50/Makefile:1.1.2.8 src/sys/modules/compat_50/Makefile:1.1.2.9
--- src/sys/modules/compat_50/Makefile:1.1.2.8	Thu Sep 13 10:16:51 2018
+++ src/sys/modules/compat_50/Makefile	Wed Sep 19 04:12:43 2018
@@ -1,4 +1,4 @@
-#	$NetBSD: Makefile,v 1.1.2.8 2018/09/13 10:16:51 pgoyette Exp $
+#	$NetBSD: Makefile,v 1.1.2.9 2018/09/19 04:12:43 pgoyette Exp $
 
 .include "../Makefile.inc"
 
@@ -30,4 +30,8 @@ SRCS+=	puffs_compat.c
 
 SRCS+=  wsevent_50.c
 
+.PATH:	${S}/dev
+
+SRCS+=	vnd_50.c
+
 .include <bsd.kmodule.mk>

Index: src/sys/sys/compat_stub.h
diff -u src/sys/sys/compat_stub.h:1.1.2.28 src/sys/sys/compat_stub.h:1.1.2.29
--- src/sys/sys/compat_stub.h:1.1.2.28	Tue Sep 18 23:03:55 2018
+++ src/sys/sys/compat_stub.h	Wed Sep 19 04:12:43 2018
@@ -1,4 +1,4 @@
-/* $NetBSD: compat_stub.h,v 1.1.2.28 2018/09/18 23:03:55 pgoyette Exp $	*/
+/* $NetBSD: compat_stub.h,v 1.1.2.29 2018/09/19 04:12:43 pgoyette Exp $	*/
 
 /*-
  * Copyright (c) 2018 The NetBSD Foundation, Inc.
@@ -135,13 +135,19 @@ MODULE_HOOK(compat_bio_30_hook, (void *,
 
 /*
  * vnd_30 ioctl compatability
- * XXX there's some _50 code mixed in
  */
 struct vattr;
 MODULE_HOOK(compat_vndioctl_30_hook, (u_long, struct lwp *, void *, int,
     struct vattr *, int (*)(struct lwp *, void *, int, struct vattr *)));
 
 /*
+ * vnd_50 ioctl compatability
+ */
+struct vattr;
+MODULE_HOOK(compat_vndioctl_50_hook, (u_long, struct lwp *, void *, int,
+    struct vattr *, int (*)(struct lwp *, void *, int, struct vattr *)));
+
+/*
  * ieee80211 ioctl compatability
  * XXX need to review this
  */

Added files:

Index: src/sys/compat/common/vnd_50.c
diff -u /dev/null src/sys/compat/common/vnd_50.c:1.1.2.1
--- /dev/null	Wed Sep 19 04:12:43 2018
+++ src/sys/compat/common/vnd_50.c	Wed Sep 19 04:12:43 2018
@@ -0,0 +1,133 @@
+/*	$NetBSD: vnd_50.c,v 1.1.2.1 2018/09/19 04:12:43 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_50.c,v 1.1.2.1 2018/09/19 04:12:43 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_50_vndioctl(u_long, struct lwp *, void *, int, struct vattr *,
+    int (*)(struct lwp *, void *, int, struct vattr *));
+
+static int
+compat_50_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_user50 *vnu = data;
+	int error;
+
+	if (cmd != VNDIOCGET50)
+		return EPASSTHROUGH;
+
+	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;
+}
+
+MODULE_SET_HOOK(compat_vndioctl_50_hook, "vnd_50", compat_50_vndioctl);
+MODULE_UNSET_HOOK(compat_vndioctl_50_hook);
+
+void
+vnd_50_init(void)
+{
+
+	compat_vndioctl_50_hook_set();
+}
+
+void
+vnd_50_fini(void)
+{
+
+	compat_vndioctl_50_hook_unset();
+}

Reply via email to