aboutsummaryrefslogtreecommitdiff
path: root/term
diff options
context:
space:
mode:
Diffstat (limited to 'term')
-rw-r--r--term/main.c24
-rw-r--r--term/mig-decls.h42
-rw-r--r--term/mig-mutate.h10
-rw-r--r--term/term.h5
-rw-r--r--term/users.c4
5 files changed, 73 insertions, 12 deletions
diff --git a/term/main.c b/term/main.c
index 9cc32d4d..be014e18 100644
--- a/term/main.c
+++ b/term/main.c
@@ -32,6 +32,10 @@
#include <version.h>
+#include "term_S.h"
+#include "tioctl_S.h"
+#include "device_reply_S.h"
+
const char *argp_program_version = STANDARD_HURD_VERSION (term);
int trivfs_fstype = FSTYPE_TERM;
@@ -61,14 +65,18 @@ dev_t rdev;
int
demuxer (mach_msg_header_t *inp, mach_msg_header_t *outp)
{
- extern int term_server (mach_msg_header_t *, mach_msg_header_t *);
- extern int tioctl_server (mach_msg_header_t *, mach_msg_header_t *);
- extern int device_reply_server (mach_msg_header_t *, mach_msg_header_t *);
-
- return (trivfs_demuxer (inp, outp)
- || term_server (inp, outp)
- || tioctl_server (inp, outp)
- || device_reply_server (inp, outp));
+ mig_routine_t routine;
+ if ((routine = NULL, trivfs_demuxer (inp, outp)) ||
+ (routine = term_server_routine (inp)) ||
+ (routine = tioctl_server_routine (inp)) ||
+ (routine = device_reply_server_routine (inp)))
+ {
+ if (routine)
+ (*routine) (inp, outp);
+ return TRUE;
+ }
+ else
+ return FALSE;
}
static struct argp_option options[] =
diff --git a/term/mig-decls.h b/term/mig-decls.h
new file mode 100644
index 00000000..c91b133a
--- /dev/null
+++ b/term/mig-decls.h
@@ -0,0 +1,42 @@
+/*
+ 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/>. */
+
+#ifndef __TERM_MIG_DECLS_H__
+#define __TERM_MIG_DECLS_H__
+
+#include <hurd/ports.h>
+
+#include "term.h"
+
+/* Called by server stub functions. */
+
+static inline struct port_info * __attribute__ ((unused))
+begin_using_ctty_port (mach_port_t port)
+{
+ return ports_lookup_port (term_bucket, port, cttyid_class);
+}
+
+static inline void __attribute__ ((unused))
+end_using_ctty (struct port_info *p)
+{
+ if (p)
+ ports_port_deref (p);
+}
+
+#endif /* __TERM_MIG_DECLS_H__ */
diff --git a/term/mig-mutate.h b/term/mig-mutate.h
index a6b99fe6..15457192 100644
--- a/term/mig-mutate.h
+++ b/term/mig-mutate.h
@@ -21,5 +21,13 @@
#define IO_INTRAN trivfs_protid_t trivfs_begin_using_protid (io_t)
#define IO_DESTRUCTOR trivfs_end_using_protid (trivfs_protid_t)
+
+#define CTTY_INTRAN \
+ port_info_t begin_using_ctty_port (mach_port_t)
+#define CTTY_DESTRUCTOR \
+ end_using_ctty (port_info_t)
+
#define TIOCTL_IMPORTS import "../libtrivfs/mig-decls.h";
-#define TERM_IMPORTS import "../libtrivfs/mig-decls.h";
+#define TERM_IMPORTS \
+ import "../libtrivfs/mig-decls.h"; \
+ import "mig-decls.h";
diff --git a/term/term.h b/term/term.h
index df82b6c9..3067425c 100644
--- a/term/term.h
+++ b/term/term.h
@@ -18,6 +18,9 @@
along with this program; if not, write to the Free Software
Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111, USA. */
+#ifndef __HURD_TERM_H__
+#define __HURD_TERM_H__
+
#include <pthread.h>
#include <assert.h>
#include <errno.h>
@@ -391,3 +394,5 @@ error_t pty_io_select (struct trivfs_protid *, mach_port_t,
error_t pty_open_hook (struct trivfs_control *, struct iouser *, int);
error_t pty_po_create_hook (struct trivfs_peropen *);
error_t pty_po_destroy_hook (struct trivfs_peropen *);
+
+#endif /* __HURD_TERM_H__ */
diff --git a/term/users.c b/term/users.c
index 9bd51d05..8151dc70 100644
--- a/term/users.c
+++ b/term/users.c
@@ -379,7 +379,7 @@ S_term_getctty (struct trivfs_protid *cred,
/* Implement termctty_open_terminal as described in <hurd/term.defs>. */
kern_return_t
-S_termctty_open_terminal (mach_port_t arg,
+S_termctty_open_terminal (struct port_info *pi,
int flags,
mach_port_t *result,
mach_msg_type_name_t *resulttype)
@@ -388,7 +388,6 @@ S_termctty_open_terminal (mach_port_t arg,
mach_port_t new_realnode;
struct iouser *user;
struct trivfs_protid *newcred;
- struct port_info *pi = ports_lookup_port (term_bucket, arg, cttyid_class);
if (!pi)
return EOPNOTSUPP;
@@ -409,7 +408,6 @@ S_termctty_open_terminal (mach_port_t arg,
}
}
- ports_port_deref (pi);
return err;
}