Next: Port Rights, Previous: Port Destruction, Up: Port Manipulation Interface
The function
mach_port_names
returns information about task's port name space. For each name, it also returns what type of rights task holds. (The same information returned bymach_port_type
.) names and types are arrays that are automatically allocated when the reply message is received. The user shouldvm_deallocate
them when the data is no longer needed.
mach_port_names
will return in names the names of the ports, port sets, and dead names in the task's port name space, in no particular order and in ncount the number of names returned. It will return in types the type of each corresponding name, which indicates what kind of rights the task holds with that name. tcount should be the same as ncount.The function returns
KERN_SUCCESS
if the call succeeded,KERN_INVALID_TASK
if task was invalid,KERN_RESOURCE_SHORTAGE
if the kernel ran out of memory.The
mach_port_names
call is actually an RPC to task, normally a send right for a task port, but potentially any send right. In addition to the normal diagnostic return codes from the call's server (normally the kernel), the call may returnmach_msg
return codes.
The function
mach_port_type
returns information about task's rights for a specific name in its port name space. The returned ptype is a bitmask indicating what rights task holds for the port, port set or dead name. The bitmask is composed of the following bits:
MACH_PORT_TYPE_SEND
- The name denotes a send right.
MACH_PORT_TYPE_RECEIVE
- The name denotes a receive right.
MACH_PORT_TYPE_SEND_ONCE
- The name denotes a send-once right.
MACH_PORT_TYPE_PORT_SET
- The name denotes a port set.
MACH_PORT_TYPE_DEAD_NAME
- The name is a dead name.
MACH_PORT_TYPE_DNREQUEST
- A dead-name request has been registered for the right.
MACH_PORT_TYPE_MAREQUEST
- A msg-accepted request for the right is pending.
MACH_PORT_TYPE_COMPAT
- The port right was created in the compatibility mode.
The function returns
KERN_SUCCESS
if the call succeeded,KERN_INVALID_TASK
if task was invalid andKERN_INVALID_NAME
if name did not denote a right.The
mach_port_type
call is actually an RPC to task, normally a send right for a task port, but potentially any send right. In addition to the normal diagnostic return codes from the call's server (normally the kernel), the call may returnmach_msg
return codes.
The function
mach_port_rename
changes the name by which a port, port set, or dead name is known to task. old_name is the original name and new_name the new name for the port right. new_name must not already be in use, and it can't be the distinguished valuesMACH_PORT_NULL
andMACH_PORT_DEAD
.The function returns
KERN_SUCCESS
if the call succeeded,KERN_INVALID_TASK
if task was invalid,KERN_INVALID_NAME
if old_name did not denote a right,KERN_INVALID_VALUE
if new_name wasMACH_PORT_NULL
orMACH_PORT_DEAD
,KERN_NAME_EXISTS
ifnew_name
already denoted a right andKERN_RESOURCE_SHORTAGE
if the kernel ran out of memory.The
mach_port_rename
call is actually an RPC to task, normally a send right for a task port, but potentially any send right. In addition to the normal diagnostic return codes from the call's server (normally the kernel), the call may returnmach_msg
return codes.