summaryrefslogtreecommitdiff
path: root/trans/ifsock.c
diff options
context:
space:
mode:
authorMichael I. Bushnell <mib@gnu.org>1995-06-28 19:31:31 +0000
committerMichael I. Bushnell <mib@gnu.org>1995-06-28 19:31:31 +0000
commit0ec33792a6faa5db08562c17123331f8d247cea0 (patch)
treef55e72b4a308c9759ff19be6d288c8ec26f4986a /trans/ifsock.c
parent9e28a72a9a3035a095d5ab266db7259666f8d93f (diff)
(PT_CTL, PT_NODE): Deleted macros.
(ports_cleanroutines): Deleted var. (ports_notice_idle, ports_no_live_ports, ports_no_hard_ports): Deleted functions. (control_class, node_class, port_bucket): New vars. (trivfs_protid_porttypes, trivfs_cntl_porttypes, trivfs_protid_nporttypes, trivfs_cntl_nporttypes): Deleted vars. (trivfs_protid_portclasses, trivfs_cntl_portclasses, trivfs_protid_nportclasses, trivfs_cntl_nportclasses): New vars. (main): Initialize control_class, node_class, port_bucket, trivfs-protid_portclasses, and trivfs_cntl_portclasses. (main): Use new trivfs interface. (trivfs_goaway): Likewise. (main): Use new ports interface. (S_ifsock_getsockaddr): Likewise. (demuxer): Renamed from ports_demuxer. (demuxer): Declare ifsock_server.
Diffstat (limited to 'trans/ifsock.c')
-rw-r--r--trans/ifsock.c72
1 files changed, 29 insertions, 43 deletions
diff --git a/trans/ifsock.c b/trans/ifsock.c
index b6862aba..acbeda13 100644
--- a/trans/ifsock.c
+++ b/trans/ifsock.c
@@ -1,5 +1,5 @@
/* Server for S_IFSOCK nodes
- Copyright (C) 1994 Free Software Foundation
+ Copyright (C) 1994, 1995 Free Software Foundation
This program is free software; you can redistribute it and/or
modify it under the terms of the GNU General Public License as
@@ -30,9 +30,9 @@
mach_port_t address_port;
-/* Port types */
-#define PT_CTL 0
-#define PT_NODE 1
+struct port_class *control_class;
+struct port_class *node_class;
+struct port_bucket *port_bucket;
int trivfs_fstype = FSTYPE_IFSOCK;
int trivfs_fsid = 0; /* ??? */
@@ -43,10 +43,17 @@ int trivfs_support_exec = 0;
int trivfs_allow_open = 0;
-int trivfs_protid_porttypes[] = {PT_NODE};
-int trivfs_cntl_porttypes[] = {PT_CTL};
-int trivfs_protid_nporttypes = 1;
-int trivfs_cntl_nporttypes = 1;
+struct port_class *trivfs_protid_portclasses[1];
+struct port_class *trivfs_cntl_portclasses[1];
+int trivfs_protid_nportclasses = 1;
+int trivfs_cntl_nportclasses = 1;
+
+int
+demuxer (mach_msg_header_t *inp, mach_msg_header_t *outp)
+{
+ extern int ifsock_server (mach_msg_header_t *, mach_msg_header_t *);
+ return trivfs_demuxer (inp, outp) || ifsock_server (inp, outp);
+}
int
main (int argc, char **argv)
@@ -56,12 +63,19 @@ main (int argc, char **argv)
mach_port_t bootstrap;
char buf[512];
+ control_class = ports_create_class (trivfs_clean_cntl, 0);
+ node_class = ports_create_class (trivfs_clean_protid, 0);
+ port_bucket = ports_create_bucket ();
+ trivfs_protid_portclasses[0] = node_class;
+ trivfs_cntl_portclasses[0] = control_class;
+
task_get_bootstrap_port (mach_task_self (), &bootstrap);
if (bootstrap == MACH_PORT_NULL)
error(1, 0, "Must be started as a translator");
/* Reply to our parent */
- err = trivfs_startup (bootstrap, PT_CTL, PT_NODE, NULL);
+ err = trivfs_startup (bootstrap, control_class, port_bucket,
+ node_class, port_bucket, NULL);
if (err)
error(2, err, "Contacting parent");
@@ -80,41 +94,10 @@ main (int argc, char **argv)
}
/* Launch. */
- ports_manage_port_operations_onethread ();
+ ports_manage_port_operations_one_thread (port_bucket, demuxer, 0);
return 0;
}
-void (*ports_cleanroutines[])(void *) =
-{
- [PT_CTL] = trivfs_clean_cntl,
- [PT_NODE] = trivfs_clean_protid,
-};
-
-int
-ports_demuxer (mach_msg_header_t *inp, mach_msg_header_t *outp)
-{
- return trivfs_demuxer (inp, outp) || ifsock_server (inp, outp);
-}
-
-void
-ports_notice_idle (int nhard, int nsoft)
-{
- if (!nhard && !nsoft)
- exit (0);
-}
-
-void
-ports_no_live_ports ()
-{
- exit (0);
-}
-
-void
-ports_no_hard_ports ()
-{
- exit (0);
-}
-
void
trivfs_modify_stat (struct stat *st)
{
@@ -122,7 +105,8 @@ trivfs_modify_stat (struct stat *st)
}
error_t
-trivfs_goaway (int flags, mach_port_t realnode, int ctltype, int pitype)
+trivfs_goaway (int flags, mach_port_t realnode, struct port_class *cntl_class,
+ struct port_class *protid_class)
{
exit (0);
}
@@ -131,7 +115,8 @@ error_t
S_ifsock_getsockaddr (file_t sockfile,
mach_port_t *address)
{
- struct trivfs_protid *cred = ports_check_port_type (sockfile, PT_NODE);
+ struct trivfs_protid *cred = ports_lookup_port (port_bucket, sockfile,
+ node_class);
int perms;
error_t err;
@@ -144,5 +129,6 @@ S_ifsock_getsockaddr (file_t sockfile,
if (!err)
*address = address_port;
+ ports_port_deref (cred);
return err;
}