Next: Port Rights, Previous: Port Destruction, Up: Port Manipulation Interface
The function
mach_port_namesreturns 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_deallocatethem when the data is no longer needed.
mach_port_nameswill 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_SUCCESSif the call succeeded,KERN_INVALID_TASKif task was invalid,KERN_RESOURCE_SHORTAGEif the kernel ran out of memory.The
mach_port_namescall 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_msgreturn codes.
The function
mach_port_typereturns 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_SUCCESSif the call succeeded,KERN_INVALID_TASKif task was invalid andKERN_INVALID_NAMEif name did not denote a right.The
mach_port_typecall 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_msgreturn codes.
The function
mach_port_renamechanges 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_NULLandMACH_PORT_DEAD.The function returns
KERN_SUCCESSif the call succeeded,KERN_INVALID_TASKif task was invalid,KERN_INVALID_NAMEif old_name did not denote a right,KERN_INVALID_VALUEif new_name wasMACH_PORT_NULLorMACH_PORT_DEAD,KERN_NAME_EXISTSifnew_namealready denoted a right andKERN_RESOURCE_SHORTAGEif the kernel ran out of memory.The
mach_port_renamecall 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_msgreturn codes.