Source-Changes-HG archive

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

[src/trunk]: src/sys - provide a hook for the 43 tty ioctls



details:   https://anonhg.NetBSD.org/src/rev/1a79ff198002
branches:  trunk
changeset: 838712:1a79ff198002
user:      christos <christos%NetBSD.org@localhost>
date:      Mon Jan 28 15:46:49 2019 +0000

description:
- provide a hook for the 43 tty ioctls
- make the 60 tty ioctl hook look the same
- fix the tty code to call both hooks and remove unused lock

diffstat:

 sys/compat/common/compat_43_mod.c |  12 ++++++------
 sys/compat/common/compat_mod.h    |   6 +++---
 sys/compat/common/tty_43.c        |  19 +++++++++++--------
 sys/compat/common/tty_60.c        |  11 ++++++-----
 sys/compat/sys/ttycom.h           |  12 ++++++++++--
 sys/kern/compat_stub.c            |  11 ++++++++---
 sys/kern/tty.c                    |  35 +++++++++++++----------------------
 sys/sys/compat_stub.h             |  12 ++++++++++--
 8 files changed, 67 insertions(+), 51 deletions(-)

diffs (truncated from 353 to 300 lines):

diff -r 365d68470e76 -r 1a79ff198002 sys/compat/common/compat_43_mod.c
--- a/sys/compat/common/compat_43_mod.c Mon Jan 28 13:13:02 2019 +0000
+++ b/sys/compat/common/compat_43_mod.c Mon Jan 28 15:46:49 2019 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: compat_43_mod.c,v 1.2 2019/01/27 02:08:39 pgoyette Exp $       */
+/*     $NetBSD: compat_43_mod.c,v 1.3 2019/01/28 15:46:49 christos Exp $       */
 
 /*-
  * Copyright (c) 2018 The NetBSD Foundation, Inc.
@@ -30,7 +30,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: compat_43_mod.c,v 1.2 2019/01/27 02:08:39 pgoyette Exp $");
+__KERNEL_RCSID(0, "$NetBSD: compat_43_mod.c,v 1.3 2019/01/28 15:46:49 christos Exp $");
 
 #if defined(_KERNEL_OPT)
 #include "opt_compat_netbsd.h"
@@ -67,7 +67,7 @@
        if (error != 0)
                goto out6;
 
-       error = tty_43_init();
+       error = kern_tty_43_init();
        if (error != 0)
                goto out5;
 
@@ -96,7 +96,7 @@
  out3:
        uipc_syscalls_43_fini();
  out4:
-       tty_43_fini();
+       kern_tty_43_fini();
  out5:
        kern_sig_43_fini();
  out6:
@@ -130,7 +130,7 @@
        if (error != 0)
                goto out6;
 
-       error = tty_43_fini();
+       error = kern_tty_43_fini();
        if (error != 0)
                goto out5;
 
@@ -159,7 +159,7 @@
  out3:
        kern_sig_43_init();
  out4:
-       tty_43_init();
+       kern_tty_43_init();
  out5:
        uipc_syscalls_43_init();
  out6:
diff -r 365d68470e76 -r 1a79ff198002 sys/compat/common/compat_mod.h
--- a/sys/compat/common/compat_mod.h    Mon Jan 28 13:13:02 2019 +0000
+++ b/sys/compat/common/compat_mod.h    Mon Jan 28 15:46:49 2019 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: compat_mod.h,v 1.2 2019/01/27 02:08:39 pgoyette Exp $  */
+/*     $NetBSD: compat_mod.h,v 1.3 2019/01/28 15:46:49 christos Exp $  */
 
 /*-
  * Copyright (c) 2013 The NetBSD Foundation, Inc.
@@ -176,8 +176,8 @@
 int kern_resource_43_fini(void);
 int kern_sig_43_init(void);
 int kern_sig_43_fini(void);
-int tty_43_init(void);
-int tty_43_fini(void);
+int kern_tty_43_init(void);
+int kern_tty_43_fini(void);
 int uipc_syscalls_43_init(void);
 int uipc_syscalls_43_fini(void);
 int vfs_syscalls_43_init(void);
diff -r 365d68470e76 -r 1a79ff198002 sys/compat/common/tty_43.c
--- a/sys/compat/common/tty_43.c        Mon Jan 28 13:13:02 2019 +0000
+++ b/sys/compat/common/tty_43.c        Mon Jan 28 15:46:49 2019 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: tty_43.c,v 1.31 2019/01/27 02:08:39 pgoyette Exp $     */
+/*     $NetBSD: tty_43.c,v 1.32 2019/01/28 15:46:49 christos Exp $     */
 
 /*-
  * Copyright (c) 2008 The NetBSD Foundation, Inc.
@@ -62,7 +62,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: tty_43.c,v 1.31 2019/01/27 02:08:39 pgoyette Exp $");
+__KERNEL_RCSID(0, "$NetBSD: tty_43.c,v 1.32 2019/01/28 15:46:49 christos Exp $");
 
 #if defined(_KERNEL_OPT)
 #include "opt_compat_netbsd.h"
@@ -78,9 +78,12 @@
 #include <sys/file.h>
 #include <sys/kernel.h>
 #include <sys/syslog.h>
+#include <sys/compat_stub.h>
+#include <sys/module_hook.h>
 #include <sys/ioctl_compat.h>
 
 #include <compat/common/compat_mod.h>
+#include <compat/sys/ttycom.h>
 
 int ttydebug = 0;
 
@@ -114,11 +117,11 @@
 static int ttcompatgetflags(struct tty *);
 static void ttcompatsetflags(struct tty *, struct termios *);
 static void ttcompatsetlflags(struct tty *, struct termios *);
-int    ttcompat(struct tty *, u_long, void *, int, struct lwp *);
 
 /*ARGSUSED*/
 int
