Source-Changes-HG archive

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

[src/pgoyette-compat]: src/sys Convert another hook to the MP-sfe mechanism.



details:   https://anonhg.NetBSD.org/src/rev/8ce716e99be8
branches:  pgoyette-compat
changeset: 445148:8ce716e99be8
user:      pgoyette <pgoyette%NetBSD.org@localhost>
date:      Mon Oct 15 09:51:33 2018 +0000

description:
Convert another hook to the MP-sfe mechanism.

XXX still have three more to convert: openat_10, sysvipc50_sysctl and
XXX compat70_unp_addsockcred

diffstat:

 sys/compat/common/compat_70_mod.c |   8 +++---
 sys/compat/common/tty_60.c        |  19 ++++++++++++-----
 sys/compat/net/route_70.h         |   4 +-
 sys/kern/compat_stub.c            |   8 ++++++-
 sys/kern/tty.c                    |  40 +++++++++++++++++++++-----------------
 sys/kern/tty_ptm.c                |  25 +++++++++++++++++++++--
 sys/kern/uipc_usrreq.c            |  10 ++++----
 sys/sys/compat_stub.h             |   8 ++++++-
 sys/sys/module.h                  |   4 +--
 sys/sys/tty.h                     |   6 +----
 10 files changed, 84 insertions(+), 48 deletions(-)

diffs (truncated from 383 to 300 lines):

diff -r 6722467ee39c -r 8ce716e99be8 sys/compat/common/compat_70_mod.c
--- a/sys/compat/common/compat_70_mod.c Mon Oct 15 04:33:34 2018 +0000
+++ b/sys/compat/common/compat_70_mod.c Mon Oct 15 09:51:33 2018 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: compat_70_mod.c,v 1.1.2.10 2018/09/22 04:56:28 pgoyette Exp $  */
+/*     $NetBSD: compat_70_mod.c,v 1.1.2.11 2018/10/15 09:51:33 pgoyette Exp $  */
 
 /*-
  * Copyright (c) 2018 The NetBSD Foundation, Inc.
@@ -38,7 +38,7 @@
 #endif
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: compat_70_mod.c,v 1.1.2.10 2018/09/22 04:56:28 pgoyette Exp $");
+__KERNEL_RCSID(0, "$NetBSD: compat_70_mod.c,v 1.1.2.11 2018/10/15 09:51:33 pgoyette Exp $");
 
 #include <sys/systm.h>
 #include <sys/module.h>
@@ -56,7 +56,7 @@
 int compat_70_init(void)
 {
 
-       vec_ocreds_valid = true;
+       compat70_ocreds_valid = true;
        rtsock_70_init();
 
        return 0;
@@ -66,7 +66,7 @@
 {
 
        rtsock_70_fini();
-       vec_ocreds_valid = false;
+       compat70_ocreds_valid = false;
 
        return 0;
 }
diff -r 6722467ee39c -r 8ce716e99be8 sys/compat/common/tty_60.c
--- a/sys/compat/common/tty_60.c        Mon Oct 15 04:33:34 2018 +0000
+++ b/sys/compat/common/tty_60.c        Mon Oct 15 09:51:33 2018 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: tty_60.c,v 1.4.16.4 2018/09/04 02:21:58 pgoyette Exp $ */
+/*     $NetBSD: tty_60.c,v 1.4.16.5 2018/10/15 09:51:33 pgoyette Exp $ */
 
 /*-
  * Copyright (c) 2012 The NetBSD Foundation, Inc.
@@ -30,7 +30,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: tty_60.c,v 1.4.16.4 2018/09/04 02:21:58 pgoyette Exp $");
+__KERNEL_RCSID(0, "$NetBSD: tty_60.c,v 1.4.16.5 2018/10/15 09:51:33 pgoyette Exp $");
 
 #if defined(_KERNEL_OPT)
 #include "opt_compat_netbsd.h"
@@ -41,6 +41,7 @@
 #include <sys/conf.h>
 #include <sys/errno.h>
 #include <sys/systm.h>
+#include <sys/compat_stub.h>
 
 #include <sys/tty.h>
 
@@ -117,17 +118,23 @@
        }
 }
 
+/* 
+ * Hooks for compat_60 ttioctl and ptmioctl
+ */
+MODULE_SET_HOOK2(compat_60_ioctl_hook, "tty_60", compat_60_ttioctl,
+    compat_60_ptmioctl);
+MODULE_UNSET_HOOK2(compat_60_ioctl_hook);
+
+
 void
 kern_tty_60_init(void)
 {
 
-       vec_compat_ttioctl_60 = compat_60_ttioctl;
-       vec_compat_ptmioctl_60 = compat_60_ptmioctl;
+       compat_60_ioctl_hook_set();
 }
 
 void
 kern_tty_60_fini(void)
 {
-       vec_compat_ttioctl_60 = NULL;
-       vec_compat_ptmioctl_60 = stub_compat_ptmioctl_60;
+       compat_60_ioctl_hook_unset();
 }
