+ return TASK_NULL;
+
+ task = convert_port_to_task(kern_port);
+
+ if (IP_VALID(kern_port))
+ ipc_port_release_send(kern_port);
+ }
+ return task;
+}
+
+task_inspect_t
+port_name_to_task_inspect(
+ mach_port_name_t name)
+{
+ ipc_port_t kern_port;
+ kern_return_t kr;
+ task_inspect_t ti = TASK_INSPECT_NULL;
+
+ if (MACH_PORT_VALID(name)) {
+ kr = ipc_object_copyin(current_space(), name,
+ MACH_MSG_TYPE_COPY_SEND,
+ (ipc_object_t *)&kern_port);
+ if (kr != KERN_SUCCESS)
+ return TASK_NULL;
+
+ ti = convert_port_to_task_inspect(kern_port);
+
+ if (IP_VALID(kern_port))
+ ipc_port_release_send(kern_port);
+ }
+ return ti;
+}
+
+/*
+ * Routine: port_name_to_host
+ * Purpose:
+ * Convert from a port name to a host pointer.
+ * NOTE: This does _not_ return a +1 reference to the host_t
+ * Conditions:
+ * Nothing locked.
+ */
+host_t
+port_name_to_host(
+ mach_port_name_t name)
+{
+
+ host_t host = HOST_NULL;
+ kern_return_t kr;
+ ipc_port_t port;
+
+ if (MACH_PORT_VALID(name)) {
+ kr = ipc_port_translate_send(current_space(), name, &port);
+ if (kr == KERN_SUCCESS) {
+ host = convert_port_to_host(port);
+ ip_unlock(port);
+ }
+ }
+ return host;
+}
+
+/*
+ * Routine: convert_task_to_port
+ * Purpose:
+ * Convert from a task to a port.
+ * Consumes a task ref; produces a naked send right
+ * which may be invalid.
+ * Conditions:
+ * Nothing locked.
+ */
+
+ipc_port_t
+convert_task_to_port(
+ task_t task)
+{
+ ipc_port_t port;
+
+ itk_lock(task);
+
+ if (task->itk_self != IP_NULL)
+ port = ipc_port_make_send(task->itk_self);
+ else
+ port = IP_NULL;
+
+ itk_unlock(task);
+
+ task_deallocate(task);
+ return port;
+}
+
+/*
+ * Routine: convert_task_inspect_to_port
+ * Purpose:
+ * Convert from a task inspect reference to a port.
+ * Consumes a task ref;
+ * As we never export task inspect ports, always
+ * creates a NULL port.
+ * Conditions:
+ * Nothing locked.
+ */
+ipc_port_t
+convert_task_inspect_to_port(
+ task_inspect_t task)
+{
+ task_deallocate(task);