summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJustus Winter <4winter@informatik.uni-hamburg.de>2014-02-28 11:26:07 +0100
committerJustus Winter <4winter@informatik.uni-hamburg.de>2014-02-28 11:26:07 +0100
commit20d3ffa76a849e2105e72e6b7c8835de5e9c1b21 (patch)
tree499494cc69d012de99c840c53bcf0f50adf6b985
parenta876dbadbb1fa625e3e5fa8bdffe803e6eb473d1 (diff)
term: fix receiver lookups in the tioctl server functions
* term/mig-mutate.h: New file. * term/Makefile: Set tioctl-MIGSFLAGS. * term/ptyio.c: Fix receiver lookups in the tioctl server functions. * term/users.c: Likewise.
-rw-r--r--term/Makefile2
-rw-r--r--term/mig-mutate.h24
-rw-r--r--term/ptyio.c48
-rw-r--r--term/users.c225
4 files changed, 130 insertions, 169 deletions
diff --git a/term/Makefile b/term/Makefile
index 025a9b39..9537c601 100644
--- a/term/Makefile
+++ b/term/Makefile
@@ -32,3 +32,5 @@ OBJS = $(subst .c,.o,$(SRCS)) termServer.o device_replyServer.o tioctlServer.o o
include ../Makeconf
device_replyServer-CPPFLAGS = -DTypeCheck=0 -Wno-unused # XXX
+
+tioctl-MIGSFLAGS = -imacros $(srcdir)/mig-mutate.h
diff --git a/term/mig-mutate.h b/term/mig-mutate.h
new file mode 100644
index 00000000..7cc13aaa
--- /dev/null
+++ b/term/mig-mutate.h
@@ -0,0 +1,24 @@
+/*
+ Copyright (C) 2014 Free Software Foundation, Inc.
+ Written by Justus Winter.
+
+ This file is part of the GNU Hurd.
+
+ The GNU Hurd is free software; you can redistribute it and/or
+ modify it under the terms of the GNU General Public License as
+ published by the Free Software Foundation; either version 2, or (at
+ your option) any later version.
+
+ The GNU Hurd is distributed in the hope that it will be useful, but
+ WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with the GNU Hurd. If not, see <http://www.gnu.org/licenses/>. */
+
+/* Only CPP macro definitions should go in this file. */
+
+#define IO_INTRAN trivfs_protid_t trivfs_begin_using_protid (io_t)
+#define IO_DESTRUCTOR trivfs_end_using_protid (trivfs_protid_t)
+#define TIOCTL_IMPORTS import "../libtrivfs/mig-decls.h";
diff --git a/term/ptyio.c b/term/ptyio.c
index 2da7d6c8..211e70a8 100644
--- a/term/ptyio.c
+++ b/term/ptyio.c
@@ -512,12 +512,12 @@ pty_io_select (struct trivfs_protid *cred, mach_port_t reply,
}
error_t
-S_tioctl_tiocsig (io_t port,
+S_tioctl_tiocsig (struct trivfs_protid *cred,
int sig)
{
- struct trivfs_protid *cred = ports_lookup_port (term_bucket,
- port, pty_class);
- if (!cred)
+ if (!cred
+ || cred->pi.bucket != term_bucket
+ || cred->pi.class != pty_class)
return EOPNOTSUPP;
pthread_mutex_lock (&global_lock);
@@ -529,20 +529,18 @@ S_tioctl_tiocsig (io_t port,
send_signal (sig);
pthread_mutex_unlock (&global_lock);
- ports_port_deref (cred);
return 0;
}
error_t
-S_tioctl_tiocpkt (io_t port,
+S_tioctl_tiocpkt (struct trivfs_protid *cred,
int mode)
{
error_t err;
-
- struct trivfs_protid *cred = ports_lookup_port (term_bucket,
- port, pty_class);
- if (!cred)
+ if (!cred
+ || cred->pi.bucket != term_bucket
+ || cred->pi.class != pty_class)
return EOPNOTSUPP;
pthread_mutex_lock (&global_lock);
@@ -559,20 +557,18 @@ S_tioctl_tiocpkt (io_t port,
}
pthread_mutex_unlock (&global_lock);
- ports_port_deref (cred);
return err;
}
error_t
-S_tioctl_tiocucntl (io_t port,
+S_tioctl_tiocucntl (struct trivfs_protid *cred,
int mode)
{
error_t err;
-
- struct trivfs_protid *cred = ports_lookup_port (term_bucket,
- port, pty_class);
- if (!cred)
+ if (!cred
+ || cred->pi.bucket != term_bucket
+ || cred->pi.class != pty_class)
return EOPNOTSUPP;
pthread_mutex_lock (&global_lock);
@@ -589,19 +585,17 @@ S_tioctl_tiocucntl (io_t port,
}
pthread_mutex_unlock (&global_lock);
- ports_port_deref (cred);
return err;
}
error_t
-S_tioctl_tiocremote (io_t port,
+S_tioctl_tiocremote (struct trivfs_protid *cred,
int how)
{
- struct trivfs_protid *cred = ports_lookup_port (term_bucket,
- port, pty_class);
-
- if (!cred)
+ if (!cred
+ || cred->pi.bucket != term_bucket
+ || cred->pi.class != pty_class)
return EOPNOTSUPP;
pthread_mutex_lock (&global_lock);
@@ -611,17 +605,16 @@ S_tioctl_tiocremote (io_t port,
clear_queue (rawq);
ptyio_notice_input_flushed ();
pthread_mutex_unlock (&global_lock);
- ports_port_deref (cred);
return 0;
}
error_t
-S_tioctl_tiocext (io_t port,
+S_tioctl_tiocext (struct trivfs_protid *cred,
int mode)
{
- struct trivfs_protid *cred = ports_lookup_port (term_bucket,
- port, pty_class);
- if (!cred)
+ if (!cred
+ || cred->pi.bucket != term_bucket
+ || cred->pi.class != pty_class)
return EOPNOTSUPP;
pthread_mutex_lock (&global_lock);
@@ -646,6 +639,5 @@ S_tioctl_tiocext (io_t port,
termstate.c_lflag &= ~EXTPROC;
}
pthread_mutex_unlock (&global_lock);
- ports_port_deref (cred);
return 0;
}
diff --git a/term/users.c b/term/users.c
index eacd150a..3f558390 100644
--- a/term/users.c
+++ b/term/users.c
@@ -902,19 +902,18 @@ trivfs_S_io_revoke (struct trivfs_protid *cred,
/* TIOCMODG ioctl -- Get modem state */
kern_return_t
-S_tioctl_tiocmodg (io_t port,
+S_tioctl_tiocmodg (struct trivfs_protid *cred,
int *state)
{
- struct trivfs_protid *cred = ports_lookup_port (term_bucket, port, 0);
error_t err = 0;
- if (!cred)
+ if (!cred
+ || cred->pi.bucket != term_bucket)
return EOPNOTSUPP;
if (cred->pi.class != pty_class
&& cred->pi.class != tty_class)
{
- ports_port_deref (cred);
return EOPNOTSUPP;
}
@@ -922,24 +921,22 @@ S_tioctl_tiocmodg (io_t port,
err = (*bottom->mdmstate) (state);
pthread_mutex_unlock (&global_lock);
- ports_port_deref (cred);
return err;
}
/* TIOCMODS ioctl -- Set modem state */
kern_return_t
-S_tioctl_tiocmods (io_t port,
+S_tioctl_tiocmods (struct trivfs_protid *cred,
int state)
{
- struct trivfs_protid *cred = ports_lookup_port (term_bucket, port, 0);
error_t err;
- if (!cred)
+ if (!cred
+ || cred->pi.bucket != term_bucket)
return EOPNOTSUPP;
if (cred->pi.class != pty_class
&& cred->pi.class != tty_class)
{
- ports_port_deref (cred);
return EOPNOTSUPP;
}
@@ -952,23 +949,21 @@ S_tioctl_tiocmods (io_t port,
pthread_mutex_unlock (&global_lock);
- ports_port_deref (cred);
return err;
}
/* TIOCEXCL ioctl -- Set exclusive use */
kern_return_t
-S_tioctl_tiocexcl (io_t port)
+S_tioctl_tiocexcl (struct trivfs_protid *cred)
{
- struct trivfs_protid *cred = ports_lookup_port (term_bucket, port, 0);
error_t err;
- if (!cred)
+ if (!cred
+ || cred->pi.bucket != term_bucket)
return EOPNOTSUPP;
if (cred->pi.class != pty_class
&& cred->pi.class != tty_class)
{
- ports_port_deref (cred);
return EOPNOTSUPP;
}
@@ -983,24 +978,22 @@ S_tioctl_tiocexcl (io_t port)
}
pthread_mutex_unlock (&global_lock);
- ports_port_deref (cred);
return err;
}
/* TIOCNXCL ioctl -- Clear exclusive use */
kern_return_t
-S_tioctl_tiocnxcl (io_t port)
+S_tioctl_tiocnxcl (struct trivfs_protid *cred)
{
- struct trivfs_protid *cred = ports_lookup_port (term_bucket, port, 0);
error_t err;
- if (!cred)
+ if (!cred
+ || cred->pi.bucket != term_bucket)
return EOPNOTSUPP;
if (cred->pi.class != pty_class
&& cred->pi.class != tty_class)
{
- ports_port_deref (cred);
return EOPNOTSUPP;
}
@@ -1014,25 +1007,23 @@ S_tioctl_tiocnxcl (io_t port)
}
pthread_mutex_unlock (&global_lock);
- ports_port_deref (cred);
return err;
}
/* TIOCFLUSH ioctl -- Flush input, output, or both */
kern_return_t
-S_tioctl_tiocflush (io_t port,
+S_tioctl_tiocflush (struct trivfs_protid *cred,
int flags)
{
- struct trivfs_protid *cred = ports_lookup_port (term_bucket, port, 0);
error_t err = 0;
- if (!cred)
+ if (!cred
+ || cred->pi.bucket != term_bucket)
return EOPNOTSUPP;
if (cred->pi.class != pty_class
&& cred->pi.class != tty_class)
{
- ports_port_deref (cred);
return EOPNOTSUPP;
}
@@ -1056,26 +1047,23 @@ S_tioctl_tiocflush (io_t port,
}
pthread_mutex_unlock (&global_lock);
- ports_port_deref (cred);
return err;
}
/* TIOCGETA ioctl -- Get termios state */
kern_return_t
-S_tioctl_tiocgeta (io_t port,
+S_tioctl_tiocgeta (struct trivfs_protid *cred,
tcflag_t *modes,
cc_t *ccs,
speed_t *speeds)
{
- struct trivfs_protid *cred = ports_lookup_port (term_bucket, port, 0);
-
- if (!cred)
+ if (!cred
+ || cred->pi.bucket != term_bucket)
return EOPNOTSUPP;
if (cred->pi.class != pty_class
&& cred->pi.class != tty_class)
{
- ports_port_deref (cred);
return EOPNOTSUPP;
}
@@ -1089,30 +1077,28 @@ S_tioctl_tiocgeta (io_t port,
speeds[1] = termstate.__ospeed;
pthread_mutex_unlock (&global_lock);
- ports_port_deref (cred);
return 0;
}
/* Common code for the varios TIOCSET* commands. */
static error_t
-set_state (io_t port,
+set_state (struct trivfs_protid *cred,
tcflag_t *modes,
cc_t *ccs,
speed_t *speeds,
int draino,
int flushi)
{
- struct trivfs_protid *cred = ports_lookup_port (term_bucket, port, 0);
error_t err;
struct termios state;
- if (!cred)
+ if (!cred
+ || cred->pi.bucket != term_bucket)
return EOPNOTSUPP;
if (cred->pi.class != pty_class
&& cred->pi.class != tty_class)
{
- ports_port_deref (cred);
return EOPNOTSUPP;
}
@@ -1181,80 +1167,75 @@ set_state (io_t port,
leave:
pthread_mutex_unlock (&global_lock);
- ports_port_deref (cred);
return err;
}
/* TIOCSETA -- Set termios state */
kern_return_t
-S_tioctl_tiocseta (io_t port,
+S_tioctl_tiocseta (struct trivfs_protid *cred,
tcflag_t *modes,
cc_t *ccs,
speed_t *speeds)
{
- return set_state (port, modes, ccs, speeds, 0, 0);
+ return set_state (cred, modes, ccs, speeds, 0, 0);
}
/* Drain output, then set term state. */
kern_return_t
-S_tioctl_tiocsetaw (io_t port,
+S_tioctl_tiocsetaw (struct trivfs_protid *cred,
tcflag_t *modes,
cc_t *ccs,
speed_t *speeds)
{
- return set_state (port, modes, ccs, speeds, 1, 0);
+ return set_state (cred, modes, ccs, speeds, 1, 0);
}
/* Flush input, drain output, then set term state. */
kern_return_t
-S_tioctl_tiocsetaf (io_t port,
+S_tioctl_tiocsetaf (struct trivfs_protid *cred,
tcflag_t *modes,
cc_t *ccs,
speed_t *speeds)
{
- return set_state (port, modes, ccs, speeds, 1, 1);
+ return set_state (cred, modes, ccs, speeds, 1, 1);
}
/* TIOCGETD -- Return line discipline */
kern_return_t
-S_tioctl_tiocgetd (io_t port,
+S_tioctl_tiocgetd (struct trivfs_protid *cred,
int *disc)
{
- struct trivfs_protid *cred = ports_lookup_port (term_bucket, port, 0);
-
- if (!cred)
+ if (!cred
+ || cred->pi.bucket != term_bucket)
return EOPNOTSUPP;
if (cred->pi.class != pty_class
&& cred->pi.class != tty_class)
{
- ports_port_deref (cred);
return EOPNOTSUPP;
}
*disc = 0;
- ports_port_deref (cred);
return 0;
}
/* TIOCSETD -- Set line discipline */
kern_return_t
-S_tioctl_tiocsetd (io_t port,
+S_tioctl_tiocsetd (struct trivfs_protid *cred,
int disc)
{
- struct trivfs_protid *cred = ports_lookup_port (term_bucket, port, 0);
error_t err;
- if (!cred)
+ if (!cred
+ || cred->pi.bucket != term_bucket)
return EOPNOTSUPP;
if (cred->pi.class != pty_class
&& cred->pi.class != tty_class)
{
- ports_port_deref (cred);
return EOPNOTSUPP;
}
@@ -1268,24 +1249,22 @@ S_tioctl_tiocsetd (io_t port,
else
err = 0;
- ports_port_deref (cred);
return err;
}
/* TIOCDRAIN -- Wait for output to drain */
kern_return_t
-S_tioctl_tiocdrain (io_t port)
+S_tioctl_tiocdrain (struct trivfs_protid *cred)
{
- struct trivfs_protid *cred = ports_lookup_port (term_bucket, port, 0);
error_t err;
- if (!cred)
+ if (!cred
+ || cred->pi.bucket != term_bucket)
return EOPNOTSUPP;
if (cred->pi.class != pty_class
&& cred->pi.class != tty_class)
{
- ports_port_deref (cred);
return EOPNOTSUPP;
}
@@ -1293,31 +1272,28 @@ S_tioctl_tiocdrain (io_t port)
if (!(cred->po->openmodes & O_WRITE))
{
pthread_mutex_unlock (&global_lock);
- ports_port_deref (cred);
return EBADF;
}
err = drain_output ();
pthread_mutex_unlock (&global_lock);
- ports_port_deref (cred);
return err;
}
/* TIOCSWINSZ -- Set window size */
kern_return_t
-S_tioctl_tiocswinsz (io_t port,
+S_tioctl_tiocswinsz (struct trivfs_protid *cred,
struct winsize size)
{
- struct trivfs_protid *cred = ports_lookup_port (term_bucket, port, 0);
error_t err;
- if (!cred)
+ if (!cred
+ || cred->pi.bucket != term_bucket)
return EOPNOTSUPP;
if (cred->pi.class != pty_class
&& cred->pi.class != tty_class)
{
- ports_port_deref (cred);
return EOPNOTSUPP;
}
@@ -1328,8 +1304,6 @@ S_tioctl_tiocswinsz (io_t port,
else
err = 0;
- ports_port_deref (cred);
-
if (! err
&& (size.ws_row != window_size.ws_row
|| size.ws_col != window_size.ws_col
@@ -1348,18 +1322,16 @@ S_tioctl_tiocswinsz (io_t port,
/* TIOCGWINSZ -- Fetch window size */
kern_return_t
-S_tioctl_tiocgwinsz (io_t port,
+S_tioctl_tiocgwinsz (struct trivfs_protid *cred,
struct winsize *size)
{
- struct trivfs_protid *cred = ports_lookup_port (term_bucket, port, 0);
-
- if (!cred)
+ if (!cred
+ || cred->pi.bucket != term_bucket)
return EOPNOTSUPP;
if (cred->pi.class != pty_class
&& cred->pi.class != tty_class)
{
- ports_port_deref (cred);
return EOPNOTSUPP;
}
@@ -1367,25 +1339,23 @@ S_tioctl_tiocgwinsz (io_t port,
*size = window_size;
pthread_mutex_unlock (&global_lock);
- ports_port_deref (cred);
return 0;
}
/* TIOCMGET -- Fetch all modem bits */
kern_return_t
-S_tioctl_tiocmget (io_t port,
+S_tioctl_tiocmget (struct trivfs_protid *cred,
int *bits)
{
- struct trivfs_protid *cred = ports_lookup_port (term_bucket, port, 0);
error_t err = 0;
- if (!cred)
+ if (!cred
+ || cred->pi.bucket != term_bucket)
return EOPNOTSUPP;
if (cred->pi.class != pty_class
&& cred->pi.class != tty_class)
{
- ports_port_deref (cred);
return EOPNOTSUPP;
}
@@ -1393,25 +1363,23 @@ S_tioctl_tiocmget (io_t port,
err = (*bottom->mdmstate) (bits);
pthread_mutex_unlock (&global_lock);
- ports_port_deref (cred);
return err;
}
/* TIOCMSET -- Set all modem bits */
kern_return_t
-S_tioctl_tiocmset (io_t port,
+S_tioctl_tiocmset (struct trivfs_protid *cred,
int bits)
{
- struct trivfs_protid *cred = ports_lookup_port (term_bucket, port, 0);
error_t err;
- if (!cred)
+ if (!cred
+ || cred->pi.bucket != term_bucket)
return EOPNOTSUPP;
if (cred->pi.class != pty_class
&& cred->pi.class != tty_class)
{
- ports_port_deref (cred);
return EOPNOTSUPP;
}
@@ -1422,25 +1390,23 @@ S_tioctl_tiocmset (io_t port,
err = (*bottom->mdmctl) (MDMCTL_SET, bits);
pthread_mutex_unlock (&global_lock);
- ports_port_deref (cred);
return err;
}
/* TIOCMBIC -- Clear some modem bits */
kern_return_t
-S_tioctl_tiocmbic (io_t port,
+S_tioctl_tiocmbic (struct trivfs_protid *cred,
int bits)
{
- struct trivfs_protid *cred = ports_lookup_port (term_bucket, port, 0);
error_t err;
- if (!cred)
+ if (!cred
+ || cred->pi.bucket != term_bucket)
return EOPNOTSUPP;
if (cred->pi.class != pty_class
&& cred->pi.class != tty_class)
{
- ports_port_deref (cred);
return EOPNOTSUPP;
}
@@ -1451,25 +1417,23 @@ S_tioctl_tiocmbic (io_t port,
err = (*bottom->mdmctl) (MDMCTL_BIC, bits);
pthread_mutex_unlock (&global_lock);
- ports_port_deref (cred);
return err;
}
/* TIOCMBIS -- Set some modem bits */
kern_return_t
-S_tioctl_tiocmbis (io_t port,
+S_tioctl_tiocmbis (struct trivfs_protid *cred,
int bits)
{
- struct trivfs_protid *cred = ports_lookup_port (term_bucket, port, 0);
error_t err;
- if (!cred)
+ if (!cred
+ || cred->pi.bucket != term_bucket)
return EOPNOTSUPP;
if (cred->pi.class != pty_class
&& cred->pi.class != tty_class)
{
- ports_port_deref (cred);
return EOPNOTSUPP;
}
@@ -1480,24 +1444,22 @@ S_tioctl_tiocmbis (io_t port,
else
err = (*bottom->mdmctl) (MDMCTL_BIS, bits);
pthread_mutex_unlock (&global_lock);
- ports_port_deref (cred);
return err;
}
/* TIOCSTART -- start output as if VSTART were typed */
kern_return_t
-S_tioctl_tiocstart (io_t port)
+S_tioctl_tiocstart (struct trivfs_protid *cred)
{
- struct trivfs_protid *cred = ports_lookup_port (term_bucket, port, 0);
error_t err;
- if (!cred)
+ if (!cred
+ || cred->pi.bucket != term_bucket)
return EOPNOTSUPP;
if (cred->pi.class != pty_class
&& cred->pi.class != tty_class)
{
- ports_port_deref (cred);
return EOPNOTSUPP;
}
@@ -1516,24 +1478,22 @@ S_tioctl_tiocstart (io_t port)
}
pthread_mutex_unlock (&global_lock);
- ports_port_deref (cred);
return err;
}
/* TIOCSTOP -- stop output as if VSTOP were typed */
kern_return_t
-S_tioctl_tiocstop (io_t port)
+S_tioctl_tiocstop (struct trivfs_protid *cred)
{
- struct trivfs_protid *cred = ports_lookup_port (term_bucket, port, 0);
error_t err;
- if (!cred)
+ if (!cred
+ || cred->pi.bucket != term_bucket)
return EOPNOTSUPP;
if (cred->pi.class != pty_class
&& cred->pi.class != tty_class)
{
- ports_port_deref (cred);
return EOPNOTSUPP;
}
pthread_mutex_lock (&global_lock);
@@ -1550,25 +1510,23 @@ S_tioctl_tiocstop (io_t port)
}
pthread_mutex_unlock (&global_lock);
- ports_port_deref (cred);
return err;
}
/* TIOCSTI -- Simulate terminal input */
kern_return_t
-S_tioctl_tiocsti (io_t port,
+S_tioctl_tiocsti (struct trivfs_protid *cred,
char c)
{
- struct trivfs_protid *cred = ports_lookup_port (term_bucket, port, 0);
error_t err;
- if (!cred)
+ if (!cred
+ || cred->pi.bucket != term_bucket)
return EOPNOTSUPP;
if (cred->pi.class != pty_class
&& cred->pi.class != tty_class)
{
- ports_port_deref (cred);
return EOPNOTSUPP;
}
@@ -1587,25 +1545,23 @@ S_tioctl_tiocsti (io_t port,
}
pthread_mutex_unlock (&global_lock);
- ports_port_deref (cred);
return err;
}
/* TIOCOUTQ -- return output queue size */
kern_return_t
-S_tioctl_tiocoutq (io_t port,
+S_tioctl_tiocoutq (struct trivfs_protid *cred,
int *queue_size)
{
- struct trivfs_protid *cred = ports_lookup_port (term_bucket, port, 0);
error_t err;
- if (!cred)
+ if (!cred
+ || cred->pi.bucket != term_bucket)
return EOPNOTSUPP;
if (cred->pi.class != pty_class
&& cred->pi.class != tty_class)
{
- ports_port_deref (cred);
return EOPNOTSUPP;
}
@@ -1620,25 +1576,23 @@ S_tioctl_tiocoutq (io_t port,
}
pthread_mutex_unlock (&global_lock);
- ports_port_deref (cred);
return err;
}
/* TIOCSPGRP -- set pgrp of terminal */
kern_return_t
-S_tioctl_tiocspgrp (io_t port,
+S_tioctl_tiocspgrp (struct trivfs_protid *cred,
int pgrp)
{
- struct trivfs_protid *cred = ports_lookup_port (term_bucket, port, 0);
error_t err;
- if (!cred)
+ if (!cred
+ || cred->pi.bucket != term_bucket)
return EOPNOTSUPP;
if (cred->pi.class != pty_class
&& cred->pi.class != tty_class)
{
- ports_port_deref (cred);
return EOPNOTSUPP;
}
@@ -1653,25 +1607,23 @@ S_tioctl_tiocspgrp (io_t port,
}
pthread_mutex_unlock (&global_lock);
- ports_port_deref (cred);
return err;
}
/* TIOCGPGRP --- fetch pgrp of terminal */
kern_return_t
-S_tioctl_tiocgpgrp (io_t port,
+S_tioctl_tiocgpgrp (struct trivfs_protid *cred,
int *pgrp)
{
- struct trivfs_protid *cred = ports_lookup_port (term_bucket, port, 0);
error_t ret;
- if (!cred)
+ if (!cred
+ || cred->pi.bucket != term_bucket)
return EOPNOTSUPP;
if (cred->pi.class != pty_class
&& cred->pi.class != tty_class)
{
- ports_port_deref (cred);
return EOPNOTSUPP;
}
@@ -1685,24 +1637,22 @@ S_tioctl_tiocgpgrp (io_t port,
}
pthread_mutex_unlock (&global_lock);
- ports_port_deref (cred);
return ret;
}
/* TIOCCDTR -- clear DTR */
kern_return_t
-S_tioctl_tioccdtr (io_t port)
+S_tioctl_tioccdtr (struct trivfs_protid *cred)
{
- struct trivfs_protid *cred = ports_lookup_port (term_bucket, port, 0);
error_t err;
- if (!cred)
+ if (!cred
+ || cred->pi.bucket != term_bucket)
return EOPNOTSUPP;
if (cred->pi.class != pty_class
&& cred->pi.class != tty_class)
{
- ports_port_deref (cred);
return EOPNOTSUPP;
}
@@ -1713,24 +1663,22 @@ S_tioctl_tioccdtr (io_t port)
err = (*bottom->mdmctl) (MDMCTL_BIC, TIOCM_DTR);
pthread_mutex_unlock (&global_lock);
- ports_port_deref (cred);
return err;
}
/* TIOCSDTR -- set DTR */
kern_return_t
-S_tioctl_tiocsdtr (io_t port)
+S_tioctl_tiocsdtr (struct trivfs_protid *cred)
{
- struct trivfs_protid *cred = ports_lookup_port (term_bucket, port, 0);
error_t err;
- if (!cred)
+ if (!cred
+ || cred->pi.bucket != term_bucket)
return EOPNOTSUPP;
if (cred->pi.class != pty_class
&& cred->pi.class != tty_class)
{
- ports_port_deref (cred);
return EOPNOTSUPP;
}
@@ -1741,24 +1689,22 @@ S_tioctl_tiocsdtr (io_t port)
err = (*bottom->mdmctl) (MDMCTL_BIS, TIOCM_DTR);
pthread_mutex_unlock (&global_lock);
- ports_port_deref (cred);
return err;
}
/* TIOCCBRK -- Clear break condition */
kern_return_t
-S_tioctl_tioccbrk (io_t port)
+S_tioctl_tioccbrk (struct trivfs_protid *cred)
{
- struct trivfs_protid *cred = ports_lookup_port (term_bucket, port, 0);
error_t err;
- if (!cred)
+ if (!cred
+ || cred->pi.bucket != term_bucket)
return EOPNOTSUPP;
if (cred->pi.class != pty_class
&& cred->pi.class != tty_class)
{
- ports_port_deref (cred);
return EOPNOTSUPP;
}
@@ -1769,24 +1715,22 @@ S_tioctl_tioccbrk (io_t port)
err = (*bottom->clear_break) ();
pthread_mutex_unlock (&global_lock);
- ports_port_deref (cred);
return err;
}
/* TIOCSBRK -- Set break condition */
kern_return_t
-S_tioctl_tiocsbrk (io_t port)
+S_tioctl_tiocsbrk (struct trivfs_protid *cred)
{
- struct trivfs_protid *cred = ports_lookup_port (term_bucket, port, 0);
error_t err;
- if (!cred)
+ if (!cred
+ || cred->pi.bucket != term_bucket)
return EOPNOTSUPP;
if (cred->pi.class != pty_class
&& cred->pi.class != tty_class)
{
- ports_port_deref (cred);
return EOPNOTSUPP;
}
@@ -1797,7 +1741,6 @@ S_tioctl_tiocsbrk (io_t port)
err = (*bottom->set_break) ();
pthread_mutex_unlock (&global_lock);
- ports_port_deref (cred);
return err;
}