diff -r 6722467ee39c -r 8ce716e99be8 sys/compat/net/route_70.h
--- a/sys/compat/net/route_70.h Mon Oct 15 04:33:34 2018 +0000
+++ b/sys/compat/net/route_70.h Mon Oct 15 09:51:33 2018 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: route_70.h,v 1.1.2.3 2018/10/15 04:33:34 pgoyette Exp $        */
+/*     $NetBSD: route_70.h,v 1.1.2.4 2018/10/15 09:51:33 pgoyette Exp $        */
 
 /*-
  * Copyright (c) 2018 The NetBSD Foundation, Inc.
@@ -39,6 +39,6 @@
 void rtsock_70_init(void);
 void rtsock_70_fini(void);
 
-extern bool vec_ocreds_valid;
+extern bool compat70_ocreds_valid;
 
 #endif /* !_COMPAT_NET_ROUTE_70_H_ */
diff -r 6722467ee39c -r 8ce716e99be8 sys/kern/compat_stub.c
--- a/sys/kern/compat_stub.c    Mon Oct 15 04:33:34 2018 +0000
+++ b/sys/kern/compat_stub.c    Mon Oct 15 09:51:33 2018 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: compat_stub.c,v 1.1.2.28 2018/10/15 04:33:34 pgoyette Exp $        */
+/* $NetBSD: compat_stub.c,v 1.1.2.29 2018/10/15 09:51:33 pgoyette Exp $        */
 
 /*-
  * Copyright (c) 2018 The NetBSD Foundation, Inc.
@@ -187,3 +187,9 @@
  */
 struct rnd_ioctl_50_hook_t rnd_ioctl_50_hook;
 struct rnd_ioctl_50_32_hook_t rnd_ioctl_50_32_hook;
+
+/* 
+ * Hooks for compat_60 ttioctl and ptmioctl
+ */
+struct compat_60_ioctl_hook_t compat_60_ioctl_hook;
+
diff -r 6722467ee39c -r 8ce716e99be8 sys/kern/tty.c
--- a/sys/kern/tty.c    Mon Oct 15 04:33:34 2018 +0000
+++ b/sys/kern/tty.c    Mon Oct 15 09:51:33 2018 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: tty.c,v 1.275.2.4 2018/09/06 06:56:42 pgoyette Exp $   */
+/*     $NetBSD: tty.c,v 1.275.2.5 2018/10/15 09:51:33 pgoyette Exp $   */
 
 /*-
  * Copyright (c) 2008 The NetBSD Foundation, Inc.
@@ -63,7 +63,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: tty.c,v 1.275.2.4 2018/09/06 06:56:42 pgoyette Exp $");
+__KERNEL_RCSID(0, "$NetBSD: tty.c,v 1.275.2.5 2018/10/15 09:51:33 pgoyette Exp $");
 
 #ifdef _KERNEL_OPT
 #include "opt_compat_netbsd.h"
@@ -98,6 +98,7 @@
 #include <sys/ioctl_compat.h>
 #include <sys/module.h>
 #include <sys/bitops.h>
+#include <sys/compat_stub.h>
 
 #ifdef COMPAT_60
 #include <compat/sys/ttycom.h>
@@ -209,9 +210,6 @@
 int tty_count;
 kmutex_t tty_lock;
 krwlock_t ttcompat_lock;
-int (*vec_compat_ttioctl_60)(dev_t, u_long, void *, int, struct lwp *) = NULL;
-int (*vec_compat_ptmioctl_60)(dev_t, u_long, void *, int, struct lwp *) =
-    stub_compat_ptmioctl_60;
 
 struct ptm_pty *ptm = NULL;
 
@@ -921,6 +919,15 @@
 }
 
 /*
+ * MODULE_HOOK glue for compat_60_ttioctl
+ */
+MODULE_CALL_HOOK_DECL(compat_60_ioctl_hook, f1, 
+    (dev_t, u_long, void *, int, struct lwp *));
+MODULE_CALL_HOOK(compat_60_ioctl_hook, f1, 
+    (dev_t dev, u_long cmd, void *data, int flag, struct lwp *l),
+    (dev, cmd, data, flag, l), enosys());
+    
+/*
  * Ioctls for all tty devices.  Called after line-discipline specific ioctl
  * has been called to do discipline-specific functions and/or reject any
  * of these ioctl commands.
@@ -1412,19 +1419,24 @@
                default:
                        break;
                }
-               /* We may have to load the compat module for this. */
+               /* We may have to load the compat_60 module for this. */
                for (;;) {
                        rw_enter(&ttcompat_lock, RW_READER);
-                       if (vec_compat_ttioctl_60 != NULL) {
+                       error = compat_60_ioctl_hook_f1_call(tp->t_dev, cmd,
+                           data, flag, l);
+                       if (error != ENOSYS) {
                                break;
                        }
                        rw_exit(&ttcompat_lock);
-                       (void)module_autoload("compat", MODULE_CLASS_EXEC);
-                       if (vec_compat_ttioctl_60 == NULL) {
+                       (void)module_autoload("compat_60", MODULE_CLASS_EXEC);
+                       rw_enter(&ttcompat_lock, RW_READER);
+                       error = compat_60_ioctl_hook_f1_call(tp->t_dev, cmd,
+                           data, flag, l);
+                       if (error == ENOSYS) {
+                               rw_exit(&ttcompat_lock);
                                return EPASSTHROUGH;
                        }
                }
-               error = (*vec_compat_ttioctl_60)(tp->t_dev, cmd, data, flag, l);
                rw_exit(&ttcompat_lock);
                return error;
        }
@@ -3068,11 +3080,3 @@
     }
     return EAGAIN;
 }