-ttcompat(struct tty *tp, u_long com, void *data, int flag, struct lwp *l)
+compat_43_ttioctl(struct tty *tp, u_long com, void *data, int flag,
+    struct lwp *l)
 {
 
        switch (com) {
@@ -513,15 +516,15 @@
 }
 
 int
-tty_43_init(void)
+kern_tty_43_init(void)
 {
-
+       MODULE_SET_HOOK(compat_43_ttioctl_hook, "tty_43", compat_43_ttioctl);
        return 0;
 }
 
 int
-tty_43_fini(void)
+kern_tty_43_fini(void)
 {
-
+       MODULE_UNSET_HOOK(compat_43_ttioctl_hook);
        return 0;
 }
diff -r 365d68470e76 -r 1a79ff198002 sys/compat/common/tty_60.c
--- a/sys/compat/common/tty_60.c        Mon Jan 28 13:13:02 2019 +0000
+++ b/sys/compat/common/tty_60.c        Mon Jan 28 15:46:49 2019 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: tty_60.c,v 1.5 2019/01/27 02:08:39 pgoyette Exp $      */
+/*     $NetBSD: tty_60.c,v 1.6 2019/01/28 15:46:49 christos 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.5 2019/01/27 02:08:39 pgoyette Exp $");
+__KERNEL_RCSID(0, "$NetBSD: tty_60.c,v 1.6 2019/01/28 15:46:49 christos Exp $");
 
 #if defined(_KERNEL_OPT)
 #include "opt_compat_netbsd.h"
@@ -93,21 +93,22 @@
  * COMPAT_60 versions of ttioctl and ptmioctl.
  */
 int
-compat_60_ttioctl(dev_t dev, u_long cmd, void *data, int flag,
+compat_60_ttioctl(struct tty *tp, u_long cmd, void *data, int flag,
        struct lwp *l)
 {
 
        switch (cmd) {
        case COMPAT_60_TIOCPTMGET:
        case COMPAT_60_TIOCPTSNAME:
-               return compat_60_ptmget_ioctl(dev, cmd, data, flag, l);
+               return compat_60_ptmget_ioctl(tp->t_dev, cmd, data, flag, l);
        default:
                return EPASSTHROUGH;
        }
 }
 
 int
-compat_60_ptmioctl(dev_t dev, u_long cmd, void *data, int flag, struct lwp *l)
+compat_60_ptmioctl(dev_t dev, u_long cmd, void *data, int flag,
+    struct lwp *l)
 {
 
        switch (cmd) {
diff -r 365d68470e76 -r 1a79ff198002 sys/compat/sys/ttycom.h
--- a/sys/compat/sys/ttycom.h   Mon Jan 28 13:13:02 2019 +0000
+++ b/sys/compat/sys/ttycom.h   Mon Jan 28 15:46:49 2019 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: ttycom.h,v 1.3 2019/01/27 02:08:41 pgoyette Exp $      */
+/*     $NetBSD: ttycom.h,v 1.4 2019/01/28 15:46:49 christos Exp $      */
 
 /*-
  * Copyright (c) 2012 The NetBSD Foundation, Inc.
@@ -40,6 +40,8 @@
 #include <sys/types.h>
 #include <sys/ioctl.h>
 
+struct tty;
+
 #ifdef COMPAT_60
 
 /*
@@ -57,10 +59,16 @@
 #define COMPAT_60_TIOCPTSNAME   _IOR('t', 72, struct compat_60_ptmget)
 
 #ifdef _KERNEL
-int compat_60_ttioctl(dev_t, u_long, void *, int, struct lwp *);
+int compat_60_ttioctl(struct tty *, u_long, void *, int, struct lwp *);
 int compat_60_ptmioctl(dev_t, u_long, void *, int, struct lwp *);
 #endif
 
 #endif /* COMPAT_60 */
 
+#ifdef COMPAT_43
+#ifdef _KERNEL
+int compat_43_ttioctl(struct tty *, u_long, void *, int, struct lwp *);
+#endif
+#endif
+
 #endif /* !_COMPAT_SYS_TTYCOM_H_ */
diff -r 365d68470e76 -r 1a79ff198002 sys/kern/compat_stub.c
--- a/sys/kern/compat_stub.c    Mon Jan 28 13:13:02 2019 +0000
+++ b/sys/kern/compat_stub.c    Mon Jan 28 15:46:49 2019 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: compat_stub.c,v 1.2 2019/01/27 02:08:43 pgoyette Exp $     */
+/* $NetBSD: compat_stub.c,v 1.3 2019/01/28 15:46:49 christos Exp $     */
 
 /*-
  * Copyright (c) 2018 The NetBSD Foundation, Inc.
@@ -166,13 +166,18 @@
  */
 struct if43_20_hook_t if43_20_hook;
 
+/* 
+ * tty 43 ioctl compatibility
+ */
+struct compat_43_ttioctl_hook_t compat_43_ttioctl_hook;
+
 /*
- * upic_syscalls_40 compatability
+ * uipc_syscalls_40 compatability
  */
 struct uipc_syscalls_40_hook_t uipc_syscalls_40_hook;
 
 /*
- * upic_syscalls_50 compatability
+ * uipc_syscalls_50 compatability
  */
 struct uipc_syscalls_50_hook_t uipc_syscalls_50_hook;
 
diff -r 365d68470e76 -r 1a79ff198002 sys/kern/tty.c
--- a/sys/kern/tty.c    Mon Jan 28 13:13:02 2019 +0000
+++ b/sys/kern/tty.c    Mon Jan 28 15:46:49 2019 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: tty.c,v 1.278 2019/01/27 02:08:43 pgoyette Exp $       */
+/*     $NetBSD: tty.c,v 1.279 2019/01/28 15:46:49 christos Exp $       */
 
 /*-
  * Copyright (c) 2008 The NetBSD Foundation, Inc.
@@ -63,7 +63,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: tty.c,v 1.278 2019/01/27 02:08:43 pgoyette Exp $");
+__KERNEL_RCSID(0, "$NetBSD: tty.c,v 1.279 2019/01/28 15:46:49 christos Exp $");
 
 #ifdef _KERNEL_OPT
 #include "opt_compat_netbsd.h"
@@ -209,7 +209,6 @@
 struct ttylist_head ttylist = TAILQ_HEAD_INITIALIZER(ttylist);
 int tty_count;
 kmutex_t tty_lock;
-krwlock_t ttcompat_lock;
 
 struct ptm_pty *ptm = NULL;
 
@@ -1410,25 +1409,18 @@
                default:
                        break;
                }
+
                /* We may have to load the compat_60 module for this. */
-               for (;;) {
-                       rw_enter(&ttcompat_lock, RW_READER);
-                       MODULE_CALL_HOOK(compat_60_ttioctl_hook,
-                           (tp->t_dev, cmd, data, flag, l), enosys(), error);
-                       if (error != ENOSYS) {
-                               break;
-                       }
-                       rw_exit(&ttcompat_lock);
-                       (void)module_autoload("compat_60", MODULE_CLASS_EXEC);
-                       rw_enter(&ttcompat_lock, RW_READER);
-                       MODULE_CALL_HOOK(compat_60_ttioctl_hook,
-                           (tp->t_dev, cmd, data, flag, l), enosys(), error);
-                       if (error == ENOSYS) {
-                               rw_exit(&ttcompat_lock);
-                               return EPASSTHROUGH;
-                       }
-               }
-               rw_exit(&ttcompat_lock);
+               (void)module_autoload("compat_60", MODULE_CLASS_EXEC);



Home | Main Index | Thread Index | Old Index