From fc6bcf785b702e7e8a675ea0fe9856cc1b24b8f6 Mon Sep 17 00:00:00 2001 From: Luca Dariz Date: Mon, 16 Jan 2023 11:58:57 +0100 Subject: replace mach_port_t with mach_port_name_t This is a cleanup following the introduction of mach_port_name_t. The same set of changes is applied to all files: - rename mach_port_t to mach_port_name_t where a port name is used, - use MACH_PORT_NAME_NULL and MACH_PORT_NAME_DEAD where appropriate, - use invalid_port_to_name() and invalid_name_to_port() for conversion where appropriate, - use regular copyout() insted of copyout_port() when we deal with mach_port_name_t already before copyout, - use the new helper ipc_kmsg_copyout_object_to_port() when we really want to place a port name in the space of a mach_port_t. * include/mach/notify.h: Likewise * ipc/ipc_entry.c: Likewise * ipc/ipc_kmsg.c: Likewise * ipc/ipc_kmsg.h: Likewise, and add ipc_kmsg_copyout_object_to_port() * ipc/ipc_marequest.c: Likewise * ipc/ipc_object.c: Likewise * ipc/ipc_port.c: Likewise * ipc/ipc_space.h: Likewise * ipc/mach_msg.c: Likewise * ipc/mach_port.c: Likewise * kern/exception.c: Likewise * kern/ipc_mig.c: Likewise Message-Id: <20230116105857.240210-8-luca@orpolo.org> --- kern/exception.c | 12 ++++++------ kern/ipc_mig.c | 16 ++++++++-------- 2 files changed, 14 insertions(+), 14 deletions(-) (limited to 'kern') diff --git a/kern/exception.c b/kern/exception.c index 0d8191a7..1014b3ed 100644 --- a/kern/exception.c +++ b/kern/exception.c @@ -269,9 +269,9 @@ exception_no_server(void) struct mach_exception { mach_msg_header_t Head; mach_msg_type_t threadType; - mach_port_name_t thread; + mach_port_t thread; mach_msg_type_t taskType; - mach_port_name_t task; + mach_port_t task; mach_msg_type_t exceptionType; integer_t exception; mach_msg_type_t codeType; @@ -658,10 +658,10 @@ exception_raise( * to handle the two ports in the body. */ - mr = (ipc_kmsg_copyout_object(space, (ipc_object_t) thread_port, - MACH_MSG_TYPE_PORT_SEND, &exc->thread) | - ipc_kmsg_copyout_object(space, (ipc_object_t) task_port, - MACH_MSG_TYPE_PORT_SEND, &exc->task)); + mr = (ipc_kmsg_copyout_object_to_port(space, (ipc_object_t) thread_port, + MACH_MSG_TYPE_PORT_SEND, &exc->thread) | + ipc_kmsg_copyout_object_to_port(space, (ipc_object_t) task_port, + MACH_MSG_TYPE_PORT_SEND, &exc->task)); if (mr != MACH_MSG_SUCCESS) { (void) ipc_kmsg_put(receiver->ith_msg, kmsg, kmsg->ikm_header.msgh_size); diff --git a/kern/ipc_mig.c b/kern/ipc_mig.c index aa433614..a1757da3 100644 --- a/kern/ipc_mig.c +++ b/kern/ipc_mig.c @@ -597,7 +597,7 @@ syscall_vm_map( if (map == VM_MAP_NULL) return MACH_SEND_INTERRUPTED; - if (MACH_PORT_VALID(memory_object)) { + if (MACH_PORT_NAME_VALID(memory_object)) { result = ipc_object_copyin(current_space(), memory_object, MACH_MSG_TYPE_COPY_SEND, (ipc_object_t *) &port); @@ -606,7 +606,7 @@ syscall_vm_map( return result; } } else - port = (ipc_port_t) memory_object; + port = (ipc_port_t)invalid_name_to_port(memory_object); copyin_address(address, &addr); result = vm_map(map, &addr, size, mask, anywhere, @@ -683,7 +683,7 @@ kern_return_t syscall_task_create( (void) ipc_kmsg_copyout_object(current_space(), (ipc_object_t) port, MACH_MSG_TYPE_PORT_SEND, &name); - copyout_port(&name, child_task); + copyout(&name, child_task, sizeof(mach_port_name_t)); } task_deallocate(t); @@ -733,7 +733,7 @@ kern_return_t syscall_task_set_special_port( if (t == TASK_NULL) return MACH_SEND_INTERRUPTED; - if (MACH_PORT_VALID(port_name)) { + if (MACH_PORT_NAME_VALID(port_name)) { result = ipc_object_copyin(current_space(), port_name, MACH_MSG_TYPE_COPY_SEND, (ipc_object_t *) &port); @@ -742,7 +742,7 @@ kern_return_t syscall_task_set_special_port( return result; } } else - port = (ipc_port_t) port_name; + port = (ipc_port_t)invalid_name_to_port(port_name); result = task_set_special_port(t, which_port, port); if ((result != KERN_SUCCESS) && IP_VALID(port)) @@ -769,7 +769,7 @@ syscall_mach_port_allocate( kr = mach_port_allocate(space, right, &name); if (kr == KERN_SUCCESS) { - copyout_port(&name, namep); + copyout(&name, namep, sizeof(mach_port_name_t)); } is_release(space); @@ -834,7 +834,7 @@ syscall_mach_port_insert_right( return KERN_INVALID_VALUE; } - if (MACH_PORT_VALID(right)) { + if (MACH_PORT_NAME_VALID(right)) { kr = ipc_object_copyin(current_space(), right, rightType, &object); if (kr != KERN_SUCCESS) { @@ -842,7 +842,7 @@ syscall_mach_port_insert_right( return kr; } } else - object = (ipc_object_t) right; + object = (ipc_object_t)invalid_name_to_port(right); newtype = ipc_object_copyin_type(rightType); kr = mach_port_insert_right(space, name, (ipc_port_t) object, newtype); -- cgit v1.2.3