diff options
Diffstat (limited to 'ipc/ipc_object.c')
-rw-r--r-- | ipc/ipc_object.c | 325 |
1 files changed, 0 insertions, 325 deletions
diff --git a/ipc/ipc_object.c b/ipc/ipc_object.c index 74d21f9..a7a7ddb 100644 --- a/ipc/ipc_object.c +++ b/ipc/ipc_object.c @@ -368,14 +368,6 @@ ipc_object_copyin_type( case MACH_MSG_TYPE_COPY_SEND: return MACH_MSG_TYPE_PORT_SEND; -#if MACH_IPC_COMPAT - case MSG_TYPE_PORT: - return MACH_MSG_TYPE_PORT_SEND; - - case MSG_TYPE_PORT_ALL: - return MACH_MSG_TYPE_PORT_RECEIVE; -#endif /* MACH_IPC_COMPAT */ - default: #if MACH_ASSERT assert(!"ipc_object_copyin_type: strange rights"); @@ -966,323 +958,6 @@ ipc_object_rename( return kr; } -#if MACH_IPC_COMPAT - -/* - * Routine: ipc_object_copyout_type_compat - * Purpose: - * Convert a carried type name to an old type name. - */ - -mach_msg_type_name_t -ipc_object_copyout_type_compat(msgt_name) - mach_msg_type_name_t msgt_name; -{ - switch (msgt_name) { - case MACH_MSG_TYPE_PORT_SEND: - case MACH_MSG_TYPE_PORT_SEND_ONCE: - return MSG_TYPE_PORT; - - case MACH_MSG_TYPE_PORT_RECEIVE: - return MSG_TYPE_PORT_ALL; - - default: -#if MACH_ASSERT - assert(!"ipc_object_copyout_type_compat: strange rights"); -#else - panic("ipc_object_copyout_type_compat: strange rights"); -#endif - } -} - -/* - * Routine: ipc_object_copyin_compat - * Purpose: - * Copyin a capability from a space. - * If successful, the caller gets a ref - * for the resulting object, which is always valid. - * Conditions: - * Nothing locked. - * Returns: - * KERN_SUCCESS Acquired a valid object. - * KERN_INVALID_TASK The space is dead. - * KERN_INVALID_NAME Name doesn't exist in space. - * KERN_INVALID_RIGHT Name doesn't denote correct right. - */ - -kern_return_t -ipc_object_copyin_compat(space, name, msgt_name, dealloc, objectp) - ipc_space_t space; - mach_port_t name; - mach_msg_type_name_t msgt_name; - boolean_t dealloc; - ipc_object_t *objectp; -{ - ipc_entry_t entry; - kern_return_t kr; - - kr = ipc_right_lookup_write(space, name, &entry); - if (kr != KERN_SUCCESS) - return kr; - /* space is write-locked and active */ - - kr = ipc_right_copyin_compat(space, name, entry, - msgt_name, dealloc, objectp); - /* space is unlocked */ - return kr; -} - -/* - * Routine: ipc_object_copyin_header - * Purpose: - * Copyin a capability from a space. - * If successful, the caller gets a ref - * for the resulting object, which is always valid. - * The type of the acquired capability is returned. - * Conditions: - * Nothing locked. - * Returns: - * KERN_SUCCESS Acquired a valid object. - * KERN_INVALID_TASK The space is dead. - * KERN_INVALID_NAME Name doesn't exist in space. - * KERN_INVALID_RIGHT Name doesn't denote correct right. - */ - -kern_return_t -ipc_object_copyin_header(space, name, objectp, msgt_namep) - ipc_space_t space; - mach_port_t name; - ipc_object_t *objectp; - mach_msg_type_name_t *msgt_namep; -{ - ipc_entry_t entry; - kern_return_t kr; - - kr = ipc_right_lookup_write(space, name, &entry); - if (kr != KERN_SUCCESS) - return kr; - /* space is write-locked and active */ - - kr = ipc_right_copyin_header(space, name, entry, - objectp, msgt_namep); - /* space is unlocked */ - return kr; -} - -/* - * Routine: ipc_object_copyout_compat - * Purpose: - * Copyout a capability, placing it into a space. - * If successful, consumes a ref for the object. - * - * Marks new entries with IE_BITS_COMPAT. - * Conditions: - * Nothing locked. - * Returns: - * KERN_SUCCESS Copied out object, consumed ref. - * KERN_INVALID_TASK The space is dead. - * KERN_INVALID_CAPABILITY The object is dead. - * KERN_NO_SPACE No room in space for another right. - * KERN_RESOURCE_SHORTAGE No memory available. - */ - -kern_return_t -ipc_object_copyout_compat(space, object, msgt_name, namep) - ipc_space_t space; - ipc_object_t object; - mach_msg_type_name_t msgt_name; - mach_port_t *namep; -{ - mach_port_t name; - ipc_entry_t entry; - ipc_port_t port; - kern_return_t kr; - - assert(IO_VALID(object)); - assert(io_otype(object) == IOT_PORT); - port = (ipc_port_t) object; - - is_write_lock(space); - - for (;;) { - ipc_port_request_index_t request; - - if (!space->is_active) { - is_write_unlock(space); - return KERN_INVALID_TASK; - } - - if ((msgt_name != MACH_MSG_TYPE_PORT_SEND_ONCE) && - ipc_right_reverse(space, (ipc_object_t) port, - &name, &entry)) { - /* port is locked and active */ - - assert(entry->ie_bits & MACH_PORT_TYPE_SEND_RECEIVE); - break; - } - - kr = ipc_entry_get(space, &name, &entry); - if (kr != KERN_SUCCESS) { - /* unlocks/locks space, so must start again */ - - kr = ipc_entry_grow_table(space); - if (kr != KERN_SUCCESS) - return kr; /* space is unlocked */ - - continue; - } - - assert(IE_BITS_TYPE(entry->ie_bits) == MACH_PORT_TYPE_NONE); - assert(entry->ie_object == IO_NULL); - - ip_lock(port); - if (!ip_active(port)) { - ip_unlock(port); - ipc_entry_dealloc(space, name, entry); - is_write_unlock(space); - return KERN_INVALID_CAPABILITY; - } - - kr = ipc_port_dnrequest(port, name, ipr_spacem(space), - &request); - if (kr != KERN_SUCCESS) { - ipc_entry_dealloc(space, name, entry); - is_write_unlock(space); - - kr = ipc_port_dngrow(port); - /* port is unlocked */ - if (kr != KERN_SUCCESS) - return kr; - - is_write_lock(space); - continue; - } - - is_reference(space); /* for dnrequest */ - entry->ie_object = (ipc_object_t) port; - entry->ie_request = request; - entry->ie_bits |= IE_BITS_COMPAT; - break; - } - - /* space is write-locked and active, port is locked and active */ - - kr = ipc_right_copyout(space, name, entry, - msgt_name, TRUE, (ipc_object_t) port); - /* object is unlocked */ - is_write_unlock(space); - - if (kr == KERN_SUCCESS) - *namep = name; - return kr; -} - -/* - * Routine: ipc_object_copyout_name_compat - * Purpose: - * Copyout a capability, placing it into a space. - * The specified name is used for the capability. - * If successful, consumes a ref for the object. - * - * Like ipc_object_copyout_name, except that - * the name can't be in use at all, even for the same - * port, and IE_BITS_COMPAT gets turned on. - * Conditions: - * Nothing locked. - * Returns: - * KERN_SUCCESS Copied out object, consumed ref. - * KERN_INVALID_TASK The space is dead. - * KERN_INVALID_CAPABILITY The object is dead. - * KERN_RESOURCE_SHORTAGE No memory available. - * KERN_RIGHT_EXISTS Space has rights under another name. - * KERN_NAME_EXISTS Name is already used. - */ - -kern_return_t -ipc_object_copyout_name_compat(space, object, msgt_name, name) - ipc_space_t space; - ipc_object_t object; - mach_msg_type_name_t msgt_name; - mach_port_t name; -{ - ipc_entry_t entry; - ipc_port_t port; - kern_return_t kr; - - assert(IO_VALID(object)); - assert(io_otype(object) == IOT_PORT); - port = (ipc_port_t) object; - - for (;;) { - mach_port_t oname; - ipc_entry_t oentry; - ipc_port_request_index_t request; - - kr = ipc_entry_alloc_name(space, name, &entry); - if (kr != KERN_SUCCESS) - return kr; - /* space is write-locked and active */ - - if (ipc_right_inuse(space, name, entry)) - return KERN_NAME_EXISTS; /* space is unlocked */ - - assert(IE_BITS_TYPE(entry->ie_bits) == MACH_PORT_TYPE_NONE); - assert(entry->ie_object == IO_NULL); - - if ((msgt_name != MACH_MSG_TYPE_PORT_SEND_ONCE) && - ipc_right_reverse(space, (ipc_object_t) port, - &oname, &oentry)) { - /* port is locked and active */ - - ip_unlock(port); - ipc_entry_dealloc(space, name, entry); - is_write_unlock(space); - return KERN_RIGHT_EXISTS; - } - - ip_lock(port); - if (!ip_active(port)) { - ip_unlock(port); - ipc_entry_dealloc(space, name, entry); - is_write_unlock(space); - return KERN_INVALID_CAPABILITY; - } - - kr = ipc_port_dnrequest(port, name, ipr_spacem(space), - &request); - if (kr != KERN_SUCCESS) { - ipc_entry_dealloc(space, name, entry); - is_write_unlock(space); - - kr = ipc_port_dngrow(port); - /* port is unlocked */ - if (kr != KERN_SUCCESS) - return kr; - - continue; - } - - is_reference(space); /* for dnrequest */ - entry->ie_object = (ipc_object_t) port; - entry->ie_request = request; - entry->ie_bits |= IE_BITS_COMPAT; - break; - } - - /* space is write-locked and active, port is locked and active */ - - kr = ipc_right_copyout(space, name, entry, - msgt_name, TRUE, (ipc_object_t) port); - /* object is unlocked */ - is_write_unlock(space); - - assert(kr == KERN_SUCCESS); - return kr; -} - -#endif /* MACH_IPC_COMPAT */ - - #if MACH_KDB #define printf kdbprintf |