- assert(is_active(space));
- assert(oname != nname);
-
- /*
- * If IE_BITS_COMPAT, we can't allow the entry to be renamed
- * if the port is dead. (This would foil ipc_port_destroy.)
- * Instead we should fail because oentry shouldn't exist.
- * Note IE_BITS_COMPAT implies ie_request != 0.
- */
-
- if (request != IE_REQ_NONE) {
- ipc_port_t port;
-
- assert(bits & MACH_PORT_TYPE_PORT_RIGHTS);
- port = (ipc_port_t) object;
- assert(port != IP_NULL);
-
- if (ipc_right_check(space, port, oname, oentry)) {
- request = IE_REQ_NONE;
- object = IO_NULL;
- bits = oentry->ie_bits;
- release_port = port;
- assert(IE_BITS_TYPE(bits) == MACH_PORT_TYPE_DEAD_NAME);
- assert(oentry->ie_request == IE_REQ_NONE);
- } else {
- /* port is locked and active */
-
- ipc_port_request_rename(port, request, oname, nname);
- ip_unlock(port);
- oentry->ie_request = IE_REQ_NONE;
- }
- }
-
- /* initialize nentry before letting ipc_hash_insert see it */
-
- assert((nentry->ie_bits & IE_BITS_RIGHT_MASK) == 0);
- nentry->ie_bits |= bits & IE_BITS_RIGHT_MASK;
- nentry->ie_request = request;
- nentry->ie_object = object;
-
- switch (IE_BITS_TYPE(bits)) {
- case MACH_PORT_TYPE_SEND: {
- ipc_port_t port;
-
- port = (ipc_port_t) object;
- assert(port != IP_NULL);
-
- /* remember, there are no other share entries possible */
- /* or we can't do the rename. Therefore we do not need */
- /* to check the other subspaces */
- ipc_hash_delete(space, (ipc_object_t) port, oname, oentry);
- ipc_hash_insert(space, (ipc_object_t) port, nname, nentry);
- break;
- }
-
- case MACH_PORT_TYPE_RECEIVE:
- case MACH_PORT_TYPE_SEND_RECEIVE: {
- ipc_port_t port;
-
- port = (ipc_port_t) object;
- assert(port != IP_NULL);
-
- ip_lock(port);
- assert(ip_active(port));
- assert(port->ip_receiver_name == oname);
- assert(port->ip_receiver == space);
-
- port->ip_receiver_name = nname;
- ip_unlock(port);
- break;
- }
-
- case MACH_PORT_TYPE_PORT_SET: {
- ipc_pset_t pset;
-
- pset = (ipc_pset_t) object;
- assert(pset != IPS_NULL);
-
- ips_lock(pset);
- assert(ips_active(pset));
-
- ips_unlock(pset);
- break;
- }
-
- case MACH_PORT_TYPE_SEND_ONCE:
- case MACH_PORT_TYPE_DEAD_NAME:
- break;
-
- default:
- panic("ipc_right_rename: strange rights");