Index: libfshelp/start-translator-long.c
===================================================================
RCS file: /cvsroot/hurd/hurd/libfshelp/start-translator-long.c,v
retrieving revision 1.16
diff -u -r1.16 start-translator-long.c
--- libfshelp/start-translator-long.c	2 Jan 2002 11:22:03 -0000	1.16
+++ libfshelp/start-translator-long.c	8 Aug 2003 18:09:46 -0000
@@ -1,5 +1,5 @@
 /*
-   Copyright (C) 1995,96,99,2000,02 Free Software Foundation, Inc.
+   Copyright (C) 1995,96,99,2000,02,03 Free Software Foundation, Inc.
    Written by Miles Bader and Michael I. Bushnell.
 
    This file is part of the GNU Hurd.
@@ -30,6 +30,7 @@
 
 
 /* The data passed in the various messages we're interested in.  */
+#ifdef MACH_MSG_TYPE_INTEGER_32
 struct fsys_startup_request
 {
   mach_msg_header_t head;
@@ -89,6 +90,25 @@
   FALSE,			/* msgt_deallocate = */
   0				/* msgt_unused = */
 };
+#else
+/* Untyped Mach IPC format.  */
+struct fsys_startup_request
+{
+  mach_msg_header_t head;
+  mach_msg_body_t body;
+  mach_msg_port_descriptor_t control_port;
+  NDR_record_t NDR;
+  int flags;
+  mach_msg_trailer_t trailer;
+};
+
+struct fsys_startup_reply
+{
+  mach_msg_header_t head;
+  mach_msg_body_t body;
+  mach_msg_port_descriptor_t realnode;
+};
+#endif
 
 
 /* Wait around for an fsys_startup message on the port PORT from the
@@ -103,12 +123,17 @@
 		      task_t task)
 {
   error_t err;
+#ifdef MACH_MSG_TYPE_INTEGER_32
   union
     {
       mach_msg_header_t head;
       struct fsys_startup_request startup;
     }
   request;
+#else
+  kern_return_t RetCode;
+  struct fsys_startup_request request;
+#endif
   struct fsys_startup_reply reply;
 
   /* Wait for the fsys_startup message...  */
@@ -128,10 +153,16 @@
     MACH_MSGH_BITS(MACH_MSGH_BITS_REMOTE(request.head.msgh_bits), 0);
   reply.head.msgh_remote_port = request.head.msgh_remote_port;
   reply.head.msgh_local_port = MACH_PORT_NULL;
+#ifdef MACH_MSG_TYPE_INTEGER_32
   reply.head.msgh_seqno = 0;
   reply.head.msgh_id = request.head.msgh_id + 100;
   reply.RetCodeType = RetCodeType;
+#else
+  reply.head.msgh_reserved = 0;
+  reply.head.msgh_id = request.head.msgh_id + 100;
+#endif
 
+#ifdef MACH_MSG_TYPE_INTEGER_32
   if (request.head.msgh_id != 22000)
     reply.RetCode = MIG_BAD_ID;
   else if ((*(int *)&request.startup.control_portType
@@ -156,11 +187,45 @@
 	/* The message can't be simple because of the port.  */
 	reply.head.msgh_bits |= MACH_MSGH_BITS_COMPLEX;
     }
+#else
+  if (request.head.msgh_id != 22000)
+    RetCode = MIG_BAD_ID;
+  else if (!(request.head.msgh_bits & MACH_MSGH_BITS_COMPLEX)
+	   || request.body.msgh_descriptor_count != 1
+	   || request.head.msgh_size
+	   != sizeof (request) - sizeof (mach_msg_trailer_t))
+    RetCode = MIG_BAD_ARGUMENTS;
+  else if (request.control_port.type != MACH_MSG_PORT_DESCRIPTOR)
+    RetCode = MIG_TYPE_ERROR;
+  else
+    {
+      mach_msg_type_name_t realnode_disposition;
+
+      *control = request.control_port.name;
+
+      RetCode = (*underlying_open_fn) (request.flags,
+				       &reply.realnode.name,
+				       &realnode_disposition,
+				       task, cookie);
+
+      if (RetCode == KERN_SUCCESS) {
+	/* The message can't be simple because of the port.  */
+	reply.head.msgh_bits |= MACH_MSGH_BITS_COMPLEX;
+	reply.body.msgh_descriptor_count = 1;
+	reply.realnode.disposition = realnode_disposition;
+	reply.realnode.type = MACH_MSG_PORT_DESCRIPTOR;
+      }
+    }
+  if (RetCode != KERN_SUCCESS)
+    ((mig_reply_error_t *) &reply)->RetCode = RetCode;
+#endif
 
   err = mach_msg (&reply.head, MACH_SEND_MSG | MACH_SEND_INTERRUPT,
 		  sizeof(reply), 0,
 		  request.head.msgh_remote_port,
 		  MACH_MSG_TIMEOUT_NONE, MACH_PORT_NULL);
+
+#ifdef MACH_MSG_TYPE_INTEGER_32
   if (err == MACH_SEND_INTERRUPTED
       && reply.realnodeType.msgt_name == MACH_MSG_TYPE_MOVE_SEND)
     /* For MACH_SEND_INTERRUPTED, we'll have pseudo-received the message
@@ -170,6 +235,17 @@
   if (reply.RetCode)
     /* Make our error return be the earlier one.  */
     err = reply.RetCode;
+#else
+  if (err == MACH_SEND_INTERRUPTED
+      && reply.realnode.disposition == MACH_MSG_TYPE_MOVE_SEND)
+    /* For MACH_SEND_INTERRUPTED, we'll have pseudo-received the message
+       and might have to clean up a generated send right.  */
+    mach_port_deallocate (mach_task_self (), reply.realnode.name);
+
+  if (RetCode != KERN_SUCCESS)
+    /* Make our error return be the earlier one.  */
+    err = RetCode;
+#endif
 
   return err;
 }