-
-int
-stub_compat_ptmioctl_60(dev_t dev, u_long cmd, void *data, int flag,
-    struct lwp *l)
-{
-
-       return EPASSTHROUGH;
-}
diff -r 6722467ee39c -r 8ce716e99be8 sys/kern/tty_ptm.c
--- a/sys/kern/tty_ptm.c        Mon Oct 15 04:33:34 2018 +0000
+++ b/sys/kern/tty_ptm.c        Mon Oct 15 09:51:33 2018 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: tty_ptm.c,v 1.37.16.1 2018/09/04 02:21:58 pgoyette Exp $       */
+/*     $NetBSD: tty_ptm.c,v 1.37.16.2 2018/10/15 09:51:34 pgoyette Exp $       */
 
 /*-
  * Copyright (c) 2004 The NetBSD Foundation, Inc.
@@ -27,7 +27,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: tty_ptm.c,v 1.37.16.1 2018/09/04 02:21:58 pgoyette Exp $");
+__KERNEL_RCSID(0, "$NetBSD: tty_ptm.c,v 1.37.16.2 2018/10/15 09:51:34 pgoyette Exp $");
 
 #ifdef _KERNEL_OPT
 #include "opt_compat_netbsd.h"
@@ -53,6 +53,7 @@
 #include <sys/poll.h>
 #include <sys/pty.h>
 #include <sys/kauth.h>
+#include <sys/compat_stub.h>
 
 #include <miscfs/specfs/specdev.h>
 
@@ -372,6 +373,24 @@
        return (0);
 }
 
+/*
+ * MODULE_HOOK glue for ptmioctl_60
+ */
+
+int                     
+stub_compat_ptmioctl_60(dev_t dev, u_long cmd, void *data, int flag,
+    struct lwp *l)
+{               
+        
+        return EPASSTHROUGH;
+}
+
+MODULE_CALL_HOOK_DECL(compat_60_ioctl_hook, f2,
+    (dev_t, u_long, void *, int, struct lwp *));
+MODULE_CALL_HOOK(compat_60_ioctl_hook, f2,
+    (dev_t dev, u_long cmd, void *data, int flag, struct lwp *l),
+    (dev, cmd, data, flag, l), enosys());
+
 static int
 /*ARGSUSED*/
 ptmioctl(dev_t dev, u_long cmd, void *data, int flag, struct lwp *l)
@@ -402,7 +421,7 @@
                        goto bad2;
                return 0;
        default:
-               error = (*vec_compat_ptmioctl_60)(dev, cmd, data, flag, l);
+               error = compat_60_ioctl_hook_f2_call(dev, cmd, data, flag, l);
                if (error != EPASSTHROUGH)
                        return error;
                DPRINTF(("ptmioctl EINVAL\n"));
diff -r 6722467ee39c -r 8ce716e99be8 sys/kern/uipc_usrreq.c
--- a/sys/kern/uipc_usrreq.c    Mon Oct 15 04:33:34 2018 +0000
+++ b/sys/kern/uipc_usrreq.c    Mon Oct 15 09:51:33 2018 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: uipc_usrreq.c,v 1.183.2.3 2018/05/21 04:36:15 pgoyette Exp $   */
+/*     $NetBSD: uipc_usrreq.c,v 1.183.2.4 2018/10/15 09:51:34 pgoyette Exp $   */
 
 /*-
  * Copyright (c) 1998, 2000, 2004, 2008, 2009 The NetBSD Foundation, Inc.
@@ -96,7 +96,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: uipc_usrreq.c,v 1.183.2.3 2018/05/21 04:36:15 pgoyette Exp $");
+__KERNEL_RCSID(0, "$NetBSD: uipc_usrreq.c,v 1.183.2.4 2018/10/15 09:51:34 pgoyette Exp $");
 
 #ifdef _KERNEL_OPT
 #include "opt_compat_netbsd.h"
@@ -209,7 +209,7 @@
        return control;



Home | Main Index | Thread Index | Old Index