@@ -385,15 +385,58 @@ _S_msg_set_environment (mach_port_t msgport, mach_port_t auth,
}
-/* XXX */
-
kern_return_t
_S_msg_get_dtable (mach_port_t process,
- mach_port_t refport,
+ mach_port_t auth,
portarray_t *dtable,
mach_msg_type_name_t *dtablePoly,
mach_msg_type_number_t *dtableCnt)
-{ return EOPNOTSUPP; }
+{
+ mach_port_t *ports;
+ mach_msg_type_number_t i;
+ error_t err;
+
+ AUTHCHECK;
+
+ HURD_CRITICAL_BEGIN;
+ __mutex_lock (&_hurd_dtable_lock);
+
+ if (err = __vm_allocate (__mach_task_self (), (vm_address_t *) &ports,
+ _hurd_dtablesize * sizeof(mach_port_t), 1))
+ goto out;
+
+ for (i = 0; i < _hurd_dtablesize; i++)
+ {
+ struct hurd_fd *cell = _hurd_dtable[i];
+ if (cell == NULL)
+ ports[i] = MACH_PORT_NULL;
+ else
+ {
+ __spin_lock (&cell->port.lock);
+ if (cell->port.port == MACH_PORT_NULL)
+ ports[i] = MACH_PORT_NULL;
+ else
+ {
+ ports[i] = cell->port.port;
+ /* We will move this send right. */
+ __mach_port_mod_refs (__mach_task_self (), ports[i],
+ MACH_PORT_RIGHT_SEND, +1);
+ }
+ __spin_unlock (&cell->port.lock);
+ }
+ }
+
+ *dtable = ports;
+ *dtablePoly = MACH_MSG_TYPE_MOVE_SEND;
+ *dtableCnt = _hurd_dtablesize;
+
+out:
+ __mutex_unlock (&_hurd_dtable_lock);
+ HURD_CRITICAL_END;
+ return err;
+}
+
+/* XXX */
kern_return_t
_S_msg_set_dtable (mach_port_t process,