diff options
author | Thomas Schwinge <tschwinge@gnu.org> | 2006-12-03 20:16:16 +0000 |
---|---|---|
committer | Thomas Schwinge <tschwinge@gnu.org> | 2009-06-18 00:26:57 +0200 |
commit | 96c01087a657dfc1c877b63e9e6b0f45c37b9c78 (patch) | |
tree | 11f6e4d507c8327b52d167a718ec65c184c6bbfd /ipc/mach_port.c | |
parent | a0e81d1ebfbf11bc056f729242e8565f177afa95 (diff) | |
download | gnumach-96c01087a657dfc1c877b63e9e6b0f45c37b9c78.tar.gz gnumach-96c01087a657dfc1c877b63e9e6b0f45c37b9c78.tar.bz2 gnumach-96c01087a657dfc1c877b63e9e6b0f45c37b9c78.zip |
2006-12-03 Thomas Schwinge <tschwinge@gnu.org>
[patch #5017 --- ``Remove obsolete IPC interfaces.'']
* DEVELOPMENT: Document the removal.
* configfrag.ac (MACH_IPC_COMPAT): Don't define.
2006-12-03 Leonardo Lopes Pereira <leonardolopespereira@gmail.com>
[patch #5017 --- ``Remove obsolete IPC interfaces.'']
* kern/act.c [MIGRATING_THREADS]: Don't include <mach_ipc_compat.h>.
* kern/act.h: Likewise.
* i386/include/mach/i386/machine_types.defs: Adapt all users of
MACH_IPC_COMPAT as if it were always defined to `0'.
* include/mach/mach.defs: Likewise.
* include/mach/mach_param.h: Likewise.
* include/mach/mach_traps.h: Likewise.
* include/mach/message.h: Likewise.
* include/mach/mig_errors.h: Likewise.
* include/mach/notify.h: Likewise.
* include/mach/port.h: Likewise.
* include/mach/std_types.defs: Likewise.
* include/mach/syscall_sw.h: Likewise.
* include/mach/task_special_ports.h: Likewise.
* include/mach/thread_special_ports.h: Likewise.
* ipc/ipc_kmsg.c: Likewise.
* ipc/ipc_kmsg.h: Likewise.
* ipc/ipc_marequest.c: Likewise.
* ipc/ipc_notify.c: Likewise.
* ipc/ipc_notify.h: Likewise.
* ipc/ipc_object.c: Likewise.
* ipc/ipc_object.h: Likewise.
* ipc/ipc_port.c: Likewise.
* ipc/ipc_port.h: Likewise.
* ipc/ipc_right.c: Likewise.
* ipc/ipc_right.h: Likewise.
* ipc/ipc_space.c: Likewise.
* ipc/ipc_space.h: Likewise.
* ipc/mach_debug.c: Likewise.
* ipc/mach_msg.c: Likewise
* ipc/mach_msg.h: Likewise.
* ipc/mach_port.c: Likewise.
* kern/act.c: Likewise.
* kern/act.h: Likewise.
* kern/ipc_host.c: Likewise.
* kern/ipc_tt.c: Likewise.
* kern/syscall_sw.c: Likewise.
* kern/thread.h: Likewise.
Diffstat (limited to 'ipc/mach_port.c')
-rw-r--r-- | ipc/mach_port.c | 959 |
1 files changed, 0 insertions, 959 deletions
diff --git a/ipc/mach_port.c b/ipc/mach_port.c index f522cac0..c9f24c5a 100644 --- a/ipc/mach_port.c +++ b/ipc/mach_port.c @@ -102,11 +102,6 @@ mach_port_names_helper( ip_unlock(port); if (died) { -#if MACH_IPC_COMPAT - if (bits & IE_BITS_COMPAT) - return; -#endif /* MACH_IPC_COMPAT */ - /* pretend this is a dead-name entry */ bits &= ~(IE_BITS_TYPE_MASK|IE_BITS_MAREQUEST); @@ -118,11 +113,6 @@ mach_port_names_helper( } type = IE_BITS_TYPE(bits); -#if MACH_IPC_COMPAT - if (bits & IE_BITS_COMPAT) - type |= MACH_PORT_TYPE_COMPAT; - else -#endif /* MACH_IPC_COMPAT */ if (request != 0) type |= MACH_PORT_TYPE_DNREQUEST; if (bits & IE_BITS_MAREQUEST) @@ -1228,19 +1218,6 @@ mach_port_request_notification( ipc_port_pdrequest(port, notify, &previous); /* port is unlocked */ -#if MACH_IPC_COMPAT - /* - * If previous was a send right instead of a send-once - * right, we can't return it in the reply message. - * So destroy it instead. - */ - - if ((previous != IP_NULL) && ip_pdsendp(previous)) { - ipc_port_release_send(ip_pdsend(previous)); - previous = IP_NULL; - } -#endif /* MACH_IPC_COMPAT */ - *previousp = previous; break; } @@ -1567,939 +1544,3 @@ mach_port_set_syscall_right(task, name) } #endif #endif /* MIGRATING_THREADS */ - -#if MACH_IPC_COMPAT - -/* - * Routine: port_translate_compat - * Purpose: - * Converts a name to a receive right. - * Conditions: - * Nothing locked. If successful, the port - * is returned locked and active. - * Returns: - * KERN_SUCCESS Port is returned. - * KERN_INVALID_ARGUMENT The space is dead. - * KERN_INVALID_ARGUMENT Name doesn't denote port rights. - * KERN_NOT_RECEIVER Name denotes send, not receive, rights. - * KERN_NOT_RECEIVER Name denotes a send-once right. - * KERN_NOT_RECEIVER Name denotes a dead name. - */ - -kern_return_t -port_translate_compat(space, name, portp) - ipc_space_t space; - mach_port_t name; - ipc_port_t *portp; -{ - ipc_entry_t entry; - mach_port_type_t type; - mach_port_urefs_t urefs; - ipc_port_t port; - kern_return_t kr; - - kr = ipc_right_lookup_write(space, name, &entry); - if (kr != KERN_SUCCESS) - return KERN_INVALID_ARGUMENT; - /* space is write-locked and active */ - - kr = ipc_right_info(space, name, entry, &type, &urefs); - if (kr != KERN_SUCCESS) - return KERN_INVALID_ARGUMENT; /* space is unlocked */ - - if ((type & (MACH_PORT_TYPE_RECEIVE)) == 0) { - is_write_unlock(space); - if (type & MACH_PORT_TYPE_PORT_OR_DEAD) - return KERN_NOT_RECEIVER; - else - return KERN_INVALID_ARGUMENT; - } - - port = (ipc_port_t) entry->ie_object; - assert(port != IP_NULL); - - ip_lock(port); - is_write_unlock(space); - assert(ip_active(port)); - - *portp = port; - return KERN_SUCCESS; -} - -/* - * Routine: convert_port_type - * Purpose: - * Convert a new mach_port_type_t to an old value. - * Note send-once rights and dead names get - * represented as send rights. The extra info - * bits get dropped. - */ - -mach_port_type_t -convert_port_type(type) - mach_port_type_t type; -{ - switch (type & MACH_PORT_TYPE_ALL_RIGHTS) { - case MACH_PORT_TYPE_SEND: - case MACH_PORT_TYPE_SEND_ONCE: - case MACH_PORT_TYPE_DEAD_NAME: - return PORT_TYPE_SEND; - - case MACH_PORT_TYPE_RECEIVE: - case MACH_PORT_TYPE_SEND_RECEIVE: - return PORT_TYPE_RECEIVE_OWN; - - case MACH_PORT_TYPE_PORT_SET: - return PORT_TYPE_SET; - - default: -#if MACH_ASSERT - assert(!"convert_port_type: strange port type"); -#else - panic("convert_port_type: strange port type"); -#endif - } -} - -/* - * Routine: port_names [kernel call] - * Purpose: - * Retrieve all the names in the task's port name space. - * As a (major) convenience, return port type information. - * The port name space includes port sets. - * Conditions: - * Nothing locked. - * Returns: - * KERN_SUCCESS Retrieved names. - * KERN_INVALID_ARGUMENT Task is null. - * KERN_INVALID_ARGUMENT Task is not active. - * Additions: - * KERN_RESOURCE_SHORTAGE Couldn't allocate memory. - */ - -kern_return_t -port_names(space, namesp, namesCnt, typesp, typesCnt) - ipc_space_t space; - mach_port_t **namesp; - mach_msg_type_number_t *namesCnt; - mach_port_type_t **typesp; - mach_msg_type_number_t *typesCnt; -{ - kern_return_t kr; - - kr = mach_port_names(space, namesp, namesCnt, typesp, typesCnt); - if (kr == KERN_SUCCESS) { - ipc_entry_num_t actual = (ipc_entry_num_t) *typesCnt; - mach_port_type_t *types; - ipc_entry_num_t i; - - vm_map_copy_t copy = (vm_map_copy_t) *typesp; - vm_offset_t addr; - vm_size_t size = round_page(actual * sizeof(mach_port_type_t)); - - /* convert copy object back to something we can use */ - - kr = vm_map_copyout(ipc_kernel_map, &addr, copy); - if (kr != KERN_SUCCESS) { - vm_map_copy_discard((vm_map_copy_t) *typesp); - vm_map_copy_discard((vm_map_copy_t) *namesp); - return KERN_RESOURCE_SHORTAGE; - } - - types = (mach_port_type_t *) addr; - - for (i = 0; i < actual; i++) - types[i] = convert_port_type(types[i]); - - /* convert memory back into a copy object */ - - kr = vm_map_copyin(ipc_kernel_map, addr, size, - TRUE, ©); - assert(kr == KERN_SUCCESS); - - *typesp = (mach_port_type_t *) copy; - } else if (kr != KERN_RESOURCE_SHORTAGE) - kr = KERN_INVALID_ARGUMENT; - - return kr; -} - -/* - * Routine: port_type [kernel call] - * Purpose: - * Return type of the capability named. - * Conditions: - * Nothing locked. - * Returns: - * KERN_SUCCESS Retrieved type. - * KERN_INVALID_ARGUMENT Task is null. - * KERN_INVALID_ARGUMENT Task is not active. - * KERN_INVALID_ARGUMENT The name doesn't denote a right. - */ - -kern_return_t -port_type(space, name, typep) - ipc_space_t space; - mach_port_t name; - mach_port_type_t *typep; -{ - mach_port_type_t type; - kern_return_t kr; - - kr = mach_port_type(space, name, &type); - if (kr != KERN_SUCCESS) - return KERN_INVALID_ARGUMENT; - - *typep = convert_port_type(type); - return KERN_SUCCESS; -} - -/* - * Routine: port_rename [kernel call] - * Purpose: - * Change the name of a capability. - * The new name can't be in use. - * Conditions: - * Nothing locked. - * Returns: - * KERN_SUCCESS Retrieved type. - * KERN_INVALID_ARGUMENT Task is null. - * KERN_INVALID_ARGUMENT Task is not active. - * KERN_INVALID_ARGUMENT The new name is reserved. - * KERN_NAME_EXISTS The new name already denotes a right. - * KERN_INVALID_ARGUMENT The old name doesn't denote a right. - */ - -kern_return_t -port_rename(space, old_name, new_name) - ipc_space_t space; - mach_port_t old_name; - mach_port_t new_name; -{ - kern_return_t kr; - - kr = mach_port_rename(space, old_name, new_name); - if ((kr != KERN_SUCCESS) && (kr != KERN_NAME_EXISTS)) - kr = KERN_INVALID_ARGUMENT; - - return kr; -} - -/* - * Routine: port_allocate [kernel call] - * Purpose: - * Allocate a new port, giving all rights to "task". - * - * Returns in "port_name" the task's local name for the port. - * Doesn't return a reference to the port. - * Conditions: - * Nothing locked. - * Returns: - * KERN_SUCCESS Allocated a port. - * KERN_INVALID_ARGUMENT Task is null. - * KERN_INVALID_ARGUMENT Task is not active. - * KERN_RESOURCE_SHORTAGE Couldn't allocate memory. - */ - -kern_return_t -port_allocate(space, namep) - ipc_space_t space; - mach_port_t *namep; -{ - ipc_port_t port; - kern_return_t kr; - - if (space == IS_NULL) - return KERN_INVALID_ARGUMENT; - - kr = ipc_port_alloc_compat(space, namep, &port); - if (kr == KERN_SUCCESS) - ip_unlock(port); - else if (kr != KERN_RESOURCE_SHORTAGE) - kr = KERN_INVALID_ARGUMENT; - - return kr; -} - -/* - * Routine: port_deallocate [kernel call] - * Purpose: - * Delete port rights (send and receive) from a task. - * Conditions: - * Nothing locked. - * Returns: - * KERN_SUCCESS Deallocated the port right. - * KERN_INVALID_ARGUMENT Task is null. - * KERN_INVALID_ARGUMENT Task is not active. - * KERN_INVALID_ARGUMENT Name doesn't denote a port right. - * Additions: - * KERN_SUCCESS Deallocated a send-once right. - * KERN_SUCCESS Destroyed a dead name. - */ - -kern_return_t -port_deallocate(space, name) - ipc_space_t space; - mach_port_t name; -{ - ipc_entry_t entry; - mach_port_type_t type; - mach_port_urefs_t urefs; - kern_return_t kr; - - if (space == IS_NULL) - return KERN_INVALID_ARGUMENT; - - kr = ipc_right_lookup_write(space, name, &entry); - if (kr != KERN_SUCCESS) - return KERN_INVALID_ARGUMENT; - /* space is write-locked and active */ - - /* - * We serialize with port destruction with the - * ipc_right_info call, not ipc_right_destroy. - * After ipc_right_info, we pretend that the - * port doesn't get destroyed. - */ - - kr = ipc_right_info(space, name, entry, &type, &urefs); - if (kr != KERN_SUCCESS) - return KERN_INVALID_ARGUMENT; /* space is unlocked */ - - if ((type & (MACH_PORT_TYPE_PORT_OR_DEAD)) == 0) { - is_write_unlock(space); - return KERN_INVALID_ARGUMENT; - } - - (void) ipc_right_destroy(space, name, entry); - /* space is unlocked */ - - return KERN_SUCCESS; -} - -/* - * Routine: port_set_backlog [kernel call] - * Purpose: - * Change the queueing backlog on "port_name" to "backlog"; - * the specified "task" must be the current receiver. - * - * Valid backlog values are 0 < backlog <= PORT_BACKLOG_MAX. - * Conditions: - * Nothing locked. - * Returns: - * KERN_SUCCESS Set the backlog. - * KERN_INVALID_ARGUMENT Task is null. - * KERN_INVALID_ARGUMENT Task is not active. - * KERN_INVALID_ARGUMENT Name doesn't denote a port right. - * KERN_NOT_RECEIVER Name denotes send rights, not receive. - * KERN_INVALID_ARGUMENT Backlog value is invalid. - * Additions: - * KERN_NOT_RECEIVER Name denotes a send-once right. - * KERN_NOT_RECEIVER Name denotes a dead name. - */ - -kern_return_t -port_set_backlog(space, name, backlog) - ipc_space_t space; - mach_port_t name; - int backlog; -{ - ipc_port_t port; - kern_return_t kr; - - if ((space == IS_NULL) || - (backlog <= 0) || - (backlog > PORT_BACKLOG_MAX)) - return KERN_INVALID_ARGUMENT; - - kr = port_translate_compat(space, name, &port); - if (kr != KERN_SUCCESS) - return kr; - /* port is locked and active */ - - ipc_port_set_qlimit(port, (mach_port_msgcount_t) backlog); - - ip_unlock(port); - return KERN_SUCCESS; -} - -/* - * Routine: port_set_backup [kernel call] - * Purpose: - * Changes the backup port for the the named port. - * The specified "task" must be the current receiver. - * Returns the old backup port, if any. - * Conditions: - * Nothing locked. - * Returns: - * KERN_SUCCESS Set the backup. - * KERN_INVALID_ARGUMENT Task is null. - * KERN_INVALID_ARGUMENT Task is not active. - * KERN_INVALID_ARGUMENT Name doesn't denote a port right. - * KERN_NOT_RECEIVER Name denotes send rights, not receive. - * Additions: - * KERN_NOT_RECEIVER Name denotes a send-once right. - * KERN_NOT_RECEIVER Name denotes a dead name. - */ - -kern_return_t -port_set_backup(space, name, backup, previousp) - ipc_space_t space; - mach_port_t name; - ipc_port_t backup; - ipc_port_t *previousp; -{ - ipc_port_t port, previous; - kern_return_t kr; - - if (space == IS_NULL) - return KERN_INVALID_ARGUMENT; - - if (backup == IP_DEAD) - backup = IP_NULL; - else if (backup != IP_NULL) - backup = ip_pdsendm(backup); - - kr = port_translate_compat(space, name, &port); - if (kr != KERN_SUCCESS) - return kr; - /* port is locked and active */ - - ipc_port_pdrequest(port, backup, &previous); - /* port is unlocked */ - - /* - * If previous was a send-once right instead of a send - * right, we can't return it in the reply message. - * So get rid of it in a notification instead. - */ - - if (previous != IP_NULL) { - if (ip_pdsendp(previous)) - previous = ip_pdsend(previous); - else { - ipc_notify_send_once(previous); - previous = IP_NULL; - } - } - - *previousp = previous; - return KERN_SUCCESS; -} - -/* - * Routine: port_status [kernel call] - * Purpose: - * Returns statistics related to "port_name", as seen by "task". - * Only the receiver for a given port will see true message - * counts. - * Conditions: - * Nothing locked. - * Returns: - * KERN_SUCCESS Retrieved status. - * KERN_INVALID_ARGUMENT Task is null. - * KERN_INVALID_ARGUMENT Task is not active. - * KERN_INVALID_ARGUMENT Name doesn't denote a port right. - * Additions: - * KERN_SUCCESS Send-once right. - * KERN_SUCCESS Dead name. - */ - -kern_return_t -port_status(space, name, enabledp, num_msgs, backlog, - ownership, receive_rights) - ipc_space_t space; - mach_port_t name; - mach_port_t *enabledp; - int *num_msgs; - int *backlog; - boolean_t *ownership; - boolean_t *receive_rights; -{ - ipc_entry_t entry; - mach_port_type_t type; - mach_port_urefs_t urefs; - kern_return_t kr; - - if (space == IS_NULL) - return KERN_INVALID_ARGUMENT; - - kr = ipc_right_lookup_write(space, name, &entry); - if (kr != KERN_SUCCESS) - return KERN_INVALID_ARGUMENT; - /* space is write-locked and active */ - - kr = ipc_right_info(space, name, entry, &type, &urefs); - if (kr != KERN_SUCCESS) - return KERN_INVALID_ARGUMENT; /* space is unlocked */ - - if ((type & MACH_PORT_TYPE_PORT_OR_DEAD) == 0) { - is_write_unlock(space); - return KERN_INVALID_ARGUMENT; - } - - if (type & MACH_PORT_TYPE_RECEIVE) { - mach_port_t enabled; - mach_port_msgcount_t qlimit; - mach_port_msgcount_t msgcount; - ipc_port_t port; - - port = (ipc_port_t) entry->ie_object; - assert(port != IP_NULL); - - ip_lock(port); - is_write_unlock(space); - assert(ip_active(port)); - - if (port->ip_pset != IPS_NULL) { - ipc_pset_t pset = port->ip_pset; - - ips_lock(pset); - if (!ips_active(pset)) { - ipc_pset_remove(pset, port); - ips_check_unlock(pset); - enabled = MACH_PORT_NULL; - } else { - enabled = pset->ips_local_name; - ips_unlock(pset); - assert(MACH_PORT_VALID(enabled)); - } - } else - enabled = MACH_PORT_NULL; - - qlimit = port->ip_qlimit; - msgcount = port->ip_msgcount; - ip_unlock(port); - - *ownership = TRUE; - *receive_rights = TRUE; - *enabledp = enabled; - *num_msgs = (int) msgcount; - *backlog = (int) qlimit; - } else { - is_write_unlock(space); - - *ownership = FALSE; - *receive_rights = FALSE; - *enabledp = MACH_PORT_NULL; - *num_msgs = -1; - *backlog = 0; - } - - return KERN_SUCCESS; -} - -/* - * Routine: port_set_allocate [kernel call] - * Purpose: - * Create a new port set, give rights to task, and - * return task's local name for the set. - * Conditions: - * Nothing locked. - * Returns: - * KERN_SUCCESS Allocated a port set. - * KERN_INVALID_ARGUMENT Task is null. - * KERN_INVALID_ARGUMENT Task is not active. - * KERN_RESOURCE_SHORTAGE Couldn't allocate memory. - */ - -kern_return_t -port_set_allocate(space, namep) - ipc_space_t space; - mach_port_t *namep; -{ - ipc_pset_t pset; - kern_return_t kr; - - if (space == IS_NULL) - return KERN_INVALID_ARGUMENT; - - kr = ipc_pset_alloc(space, namep, &pset); - if (kr == KERN_SUCCESS) - ips_unlock(pset); - else if (kr != KERN_RESOURCE_SHORTAGE) - kr = KERN_INVALID_ARGUMENT; - - return kr; -} - -/* - * Routine: port_set_deallocate [kernel call] - * Purpose: - * Destroys the task's port set. If there are any - * receive rights in the set, they are removed. - * Conditions: - * Nothing locked. - * Returns: - * KERN_SUCCESS Deallocated the port set. - * KERN_INVALID_ARGUMENT Task is null. - * KERN_INVALID_ARGUMENT Task is not active. - * KERN_INVALID_ARGUMENT Name doesn't denote a port set. - */ - -kern_return_t -port_set_deallocate(space, name) - ipc_space_t space; - mach_port_t name; -{ - ipc_entry_t entry; - kern_return_t kr; - - if (space == IS_NULL) - return KERN_INVALID_ARGUMENT; - - kr = ipc_right_lookup_write(space, name, &entry); - if (kr != KERN_SUCCESS) - return kr; - /* space is write-locked and active */ - - if ((entry->ie_bits & MACH_PORT_TYPE_PORT_SET) == 0) { - is_write_unlock(space); - return KERN_INVALID_ARGUMENT; - } - - kr = ipc_right_destroy(space, name, entry); - /* space is unlocked */ - assert(kr == KERN_SUCCESS); - return kr; -} - -/* - * Routine: port_set_add [kernel call] - * Purpose: - * Moves receive rights into the port set. - * Conditions: - * Nothing locked. - * Returns: - * KERN_SUCCESS Moved the receive right. - * KERN_INVALID_ARGUMENT Task is null. - * KERN_INVALID_ARGUMENT Task is not active. - * KERN_INVALID_ARGUMENT port_name doesn't denote port rights. - * KERN_NOT_RECEIVER port_name doesn't denote receive right. - * KERN_INVALID_ARGUMENT set_name doesn't denote a port set. - * Additions: - * KERN_NOT_RECEIVER port_name denotes a send-once right. - * KERN_NOT_RECEIVER port_name denotes a dead name. - */ - -kern_return_t -port_set_add(space, set_name, port_name) - ipc_space_t space; - mach_port_t set_name; - mach_port_t port_name; -{ - ipc_entry_t entry; - mach_port_type_t type; - mach_port_urefs_t urefs; - ipc_port_t port; - ipc_pset_t pset; - kern_return_t kr; - - if (space == IS_NULL) - return KERN_INVALID_ARGUMENT; - - kr = ipc_right_lookup_write(space, port_name, &entry); - if (kr != KERN_SUCCESS) - return KERN_INVALID_ARGUMENT; - /* space is write-locked and active */ - - /* use ipc_right_info to check for dead compat entries */ - - kr = ipc_right_info(space, port_name, entry, &type, &urefs); - if (kr != KERN_SUCCESS) - return KERN_INVALID_ARGUMENT; /* space is unlocked */ - - if ((type & MACH_PORT_TYPE_RECEIVE) == 0) { - is_write_unlock(space); - if (type & MACH_PORT_TYPE_PORT_OR_DEAD) - return KERN_NOT_RECEIVER; - else - return KERN_INVALID_ARGUMENT; - } - - is_write_to_read_lock(space); - port = (ipc_port_t) entry->ie_object; - assert(port != IP_NULL); - - entry = ipc_entry_lookup(space, set_name); - if ((entry == IE_NULL) || - ((entry->ie_bits & MACH_PORT_TYPE_PORT_SET) == 0)) { - is_read_unlock(space); - return KERN_INVALID_ARGUMENT; - } - - pset = (ipc_pset_t) entry->ie_object; - assert(pset != IPS_NULL); - - kr = ipc_pset_move(space, port, pset); - /* space is unlocked */ - assert(kr == KERN_SUCCESS); - return kr; -} - -/* - * Routine: port_set_remove [kernel call] - * Purpose: - * Removes the receive rights from the set they are in. - * Conditions: - * Nothing locked. - * Returns: - * KERN_SUCCESS Removed the receive right. - * KERN_INVALID_ARGUMENT Task is null. - * KERN_INVALID_ARGUMENT Task is not active. - * KERN_INVALID_ARGUMENT Name doesn't denote a port right. - * KERN_NOT_RECEIVER Name denotes send rights, not receive. - * KERN_NOT_IN_SET Port isn't in a port set. - * Additions: - * KERN_NOT_RECEIVER Name denotes a send-once right. - * KERN_NOT_RECEIVER Name denotes a dead name. - */ - -kern_return_t -port_set_remove(space, name) - ipc_space_t space; - mach_port_t name; -{ - ipc_entry_t entry; - mach_port_type_t type; - mach_port_urefs_t urefs; - ipc_port_t port; - kern_return_t kr; - - if (space == IS_NULL) - return KERN_INVALID_ARGUMENT; - - kr = ipc_right_lookup_write(space, name, &entry); - if (kr != KERN_SUCCESS) - return KERN_INVALID_ARGUMENT; - /* space is write-locked and active */ - - /* use ipc_right_info to check for dead compat entries */ - - kr = ipc_right_info(space, name, entry, &type, &urefs); - if (kr != KERN_SUCCESS) - return KERN_INVALID_ARGUMENT; /* space is unlocked */ - - if ((type & (MACH_PORT_TYPE_RECEIVE)) == 0) { - is_write_unlock(space); - if (type & MACH_PORT_TYPE_PORT_OR_DEAD) - return KERN_NOT_RECEIVER; - else - return KERN_INVALID_ARGUMENT; - } - - is_write_to_read_lock(space); - port = (ipc_port_t) entry->ie_object; - assert(port != IP_NULL); - - kr = ipc_pset_move(space, port, IPS_NULL); - /* space is unlocked */ - return kr; -} - -/* - * Routine: port_set_status [kernel call] - * Purpose: - * Retrieve list of members of a port set. - * Conditions: - * Nothing locked. - * Returns: - * KERN_SUCCESS Retrieved port set status. - * KERN_INVALID_ARGUMENT Task is null. - * KERN_INVALID_ARGUMENT Task is not active. - * KERN_INVALID_ARGUMENT Name doesn't denote a port set. - * Additions: - * KERN_RESOURCE_SHORTAGE Couldn't allocate memory. - */ - -kern_return_t -port_set_status(space, name, members, membersCnt) - ipc_space_t space; - mach_port_t name; - mach_port_t **members; - mach_msg_type_number_t *membersCnt; -{ - kern_return_t kr; - - kr = mach_port_get_set_status(space, name, members, membersCnt); - if ((kr != KERN_SUCCESS) && (kr != KERN_RESOURCE_SHORTAGE)) - kr = KERN_INVALID_ARGUMENT; - - return kr; -} - -/* - * Routine: port_insert_send [kernel call] - * Purpose: - * Inserts send rights to a port into a task, - * at a given name. The name must not be in use. - * Conditions: - * Nothing locked. - * Returns: - * KERN_SUCCESS Inserted send right. - * KERN_INVALID_ARGUMENT Task is null. - * KERN_INVALID_ARGUMENT Task is not active. - * KERN_INVALID_ARGUMENT Port is null or dead. - * KERN_INVALID_ARGUMENT Name is reserved. - * KERN_NAME_EXISTS Name already denotes a right. - * KERN_FAILURE Task already has rights for the port. - * Additions: - * KERN_RESOURCE_SHORTAGE Couldn't allocate memory. - */ - -kern_return_t -port_insert_send(space, port, name) - ipc_space_t space; - ipc_port_t port; - mach_port_t name; -{ - kern_return_t kr; - - if ((space == IS_NULL) || - !MACH_PORT_VALID(name) || - !IP_VALID(port)) - return KERN_INVALID_ARGUMENT; - - kr = ipc_object_copyout_name_compat(space, (ipc_object_t) port, - MACH_MSG_TYPE_PORT_SEND, name); - switch (kr) { - case KERN_SUCCESS: - case KERN_NAME_EXISTS: - case KERN_RESOURCE_SHORTAGE: - break; - - case KERN_RIGHT_EXISTS: - kr = KERN_FAILURE; - break; - - default: - kr = KERN_INVALID_ARGUMENT; - break; - } - - return kr; -} - -/* - * Routine: port_extract_send [kernel call] - * Purpose: - * Extracts send rights from "task"'s "his_name" port. - * The task is left with no rights for the port. - * Conditions: - * Nothing locked. - * Returns: - * KERN_SUCCESS Extracted send right. - * KERN_INVALID_ARGUMENT Task is null. - * KERN_INVALID_ARGUMENT Task is not active. - * KERN_INVALID_ARGUMENT Name doesn't denote pure send rights. - */ - -kern_return_t -port_extract_send(space, name, portp) - ipc_space_t space; - mach_port_t name; - ipc_port_t *portp; -{ - kern_return_t kr; - - if (space == IS_NULL) - return KERN_INVALID_ARGUMENT; - - kr = ipc_object_copyin_compat(space, name, - MSG_TYPE_PORT, TRUE, - (ipc_object_t *) portp); - if (kr != KERN_SUCCESS) - kr = KERN_INVALID_ARGUMENT; - - return kr; -} - -/* - * Routine: port_insert_receive [kernel call] - * Purpose: - * Inserts receive/ownership rights to a port into a task, - * at a given name. - * Conditions: - * Nothing locked. - * Returns: - * KERN_SUCCESS Inserted receive right. - * KERN_INVALID_ARGUMENT Task is null. - * KERN_INVALID_ARGUMENT Task is not active. - * KERN_INVALID_ARGUMENT Port is null. (Can't be dead.) - * KERN_INVALID_ARGUMENT Name is reserved. - * KERN_NAME_EXISTS Name already denotes a right. - * KERN_FAILURE Task already has rights for the port. - * Additions: - * KERN_RESOURCE_SHORTAGE Couldn't allocate memory. - */ - -kern_return_t -port_insert_receive(space, port, name) - ipc_space_t space; - ipc_port_t port; - mach_port_t name; -{ - kern_return_t kr; - - if ((space == IS_NULL) || - !MACH_PORT_VALID(name) || - !IP_VALID(port)) - return KERN_INVALID_ARGUMENT; - - kr = ipc_object_copyout_name_compat(space, (ipc_object_t) port, - MACH_MSG_TYPE_PORT_RECEIVE, name); - switch (kr) { - case KERN_SUCCESS: - case KERN_NAME_EXISTS: - case KERN_RESOURCE_SHORTAGE: - break; - - case KERN_RIGHT_EXISTS: - kr = KERN_FAILURE; - break; - - default: - kr = KERN_INVALID_ARGUMENT; - break; - } - - return kr; -} - -/* - * Routine: port_extract_receive [kernel call] - * Purpose: - * Extracts receive/ownership rights - * from "task"'s "his_name" port. - * - * The task is left with no rights for the port. - * Conditions: - * Nothing locked. - * Returns: - * KERN_SUCCESS Extracted receive right. - * KERN_INVALID_ARGUMENT Task is null. - * KERN_INVALID_ARGUMENT Task is not active. - * KERN_INVALID_ARGUMENT Name doesn't denote receive rights. - */ - -kern_return_t -port_extract_receive(space, name, portp) - ipc_space_t space; - mach_port_t name; - ipc_port_t *portp; -{ - kern_return_t kr; - - if (space == IS_NULL) - return KERN_INVALID_ARGUMENT; - - kr = ipc_object_copyin_compat(space, name, - MSG_TYPE_PORT_ALL, TRUE, - (ipc_object_t *) portp); - if (kr != KERN_SUCCESS) - kr = KERN_INVALID_ARGUMENT; - - return kr; -} - -#endif /* MACH_IPC_COMPAT */ |