Source-Changes-HG archive

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

[src/pgoyette-compat]: src/sys Split vnd compat_30 code out of the main drive...



details:   https://anonhg.NetBSD.org/src/rev/7dc3e323b114
branches:  pgoyette-compat
changeset: 321115:7dc3e323b114
user:      pgoyette <pgoyette%NetBSD.org@localhost>
date:      Wed Mar 28 07:51:09 2018 +0000

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

diffstat:

 sys/compat/common/Makefile.sysio  |    4 +-
 sys/compat/common/compat_30_mod.c |    8 +-
 sys/compat/common/compat_mod.h    |    4 +-
 sys/compat/common/files.common    |    3 +-
 sys/compat/common/vnd_30.c        |  130 ++++++++++++++++++++++++++++++++++++++
 sys/dev/vnd.c                     |   24 ++----
 sys/kern/compat_stub.c            |    9 ++-
 sys/modules/compat_30/Makefile    |    4 +-
 sys/sys/compat_stub.h             |   10 ++-
 9 files changed, 172 insertions(+), 24 deletions(-)

diffs (truncated from 352 to 300 lines):

diff -r 2275f4557ec7 -r 7dc3e323b114 sys/compat/common/Makefile.sysio
--- a/sys/compat/common/Makefile.sysio  Wed Mar 28 04:18:24 2018 +0000
+++ b/sys/compat/common/Makefile.sysio  Wed Mar 28 07:51:09 2018 +0000
@@ -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+= 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
diff -r 2275f4557ec7 -r 7dc3e323b114 sys/compat/common/compat_30_mod.c
--- a/sys/compat/common/compat_30_mod.c Wed Mar 28 04:18:24 2018 +0000
+++ b/sys/compat/common/compat_30_mod.c Wed Mar 28 07:51:09 2018 +0000
@@ -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 @@
                return error;
        }
        bio_30_init();
+       vnd_30_init();
 
        return error;
 }
@@ -72,17 +73,20 @@
 {
        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;
        }
diff -r 2275f4557ec7 -r 7dc3e323b114 sys/compat/common/compat_mod.h
--- a/sys/compat/common/compat_mod.h    Wed Mar 28 04:18:24 2018 +0000
+++ b/sys/compat/common/compat_mod.h    Wed Mar 28 07:51:09 2018 +0000
@@ -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_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_ */
diff -r 2275f4557ec7 -r 7dc3e323b114 sys/compat/common/files.common
--- a/sys/compat/common/files.common    Wed Mar 28 04:18:24 2018 +0000
+++ b/sys/compat/common/files.common    Wed Mar 28 07:51:09 2018 +0000
@@ -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/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
diff -r 2275f4557ec7 -r 7dc3e323b114 sys/compat/common/vnd_30.c
--- /dev/null   Thu Jan 01 00:00:00 1970 +0000
+++ b/sys/compat/common/vnd_30.c        Wed Mar 28 07:51:09 2018 +0000
@@ -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;
+}
diff -r 2275f4557ec7 -r 7dc3e323b114 sys/dev/vnd.c
--- a/sys/dev/vnd.c     Wed Mar 28 04:18:24 2018 +0000
+++ b/sys/dev/vnd.c     Wed Mar 28 07:51:09 2018 +0000
@@ -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 @@
 #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 @@
 #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 @@
                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);
diff -r 2275f4557ec7 -r 7dc3e323b114 sys/kern/compat_stub.c
--- a/sys/kern/compat_stub.c    Wed Mar 28 04:18:24 2018 +0000
+++ b/sys/kern/compat_stub.c    Wed Mar 28 07:51:09 2018 +0000
@@ -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 $        */
 



Home | Main Index | Thread Index | Old Index