Source-Changes-HG archive

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

[src/pgoyette-compat]: src/sys Split out the vnd COMPAT_50 code



details:   https://anonhg.NetBSD.org/src/rev/34535b71eb83
branches:  pgoyette-compat
changeset: 830726:34535b71eb83
user:      pgoyette <pgoyette%NetBSD.org@localhost>
date:      Wed Sep 19 04:12:43 2018 +0000

description:
Split out the vnd COMPAT_50 code

diffstat:

 sys/compat/common/compat_50_mod.c |    7 +-
 sys/compat/common/compat_mod.h    |    4 +-
 sys/compat/common/files.common    |    3 +-
 sys/compat/common/vnd_50.c        |  133 ++++++++++++++++++++++++++++++++++++++
 sys/dev/vnd.c                     |   76 ++++++++++++---------
 sys/kern/compat_stub.c            |    3 +-
 sys/modules/compat_50/Makefile    |    6 +-
 sys/sys/compat_stub.h             |   10 ++-
 8 files changed, 201 insertions(+), 41 deletions(-)

diffs (truncated from 434 to 300 lines):

diff -r be1994d84159 -r 34535b71eb83 sys/compat/common/compat_50_mod.c
--- a/sys/compat/common/compat_50_mod.c Tue Sep 18 23:03:54 2018 +0000
+++ b/sys/compat/common/compat_50_mod.c Wed Sep 19 04:12:43 2018 +0000
@@ -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 @@
        raidframe_50_init();
        puffs_50_init();
        wsevent_50_init();
+       vnd_50_init();
 
        return error;
 
@@ -106,6 +107,7 @@
 {
        int error = 0;
 
+       vnd_50_fini();
        wsevent_50_fini();
        puffs_50_fini();
        raidframe_50_fini();
@@ -149,6 +151,7 @@
        raidframe_50_init();
        puffs_50_init();
        wsevent_50_init();
+       vnd_50_init();
 
        return error;
 }
diff -r be1994d84159 -r 34535b71eb83 sys/compat/common/compat_mod.h
--- a/sys/compat/common/compat_mod.h    Tue Sep 18 23:03:54 2018 +0000
+++ b/sys/compat/common/compat_mod.h    Wed Sep 19 04:12:43 2018 +0000
@@ -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_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
diff -r be1994d84159 -r 34535b71eb83 sys/compat/common/files.common
--- a/sys/compat/common/files.common    Tue Sep 18 23:03:54 2018 +0000
+++ b/sys/compat/common/files.common    Wed Sep 19 04:12:43 2018 +0000
@@ -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/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
diff -r be1994d84159 -r 34535b71eb83 sys/compat/common/vnd_50.c
--- /dev/null   Thu Jan 01 00:00:00 1970 +0000
+++ b/sys/compat/common/vnd_50.c        Wed Sep 19 04:12:43 2018 +0000
@@ -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();
+}
diff -r be1994d84159 -r 34535b71eb83 sys/dev/vnd.c
--- a/sys/dev/vnd.c     Tue Sep 18 23:03:54 2018 +0000
+++ b/sys/dev/vnd.c     Wed Sep 19 04:12:43 2018 +0000
@@ -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 @@
     (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 @@
 #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 @@
                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,



Home | Main Index | Thread Index | Old Index