2003-01-03 16:40:04 +03:00
|
|
|
/* $NetBSD: mach_port.c,v 1.30 2003/01/03 13:40:05 manu Exp $ */
|
2002-11-11 00:53:40 +03:00
|
|
|
|
|
|
|
/*-
|
2003-01-02 15:46:06 +03:00
|
|
|
* Copyright (c) 2002-2003 The NetBSD Foundation, Inc.
|
2002-11-11 00:53:40 +03:00
|
|
|
* All rights reserved.
|
|
|
|
*
|
|
|
|
* This code is derived from software contributed to The NetBSD Foundation
|
|
|
|
* by Emmanuel Dreyfus
|
|
|
|
*
|
|
|
|
* Redistribution and use in source and binary forms, with or without
|
|
|
|
* modification, are permitted provided that the following conditions
|
|
|
|
* are met:
|
|
|
|
* 1. Redistributions of source code must retain the above copyright
|
|
|
|
* notice, this list of conditions and the following disclaimer.
|
|
|
|
* 2. Redistributions in binary form must reproduce the above copyright
|
|
|
|
* notice, this list of conditions and the following disclaimer in the
|
|
|
|
* documentation and/or other materials provided with the distribution.
|
|
|
|
* 3. All advertising materials mentioning features or use of this software
|
|
|
|
* must display the following acknowledgement:
|
|
|
|
* This product includes software developed by the NetBSD
|
|
|
|
* Foundation, Inc. and its contributors.
|
|
|
|
* 4. Neither the name of The NetBSD Foundation nor the names of its
|
|
|
|
* contributors may be used to endorse or promote products derived
|
|
|
|
* from this software without specific prior written permission.
|
|
|
|
*
|
|
|
|
* THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
|
|
|
|
* ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
|
|
|
|
* TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
|
|
|
|
* PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
|
|
|
|
* BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
|
|
|
|
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
|
|
|
|
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
|
|
|
|
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
|
|
|
|
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
|
|
|
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
|
|
|
* POSSIBILITY OF SUCH DAMAGE.
|
|
|
|
*/
|
|
|
|
|
2002-12-30 21:44:33 +03:00
|
|
|
#include "opt_compat_darwin.h"
|
|
|
|
|
2002-11-11 00:53:40 +03:00
|
|
|
#include <sys/cdefs.h>
|
2003-01-03 16:40:04 +03:00
|
|
|
__KERNEL_RCSID(0, "$NetBSD: mach_port.c,v 1.30 2003/01/03 13:40:05 manu Exp $");
|
2002-11-11 00:53:40 +03:00
|
|
|
|
|
|
|
#include <sys/types.h>
|
|
|
|
#include <sys/param.h>
|
|
|
|
#include <sys/systm.h>
|
|
|
|
#include <sys/signal.h>
|
2002-12-15 03:40:24 +03:00
|
|
|
#include <sys/pool.h>
|
|
|
|
#include <sys/queue.h>
|
|
|
|
#include <sys/malloc.h>
|
2002-11-11 00:53:40 +03:00
|
|
|
#include <sys/proc.h>
|
|
|
|
|
|
|
|
#include <compat/mach/mach_types.h>
|
|
|
|
#include <compat/mach/mach_message.h>
|
|
|
|
#include <compat/mach/mach_port.h>
|
2002-11-26 11:10:14 +03:00
|
|
|
#include <compat/mach/mach_clock.h>
|
2002-12-15 03:40:24 +03:00
|
|
|
#include <compat/mach/mach_exec.h>
|
|
|
|
#include <compat/mach/mach_errno.h>
|
2002-11-11 00:53:40 +03:00
|
|
|
#include <compat/mach/mach_syscallargs.h>
|
|
|
|
|
2002-12-30 21:44:33 +03:00
|
|
|
#ifdef COMPAT_DARWIN
|
|
|
|
#include <compat/darwin/darwin_exec.h>
|
|
|
|
#endif
|
|
|
|
|
2002-12-17 21:42:54 +03:00
|
|
|
/* Right and port pools, list of all rights and its lock */
|
2002-12-15 03:40:24 +03:00
|
|
|
static struct pool mach_port_pool;
|
|
|
|
static struct pool mach_right_pool;
|
|
|
|
|
2002-12-27 22:57:47 +03:00
|
|
|
struct mach_port *mach_bootstrap_port;
|
|
|
|
struct mach_port *mach_clock_port;
|
2002-12-30 21:44:33 +03:00
|
|
|
struct mach_port *mach_saved_bootstrap_port;
|
2002-12-27 22:57:47 +03:00
|
|
|
|
2002-11-11 00:53:40 +03:00
|
|
|
int
|
|
|
|
mach_sys_reply_port(p, v, retval)
|
|
|
|
struct proc *p;
|
|
|
|
void *v;
|
|
|
|
register_t *retval;
|
|
|
|
{
|
2002-12-15 03:40:24 +03:00
|
|
|
struct mach_right *mr;
|
|
|
|
|
2002-12-31 18:47:37 +03:00
|
|
|
mr = mach_right_get(mach_port_get(), p, MACH_PORT_TYPE_RECEIVE, 0);
|
|
|
|
*retval = (register_t)mr->mr_name;
|
2002-11-11 00:53:40 +03:00
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
int
|
|
|
|
mach_sys_thread_self_trap(p, v, retval)
|
|
|
|
struct proc *p;
|
|
|
|
void *v;
|
|
|
|
register_t *retval;
|
|
|
|
{
|
2002-12-15 03:40:24 +03:00
|
|
|
struct mach_emuldata *med;
|
|
|
|
struct mach_right *mr;
|
|
|
|
|
|
|
|
/*
|
|
|
|
* XXX for now thread kernel port and task kernel port are the same
|
|
|
|
* awaiting for struct lwp ...
|
|
|
|
*/
|
|
|
|
med = (struct mach_emuldata *)p->p_emuldata;
|
2002-12-31 18:47:37 +03:00
|
|
|
mr = mach_right_get(med->med_kernel, p, MACH_PORT_TYPE_SEND, 0);
|
|
|
|
*retval = (register_t)mr->mr_name;
|
2002-12-15 03:40:24 +03:00
|
|
|
|
2002-11-11 00:53:40 +03:00
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
int
|
|
|
|
mach_sys_task_self_trap(p, v, retval)
|
|
|
|
struct proc *p;
|
|
|
|
void *v;
|
|
|
|
register_t *retval;
|
|
|
|
{
|
2002-12-15 03:40:24 +03:00
|
|
|
struct mach_emuldata *med;
|
|
|
|
struct mach_right *mr;
|
|
|
|
|
|
|
|
med = (struct mach_emuldata *)p->p_emuldata;
|
2002-12-31 18:47:37 +03:00
|
|
|
mr = mach_right_get(med->med_kernel, p, MACH_PORT_TYPE_SEND, 0);
|
|
|
|
*retval = (register_t)mr->mr_name;
|
2002-12-15 03:40:24 +03:00
|
|
|
|
2002-11-11 00:53:40 +03:00
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
int
|
|
|
|
mach_sys_host_self_trap(p, v, retval)
|
|
|
|
struct proc *p;
|
|
|
|
void *v;
|
|
|
|
register_t *retval;
|
|
|
|
{
|
2002-12-15 03:40:24 +03:00
|
|
|
struct mach_emuldata *med;
|
|
|
|
struct mach_right *mr;
|
|
|
|
|
|
|
|
med = (struct mach_emuldata *)p->p_emuldata;
|
2002-12-31 18:47:37 +03:00
|
|
|
mr = mach_right_get(med->med_host, p, MACH_PORT_TYPE_SEND, 0);
|
|
|
|
*retval = (register_t)mr->mr_name;
|
2002-12-15 03:40:24 +03:00
|
|
|
|
2002-11-11 00:53:40 +03:00
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
int
|
2002-12-17 21:42:54 +03:00
|
|
|
mach_port_deallocate(args)
|
|
|
|
struct mach_trap_args *args;
|
2002-11-11 00:53:40 +03:00
|
|
|
{
|
2002-12-17 21:42:54 +03:00
|
|
|
mach_port_deallocate_request_t *req = args->smsg;
|
|
|
|
mach_port_deallocate_reply_t *rep = args->rmsg;
|
|
|
|
size_t *msglen = args->rsize;
|
|
|
|
struct proc *p = args->p;
|
2002-12-31 18:47:37 +03:00
|
|
|
mach_port_t mn;
|
2002-12-15 03:40:24 +03:00
|
|
|
struct mach_right *mr;
|
2002-11-11 00:53:40 +03:00
|
|
|
|
2002-12-31 18:47:37 +03:00
|
|
|
mn = req->req_name;
|
2003-01-03 16:40:04 +03:00
|
|
|
if ((mr = mach_right_check(mn, p, MACH_PORT_TYPE_REF_RIGHTS)) != NULL)
|
|
|
|
mach_right_put(mr, MACH_PORT_TYPE_REF_RIGHTS);
|
2002-12-31 18:47:37 +03:00
|
|
|
|
2002-12-17 21:42:54 +03:00
|
|
|
rep->rep_msgh.msgh_bits =
|
2002-11-11 12:28:00 +03:00
|
|
|
MACH_MSGH_REPLY_LOCAL_BITS(MACH_MSG_TYPE_MOVE_SEND_ONCE);
|
2002-12-17 21:42:54 +03:00
|
|
|
rep->rep_msgh.msgh_size = sizeof(*rep) - sizeof(rep->rep_trailer);
|
|
|
|
rep->rep_msgh.msgh_local_port = req->req_msgh.msgh_local_port;
|
|
|
|
rep->rep_msgh.msgh_id = req->req_msgh.msgh_id + 100;
|
|
|
|
rep->rep_trailer.msgh_trailer_size = 8;
|
2002-11-11 00:53:40 +03:00
|
|
|
|
2002-12-17 21:42:54 +03:00
|
|
|
*msglen = sizeof(*rep);
|
|
|
|
return 0;
|
2002-11-11 00:53:40 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
int
|
2002-12-17 21:42:54 +03:00
|
|
|
mach_port_allocate(args)
|
|
|
|
struct mach_trap_args *args;
|
2002-11-11 00:53:40 +03:00
|
|
|
{
|
2002-12-17 21:42:54 +03:00
|
|
|
mach_port_allocate_request_t *req = args->smsg;
|
|
|
|
mach_port_allocate_reply_t *rep = args->rmsg;
|
|
|
|
size_t *msglen = args->rsize;
|
|
|
|
struct proc *p = args->p;
|
2002-12-15 03:40:24 +03:00
|
|
|
struct mach_right *mr;
|
2002-12-31 18:47:37 +03:00
|
|
|
struct mach_port *mp;
|
2002-11-11 00:53:40 +03:00
|
|
|
|
2002-12-17 21:42:54 +03:00
|
|
|
switch (req->req_right) {
|
2002-12-15 03:40:24 +03:00
|
|
|
case MACH_PORT_RIGHT_RECEIVE:
|
2002-12-31 18:47:37 +03:00
|
|
|
mp = mach_port_get();
|
|
|
|
mr = mach_right_get(mp, p, MACH_PORT_TYPE_RECEIVE, 0);
|
2002-12-15 03:40:24 +03:00
|
|
|
break;
|
|
|
|
|
|
|
|
case MACH_PORT_RIGHT_DEAD_NAME:
|
2002-12-31 18:47:37 +03:00
|
|
|
mr = mach_right_get(NULL, p, MACH_PORT_TYPE_DEAD_NAME, 0);
|
2002-12-15 03:40:24 +03:00
|
|
|
break;
|
|
|
|
|
|
|
|
case MACH_PORT_RIGHT_PORT_SET:
|
2002-12-31 18:47:37 +03:00
|
|
|
mr = mach_right_get(NULL, p, MACH_PORT_TYPE_PORT_SET, 0);
|
2002-12-15 03:40:24 +03:00
|
|
|
break;
|
|
|
|
|
|
|
|
default:
|
2002-12-22 02:50:00 +03:00
|
|
|
uprintf("mach_port_allocate: unknown right %x\n",
|
2002-12-17 21:42:54 +03:00
|
|
|
req->req_right);
|
2002-12-15 03:40:24 +03:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
2002-12-17 21:42:54 +03:00
|
|
|
rep->rep_msgh.msgh_bits =
|
2002-11-11 12:28:00 +03:00
|
|
|
MACH_MSGH_REPLY_LOCAL_BITS(MACH_MSG_TYPE_MOVE_SEND_ONCE);
|
2002-12-17 21:42:54 +03:00
|
|
|
rep->rep_msgh.msgh_size = sizeof(*rep) - sizeof(rep->rep_trailer);
|
|
|
|
rep->rep_msgh.msgh_local_port = req->req_msgh.msgh_local_port;
|
|
|
|
rep->rep_msgh.msgh_id = req->req_msgh.msgh_id + 100;
|
2002-12-31 18:47:37 +03:00
|
|
|
rep->rep_name = (mach_port_name_t)mr->mr_name;
|
2002-12-17 21:42:54 +03:00
|
|
|
rep->rep_trailer.msgh_trailer_size = 8;
|
2002-11-11 00:53:40 +03:00
|
|
|
|
2002-12-17 21:42:54 +03:00
|
|
|
*msglen = sizeof(*rep);
|
|
|
|
return 0;
|
2002-11-11 00:53:40 +03:00
|
|
|
}
|
|
|
|
|
2002-11-19 22:54:07 +03:00
|
|
|
int
|
2002-12-17 21:42:54 +03:00
|
|
|
mach_port_insert_right(args)
|
|
|
|
struct mach_trap_args *args;
|
2002-11-19 22:54:07 +03:00
|
|
|
{
|
2002-12-17 21:42:54 +03:00
|
|
|
mach_port_insert_right_request_t *req = args->smsg;
|
|
|
|
mach_port_insert_right_reply_t *rep = args->rmsg;
|
|
|
|
size_t *msglen = args->rsize;
|
|
|
|
struct proc *p = args->p;
|
2002-12-31 18:47:37 +03:00
|
|
|
mach_port_t name;
|
|
|
|
mach_port_t right;
|
2002-12-15 03:40:24 +03:00
|
|
|
struct mach_right *mr;
|
|
|
|
struct mach_right *nmr;
|
2002-11-19 22:54:07 +03:00
|
|
|
|
2002-12-31 18:47:37 +03:00
|
|
|
name = req->req_name;
|
|
|
|
right = req->req_poly.name;
|
2002-12-15 03:40:24 +03:00
|
|
|
nmr = NULL;
|
|
|
|
|
2002-12-31 18:47:37 +03:00
|
|
|
mr = mach_right_check(right, p, MACH_PORT_TYPE_ALL_RIGHTS);
|
|
|
|
if (mr == NULL)
|
2002-12-17 21:42:54 +03:00
|
|
|
return mach_msg_error(args, EPERM);
|
|
|
|
|
2002-12-22 02:50:00 +03:00
|
|
|
switch (req->req_poly.disposition) {
|
2002-12-15 03:40:24 +03:00
|
|
|
case MACH_MSG_TYPE_MAKE_SEND:
|
|
|
|
case MACH_MSG_TYPE_MOVE_SEND:
|
|
|
|
case MACH_MSG_TYPE_COPY_SEND:
|
2002-12-31 18:47:37 +03:00
|
|
|
nmr = mach_right_get(mr->mr_port,
|
|
|
|
p, MACH_PORT_TYPE_SEND, name);
|
2002-12-15 03:40:24 +03:00
|
|
|
break;
|
|
|
|
|
|
|
|
case MACH_MSG_TYPE_MAKE_SEND_ONCE:
|
|
|
|
case MACH_MSG_TYPE_MOVE_SEND_ONCE:
|
|
|
|
nmr = mach_right_get(mr->mr_port,
|
2002-12-31 18:47:37 +03:00
|
|
|
p, MACH_PORT_TYPE_SEND_ONCE, name);
|
2002-12-15 03:40:24 +03:00
|
|
|
break;
|
|
|
|
|
|
|
|
case MACH_MSG_TYPE_MOVE_RECEIVE:
|
2002-12-31 18:47:37 +03:00
|
|
|
nmr = mach_right_get(mr->mr_port,
|
|
|
|
p, MACH_PORT_TYPE_RECEIVE, name);
|
2002-12-15 03:40:24 +03:00
|
|
|
break;
|
|
|
|
|
|
|
|
default:
|
2002-12-22 02:50:00 +03:00
|
|
|
uprintf("mach_port_insert_right: unknown right %x\n",
|
|
|
|
req->req_poly.disposition);
|
2002-12-15 03:40:24 +03:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
2002-12-17 21:42:54 +03:00
|
|
|
rep->rep_msgh.msgh_bits =
|
2002-11-19 22:54:07 +03:00
|
|
|
MACH_MSGH_REPLY_LOCAL_BITS(MACH_MSG_TYPE_MOVE_SEND_ONCE);
|
2002-12-17 21:42:54 +03:00
|
|
|
rep->rep_msgh.msgh_size = sizeof(*rep) - sizeof(rep->rep_trailer);
|
|
|
|
rep->rep_msgh.msgh_local_port = req->req_msgh.msgh_local_port;
|
|
|
|
rep->rep_msgh.msgh_id = req->req_msgh.msgh_id + 100;
|
|
|
|
rep->rep_trailer.msgh_trailer_size = 8;
|
2002-11-19 22:54:07 +03:00
|
|
|
|
2002-12-17 21:42:54 +03:00
|
|
|
*msglen = sizeof(*rep);
|
|
|
|
return 0;
|
2002-11-19 22:54:07 +03:00
|
|
|
}
|
|
|
|
|
2002-12-08 00:23:03 +03:00
|
|
|
int
|
2002-12-17 21:42:54 +03:00
|
|
|
mach_port_type(args)
|
|
|
|
struct mach_trap_args *args;
|
2002-12-08 00:23:03 +03:00
|
|
|
{
|
2002-12-17 21:42:54 +03:00
|
|
|
mach_port_type_request_t *req = args->smsg;
|
|
|
|
mach_port_type_reply_t *rep = args->rmsg;
|
|
|
|
size_t *msglen = args->rsize;
|
|
|
|
struct proc *p = args->p;
|
2002-12-31 18:47:37 +03:00
|
|
|
mach_port_t mn;
|
2002-12-15 03:40:24 +03:00
|
|
|
struct mach_right *mr;
|
2002-12-08 00:23:03 +03:00
|
|
|
|
2002-12-31 18:47:37 +03:00
|
|
|
mn = req->req_name;
|
2003-01-02 15:46:06 +03:00
|
|
|
if ((mr = mach_right_check(mn, p, MACH_PORT_TYPE_ALL_RIGHTS)) == NULL)
|
2002-12-17 21:42:54 +03:00
|
|
|
return mach_msg_error(args, EPERM);
|
2002-12-15 03:40:24 +03:00
|
|
|
|
2002-12-17 21:42:54 +03:00
|
|
|
rep->rep_msgh.msgh_bits =
|
2002-12-08 00:23:03 +03:00
|
|
|
MACH_MSGH_REPLY_LOCAL_BITS(MACH_MSG_TYPE_MOVE_SEND_ONCE);
|
2002-12-17 21:42:54 +03:00
|
|
|
rep->rep_msgh.msgh_size = sizeof(*rep) - sizeof(rep->rep_trailer);
|
|
|
|
rep->rep_msgh.msgh_local_port = req->req_msgh.msgh_local_port;
|
|
|
|
rep->rep_msgh.msgh_id = req->req_msgh.msgh_id + 100;
|
|
|
|
rep->rep_retval = 0;
|
|
|
|
rep->rep_ptype = mr->mr_type;
|
|
|
|
rep->rep_trailer.msgh_trailer_size = 8;
|
|
|
|
|
|
|
|
*msglen = sizeof(*rep);
|
|
|
|
return 0;
|
2002-12-08 00:23:03 +03:00
|
|
|
}
|
|
|
|
|
2002-12-11 00:36:45 +03:00
|
|
|
int
|
2002-12-17 21:42:54 +03:00
|
|
|
mach_port_set_attributes(args)
|
|
|
|
struct mach_trap_args *args;
|
2002-12-11 00:36:45 +03:00
|
|
|
{
|
2002-12-17 21:42:54 +03:00
|
|
|
mach_port_set_attributes_request_t *req = args->smsg;
|
|
|
|
mach_port_set_attributes_reply_t *rep = args->rmsg;
|
|
|
|
size_t *msglen = args->rsize;
|
2002-12-11 00:36:45 +03:00
|
|
|
|
2002-12-17 21:42:54 +03:00
|
|
|
switch(req->req_flavor) {
|
2002-12-11 00:36:45 +03:00
|
|
|
case MACH_PORT_LIMITS_INFO:
|
|
|
|
case MACH_PORT_RECEIVE_STATUS:
|
|
|
|
case MACH_PORT_DNREQUESTS_SIZE:
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
uprintf("mach_port_get_attributes: unknown flavor %d\n",
|
2002-12-17 21:42:54 +03:00
|
|
|
req->req_flavor);
|
2002-12-11 00:36:45 +03:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
2002-12-17 21:42:54 +03:00
|
|
|
rep->rep_msgh.msgh_bits =
|
2002-12-11 00:36:45 +03:00
|
|
|
MACH_MSGH_REPLY_LOCAL_BITS(MACH_MSG_TYPE_MOVE_SEND_ONCE);
|
2002-12-17 21:42:54 +03:00
|
|
|
rep->rep_msgh.msgh_size = sizeof(*rep) - sizeof(rep->rep_trailer);
|
|
|
|
rep->rep_msgh.msgh_local_port = req->req_msgh.msgh_local_port;
|
|
|
|
rep->rep_msgh.msgh_id = req->req_msgh.msgh_id + 100;
|
|
|
|
rep->rep_trailer.msgh_trailer_size = 8;
|
2002-12-11 00:36:45 +03:00
|
|
|
|
2002-12-17 21:42:54 +03:00
|
|
|
*msglen = sizeof(*rep);
|
|
|
|
return 0;
|
2002-12-11 00:36:45 +03:00
|
|
|
}
|
|
|
|
|
2002-12-31 18:47:37 +03:00
|
|
|
/* XXX insert a recv right into a port set without removing it from another */
|
2002-12-11 00:36:45 +03:00
|
|
|
int
|
2002-12-17 21:42:54 +03:00
|
|
|
mach_port_insert_member(args)
|
|
|
|
struct mach_trap_args *args;
|
2002-12-11 00:36:45 +03:00
|
|
|
{
|
2002-12-17 21:42:54 +03:00
|
|
|
mach_port_insert_member_request_t *req = args->smsg;
|
|
|
|
mach_port_insert_member_reply_t *rep = args->rmsg;
|
|
|
|
size_t *msglen = args->rsize;
|
2002-12-11 00:36:45 +03:00
|
|
|
|
2002-12-17 21:42:54 +03:00
|
|
|
rep->rep_msgh.msgh_bits =
|
2002-12-11 00:36:45 +03:00
|
|
|
MACH_MSGH_REPLY_LOCAL_BITS(MACH_MSG_TYPE_MOVE_SEND_ONCE);
|
2002-12-17 21:42:54 +03:00
|
|
|
rep->rep_msgh.msgh_size = sizeof(*rep) - sizeof(rep->rep_trailer);
|
|
|
|
rep->rep_msgh.msgh_local_port = req->req_msgh.msgh_local_port;
|
|
|
|
rep->rep_msgh.msgh_id = req->req_msgh.msgh_id + 100;
|
|
|
|
rep->rep_trailer.msgh_trailer_size = 8;
|
2002-12-11 00:36:45 +03:00
|
|
|
|
2002-12-17 21:42:54 +03:00
|
|
|
*msglen = sizeof(*rep);
|
|
|
|
return 0;
|
2002-12-11 00:36:45 +03:00
|
|
|
}
|
2002-12-12 03:29:23 +03:00
|
|
|
|
|
|
|
int
|
2002-12-17 21:42:54 +03:00
|
|
|
mach_port_move_member(args)
|
|
|
|
struct mach_trap_args *args;
|
2002-12-12 03:29:23 +03:00
|
|
|
{
|
2002-12-20 01:23:06 +03:00
|
|
|
mach_port_move_member_request_t *req = args->smsg;
|
|
|
|
mach_port_move_member_reply_t *rep = args->rmsg;
|
2002-12-17 21:42:54 +03:00
|
|
|
size_t *msglen = args->rsize;
|
2002-12-20 01:23:06 +03:00
|
|
|
struct proc *p = args->p;
|
2003-01-03 16:40:04 +03:00
|
|
|
struct mach_emuldata *med = p->p_emuldata;
|
2002-12-31 18:47:37 +03:00
|
|
|
mach_port_t member = req->req_member;
|
|
|
|
mach_port_t after = req->req_after;
|
|
|
|
struct mach_right *mrr;
|
|
|
|
struct mach_right *mrs;
|
2002-12-20 01:23:06 +03:00
|
|
|
|
2002-12-31 18:47:37 +03:00
|
|
|
mrr = mach_right_check(member, p, MACH_PORT_TYPE_RECEIVE);
|
|
|
|
if (mrr == NULL)
|
2002-12-20 01:23:06 +03:00
|
|
|
return mach_msg_error(args, EPERM);
|
|
|
|
|
2002-12-31 18:47:37 +03:00
|
|
|
mrs = mach_right_check(after, p, MACH_PORT_TYPE_PORT_SET);
|
|
|
|
if (mrs == NULL)
|
2002-12-20 01:23:06 +03:00
|
|
|
return mach_msg_error(args, EPERM);
|
|
|
|
|
2003-01-03 16:40:04 +03:00
|
|
|
lockmgr(&med->med_rightlock, LK_EXCLUSIVE, NULL);
|
2002-12-30 21:44:33 +03:00
|
|
|
|
|
|
|
/* Remove it from an existing port set */
|
2002-12-30 15:41:52 +03:00
|
|
|
if (mrr->mr_sethead != mrr)
|
2002-12-20 01:23:06 +03:00
|
|
|
LIST_REMOVE(mrr, mr_setlist);
|
|
|
|
|
|
|
|
/* Insert it into the new port set */
|
|
|
|
LIST_INSERT_HEAD(&mrs->mr_set, mrr, mr_setlist);
|
|
|
|
mrr->mr_sethead = mrs;
|
|
|
|
|
2003-01-03 16:40:04 +03:00
|
|
|
lockmgr(&med->med_rightlock, LK_RELEASE, NULL);
|
2002-12-12 03:29:23 +03:00
|
|
|
|
2002-12-17 21:42:54 +03:00
|
|
|
rep->rep_msgh.msgh_bits =
|
2002-12-12 03:29:23 +03:00
|
|
|
MACH_MSGH_REPLY_LOCAL_BITS(MACH_MSG_TYPE_MOVE_SEND_ONCE);
|
2002-12-17 21:42:54 +03:00
|
|
|
rep->rep_msgh.msgh_size = sizeof(*rep) - sizeof(rep->rep_trailer);
|
|
|
|
rep->rep_msgh.msgh_local_port = req->req_msgh.msgh_local_port;
|
|
|
|
rep->rep_msgh.msgh_id = req->req_msgh.msgh_id + 100;
|
|
|
|
rep->rep_trailer.msgh_trailer_size = 8;
|
2002-12-12 03:29:23 +03:00
|
|
|
|
2002-12-17 21:42:54 +03:00
|
|
|
*msglen = sizeof(*rep);
|
|
|
|
return 0;
|
2002-12-12 03:29:23 +03:00
|
|
|
}
|
|
|
|
|
2002-12-15 03:40:24 +03:00
|
|
|
void
|
|
|
|
mach_port_init(void)
|
|
|
|
{
|
|
|
|
pool_init(&mach_port_pool, sizeof (struct mach_port),
|
|
|
|
0, 0, 128, "mach_port_pool", NULL);
|
|
|
|
pool_init(&mach_right_pool, sizeof (struct mach_right),
|
|
|
|
0, 0, 128, "mach_right_pool", NULL);
|
2002-12-27 22:57:47 +03:00
|
|
|
|
|
|
|
mach_bootstrap_port = mach_port_get();
|
|
|
|
mach_clock_port = mach_port_get();
|
2002-12-30 21:44:33 +03:00
|
|
|
mach_saved_bootstrap_port = mach_bootstrap_port;
|
2002-12-27 22:57:47 +03:00
|
|
|
|
2002-12-15 03:40:24 +03:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
struct mach_port *
|
2002-12-18 01:48:33 +03:00
|
|
|
mach_port_get(void)
|
2002-12-15 03:40:24 +03:00
|
|
|
{
|
|
|
|
struct mach_port *mp;
|
|
|
|
|
|
|
|
mp = (struct mach_port *)pool_get(&mach_port_pool, M_WAITOK);
|
2002-12-17 21:42:54 +03:00
|
|
|
bzero(mp, sizeof(*mp));
|
2002-12-18 01:48:33 +03:00
|
|
|
mp->mp_recv = NULL;
|
2002-12-15 03:40:24 +03:00
|
|
|
mp->mp_count = 0;
|
|
|
|
TAILQ_INIT(&mp->mp_msglist);
|
|
|
|
lockinit(&mp->mp_msglock, PZERO|PCATCH, "mach_port", 0, 0);
|
|
|
|
|
|
|
|
return mp;
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
mach_port_put(mp)
|
|
|
|
struct mach_port *mp;
|
|
|
|
{
|
|
|
|
struct mach_message *mm;
|
|
|
|
|
2003-01-03 16:40:04 +03:00
|
|
|
if (mp->mp_refcount > 0) {
|
2002-12-27 12:59:24 +03:00
|
|
|
uprintf("mach_port_put: trying to free a referenced port\n");
|
|
|
|
return;
|
2002-12-17 21:42:54 +03:00
|
|
|
}
|
2002-12-15 03:40:24 +03:00
|
|
|
|
|
|
|
lockmgr(&mp->mp_msglock, LK_EXCLUSIVE, NULL);
|
|
|
|
while ((mm = TAILQ_FIRST(&mp->mp_msglist)) != NULL)
|
2002-12-17 21:42:54 +03:00
|
|
|
mach_message_put_exclocked(mm);
|
2002-12-15 03:40:24 +03:00
|
|
|
lockmgr(&mp->mp_msglock, LK_RELEASE, NULL);
|
|
|
|
lockmgr(&mp->mp_msglock, LK_DRAIN, NULL);
|
|
|
|
|
|
|
|
pool_put(&mach_port_pool, mp);
|
|
|
|
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
struct mach_right *
|
2002-12-31 18:47:37 +03:00
|
|
|
mach_right_get(mp, p, type, hint)
|
2002-12-15 03:40:24 +03:00
|
|
|
struct mach_port *mp;
|
|
|
|
struct proc *p;
|
|
|
|
int type;
|
2002-12-31 18:47:37 +03:00
|
|
|
mach_port_t hint;
|
2002-12-15 03:40:24 +03:00
|
|
|
{
|
|
|
|
struct mach_right *mr;
|
|
|
|
struct mach_emuldata *med;
|
2002-12-27 12:59:24 +03:00
|
|
|
int rights;
|
2002-12-26 14:41:46 +03:00
|
|
|
|
2003-01-02 15:46:06 +03:00
|
|
|
#ifdef DEBUG_MACH
|
|
|
|
if (type == 0)
|
|
|
|
uprintf("mach_right_get: right = 0\n");
|
|
|
|
#endif
|
2002-12-20 01:23:06 +03:00
|
|
|
med = (struct mach_emuldata *)p->p_emuldata;
|
|
|
|
|
|
|
|
/* Send and receive right must return an existing right */
|
2002-12-27 12:59:24 +03:00
|
|
|
rights = (MACH_PORT_TYPE_SEND | MACH_PORT_TYPE_RECEIVE);
|
|
|
|
if (type & rights) {
|
2003-01-03 16:40:04 +03:00
|
|
|
lockmgr(&med->med_rightlock, LK_SHARED, NULL);
|
2002-12-27 12:59:24 +03:00
|
|
|
LIST_FOREACH(mr, &med->med_right, mr_list) {
|
|
|
|
if ((mr->mr_port == mp) && (mr->mr_type & rights))
|
2002-12-20 01:23:06 +03:00
|
|
|
break;
|
2002-12-27 12:59:24 +03:00
|
|
|
}
|
2003-01-03 16:40:04 +03:00
|
|
|
lockmgr(&med->med_rightlock, LK_RELEASE, NULL);
|
2002-12-20 01:23:06 +03:00
|
|
|
|
|
|
|
if (mr != NULL) {
|
2002-12-27 12:59:24 +03:00
|
|
|
mr->mr_type |= type;
|
2003-01-03 16:40:04 +03:00
|
|
|
if (type & MACH_PORT_TYPE_SEND)
|
|
|
|
mr->mr_refcount++;
|
2002-12-30 15:46:19 +03:00
|
|
|
goto rcvck;
|
2002-12-20 01:23:06 +03:00
|
|
|
}
|
|
|
|
}
|
2002-12-31 18:47:37 +03:00
|
|
|
|
2002-12-15 03:40:24 +03:00
|
|
|
mr = pool_get(&mach_right_pool, M_WAITOK);
|
|
|
|
|
|
|
|
mr->mr_port = mp;
|
|
|
|
mr->mr_p = p;
|
|
|
|
mr->mr_type = type;
|
2002-12-30 15:41:52 +03:00
|
|
|
mr->mr_sethead = mr;
|
2002-12-20 01:23:06 +03:00
|
|
|
mr->mr_refcount = 1;
|
2002-12-27 12:59:24 +03:00
|
|
|
|
2002-12-30 21:44:33 +03:00
|
|
|
LIST_INIT(&mr->mr_set);
|
2002-12-15 03:40:24 +03:00
|
|
|
|
2002-12-20 01:23:06 +03:00
|
|
|
if (mp != NULL)
|
|
|
|
mp->mp_refcount++;
|
2002-12-15 03:40:24 +03:00
|
|
|
|
2003-01-02 15:46:06 +03:00
|
|
|
/* Insert the right in the right lists */
|
2002-12-27 22:57:47 +03:00
|
|
|
if (type & MACH_PORT_TYPE_ALL_RIGHTS) {
|
2003-01-03 16:40:04 +03:00
|
|
|
lockmgr(&med->med_rightlock, LK_EXCLUSIVE, NULL);
|
2003-01-02 15:46:06 +03:00
|
|
|
mr->mr_name = mach_right_newname(p, hint);
|
2003-01-03 16:40:04 +03:00
|
|
|
#ifdef DEBUG_MACH_RIGHT
|
|
|
|
printf("mach_right_get: insert right %x(%x)\n",
|
|
|
|
mr->mr_name, mr->mr_type);
|
|
|
|
#endif
|
2002-12-20 01:23:06 +03:00
|
|
|
LIST_INSERT_HEAD(&med->med_right, mr, mr_list);
|
2003-01-03 16:40:04 +03:00
|
|
|
lockmgr(&med->med_rightlock, LK_RELEASE, NULL);
|
2002-12-27 12:59:24 +03:00
|
|
|
}
|
2002-12-20 01:23:06 +03:00
|
|
|
|
2002-12-30 15:46:19 +03:00
|
|
|
rcvck:
|
2002-12-27 12:59:24 +03:00
|
|
|
if (type & MACH_PORT_TYPE_RECEIVE) {
|
2002-12-15 03:40:24 +03:00
|
|
|
/*
|
2002-12-18 01:48:33 +03:00
|
|
|
* Destroy the former receive right on this port, and
|
|
|
|
* register the new right.
|
2002-12-15 03:40:24 +03:00
|
|
|
*/
|
2002-12-18 01:48:33 +03:00
|
|
|
if (mr->mr_port->mp_recv != NULL)
|
2003-01-02 15:46:06 +03:00
|
|
|
mach_right_put(mr->mr_port->mp_recv,
|
|
|
|
MACH_PORT_TYPE_RECEIVE);
|
2002-12-18 01:48:33 +03:00
|
|
|
mr->mr_port->mp_recv = mr;
|
2002-12-15 03:40:24 +03:00
|
|
|
}
|
|
|
|
return mr;
|
|
|
|
}
|
|
|
|
|
2002-12-17 21:42:54 +03:00
|
|
|
void
|
2003-01-02 15:46:06 +03:00
|
|
|
mach_right_put(mr, right)
|
2002-12-15 03:40:24 +03:00
|
|
|
struct mach_right *mr;
|
2003-01-02 15:46:06 +03:00
|
|
|
int right;
|
2002-12-17 21:42:54 +03:00
|
|
|
{
|
2003-01-03 16:40:04 +03:00
|
|
|
struct mach_emuldata *med = mr->mr_p->p_emuldata;
|
|
|
|
|
|
|
|
lockmgr(&med->med_rightlock, LK_EXCLUSIVE, NULL);
|
2003-01-02 15:46:06 +03:00
|
|
|
mach_right_put_exclocked(mr, right);
|
2003-01-03 16:40:04 +03:00
|
|
|
lockmgr(&med->med_rightlock, LK_RELEASE, NULL);
|
2002-12-17 21:42:54 +03:00
|
|
|
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
2003-01-02 15:46:06 +03:00
|
|
|
mach_right_put_shlocked(mr, right)
|
2002-12-17 21:42:54 +03:00
|
|
|
struct mach_right *mr;
|
2003-01-02 15:46:06 +03:00
|
|
|
int right;
|
2002-12-17 21:42:54 +03:00
|
|
|
{
|
2003-01-03 16:40:04 +03:00
|
|
|
struct mach_emuldata *med = mr->mr_p->p_emuldata;
|
|
|
|
|
|
|
|
lockmgr(&med->med_rightlock, LK_UPGRADE, NULL);
|
2003-01-02 15:46:06 +03:00
|
|
|
mach_right_put_exclocked(mr, right);
|
2003-01-03 16:40:04 +03:00
|
|
|
lockmgr(&med->med_rightlock, LK_DOWNGRADE, NULL);
|
2002-12-17 21:42:54 +03:00
|
|
|
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
2003-01-02 15:46:06 +03:00
|
|
|
mach_right_put_exclocked(mr, right)
|
2002-12-17 21:42:54 +03:00
|
|
|
struct mach_right *mr;
|
2003-01-02 15:46:06 +03:00
|
|
|
int right;
|
2002-12-15 03:40:24 +03:00
|
|
|
{
|
2002-12-20 01:23:06 +03:00
|
|
|
struct mach_right *cmr;
|
2003-01-03 16:40:04 +03:00
|
|
|
struct mach_emuldata *med;
|
|
|
|
int lright;
|
|
|
|
int kill_right;
|
|
|
|
|
|
|
|
med = mr->mr_p->p_emuldata;
|
|
|
|
|
|
|
|
#ifdef DEBUG_MACH_RIGHT
|
|
|
|
printf("mach_right_put: mr = %p\n", mr);
|
|
|
|
printf("right %x(%x) refcount %d, deallocate %x\n",
|
|
|
|
mr->mr_name, mr->mr_type, mr->mr_refcount, right);
|
2003-01-02 15:46:06 +03:00
|
|
|
if ((mr->mr_type & right) == 0)
|
2003-01-03 16:40:04 +03:00
|
|
|
printf("mach_right_put: dropping nonexistant right %x on %x\n",
|
2003-01-02 15:46:06 +03:00
|
|
|
right, mr->mr_name);
|
2003-01-03 16:40:04 +03:00
|
|
|
LIST_FOREACH(cmr, &med->med_right, mr_list)
|
|
|
|
if (cmr == mr)
|
|
|
|
break;
|
|
|
|
if (cmr == NULL) {
|
|
|
|
printf("mach_right_put: dropping already dropped right %x\n",
|
|
|
|
mr->mr_name);
|
|
|
|
return;
|
|
|
|
}
|
2003-01-02 15:46:06 +03:00
|
|
|
#endif
|
2003-01-03 16:40:04 +03:00
|
|
|
kill_right = 0;
|
|
|
|
|
|
|
|
/* When receive right is deallocated, the port should die */
|
|
|
|
lright = (right & MACH_PORT_TYPE_RECEIVE);
|
|
|
|
if (mr->mr_type & lright) {
|
|
|
|
if (mr->mr_refcount <= 0) {
|
|
|
|
mr->mr_type &= ~MACH_PORT_TYPE_RECEIVE;
|
|
|
|
kill_right = 1;
|
|
|
|
} else {
|
|
|
|
mr->mr_type &= ~MACH_PORT_TYPE_RECEIVE;
|
|
|
|
mr->mr_type |= MACH_PORT_TYPE_DEAD_NAME;
|
|
|
|
}
|
|
|
|
if (mr->mr_port != NULL) {
|
|
|
|
mr->mr_port->mp_refcount--;
|
|
|
|
if (mr->mr_port->mp_refcount <= 0)
|
|
|
|
mach_port_put(mr->mr_port);
|
|
|
|
mr->mr_port = NULL;
|
|
|
|
}
|
|
|
|
}
|
2002-12-20 01:23:06 +03:00
|
|
|
|
2003-01-03 16:40:04 +03:00
|
|
|
/* send, send_once and dead_name */
|
|
|
|
lright = (right & MACH_PORT_TYPE_REF_RIGHTS);
|
|
|
|
if (mr->mr_type & lright) {
|
|
|
|
mr->mr_refcount--;
|
|
|
|
if (mr->mr_refcount <= 0) {
|
|
|
|
mr->mr_type &= ~MACH_PORT_TYPE_REF_RIGHTS;
|
|
|
|
if ((mr->mr_type & MACH_PORT_TYPE_RECEIVE) == 0)
|
|
|
|
kill_right = 1;
|
|
|
|
}
|
2003-01-02 15:46:06 +03:00
|
|
|
}
|
2002-12-15 03:40:24 +03:00
|
|
|
|
2003-01-03 16:40:04 +03:00
|
|
|
lright = (right & MACH_PORT_TYPE_PORT_SET);
|
|
|
|
if ((mr->mr_type & lright) || (kill_right == 1)) {
|
|
|
|
while ((cmr = LIST_FIRST(&mr->mr_set)) != NULL) {
|
2003-01-02 15:46:06 +03:00
|
|
|
LIST_REMOVE(cmr, mr_setlist);
|
|
|
|
cmr->mr_sethead = cmr;
|
|
|
|
}
|
2003-01-03 16:40:04 +03:00
|
|
|
mr->mr_type &= ~MACH_PORT_TYPE_PORT_SET;
|
|
|
|
if ((mr->mr_type & MACH_PORT_TYPE_RECEIVE) == 0)
|
|
|
|
kill_right = 1;
|
2002-12-27 12:59:24 +03:00
|
|
|
}
|
2002-12-15 03:40:24 +03:00
|
|
|
|
2003-01-03 16:40:04 +03:00
|
|
|
/* Should we kill it? */
|
|
|
|
if (kill_right == 1) {
|
|
|
|
#ifdef DEBUG_MACH_RIGHT
|
|
|
|
printf("mach_right_put: kill name %x\n", mr->mr_name);
|
|
|
|
#endif
|
|
|
|
LIST_REMOVE(mr, mr_list);
|
|
|
|
pool_put(&mach_right_pool, mr);
|
2002-12-20 01:23:06 +03:00
|
|
|
}
|
2002-12-15 03:40:24 +03:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
2002-12-27 12:59:24 +03:00
|
|
|
* Check that a process do have a given right
|
2002-12-15 03:40:24 +03:00
|
|
|
*/
|
2002-12-31 18:47:37 +03:00
|
|
|
struct mach_right *
|
|
|
|
mach_right_check(mn, p, type)
|
|
|
|
mach_port_t mn;
|
2002-12-15 03:40:24 +03:00
|
|
|
struct proc *p;
|
2002-12-20 01:23:06 +03:00
|
|
|
int type;
|
2002-12-15 03:40:24 +03:00
|
|
|
{
|
|
|
|
struct mach_right *cmr;
|
|
|
|
struct mach_emuldata *med;
|
|
|
|
|
2003-01-02 15:46:06 +03:00
|
|
|
if ((mn == 0) || (mn == -1) || (p == NULL))
|
|
|
|
return NULL;
|
|
|
|
|
2002-12-15 03:40:24 +03:00
|
|
|
med = (struct mach_emuldata *)p->p_emuldata;
|
|
|
|
|
2003-01-03 16:40:04 +03:00
|
|
|
lockmgr(&med->med_rightlock, LK_SHARED, NULL);
|
2002-12-17 21:42:54 +03:00
|
|
|
|
2002-12-30 21:44:33 +03:00
|
|
|
#ifdef DEBUG_MACH_RIGHT
|
2002-12-31 18:47:37 +03:00
|
|
|
printf("mach_right_check: type = %x, mn = %x\n", type, mn);
|
2002-12-30 21:44:33 +03:00
|
|
|
#endif
|
2002-12-20 01:23:06 +03:00
|
|
|
LIST_FOREACH(cmr, &med->med_right, mr_list) {
|
2002-12-30 21:44:33 +03:00
|
|
|
#ifdef DEBUG_MACH_RIGHT
|
2002-12-31 18:47:37 +03:00
|
|
|
printf("cmr = %p, cmr->mr_name = %x, cmr->mr_type = %x\n",
|
|
|
|
cmr, cmr->mr_name, cmr->mr_type);
|
2002-12-30 21:44:33 +03:00
|
|
|
#endif
|
2002-12-31 18:47:37 +03:00
|
|
|
if (cmr->mr_name != mn)
|
2002-12-20 01:23:06 +03:00
|
|
|
continue;
|
2002-12-27 12:59:24 +03:00
|
|
|
if (type & cmr->mr_type)
|
|
|
|
break;
|
2002-12-15 03:40:24 +03:00
|
|
|
}
|
|
|
|
|
2003-01-03 16:40:04 +03:00
|
|
|
lockmgr(&med->med_rightlock, LK_RELEASE, NULL);
|
2002-12-17 21:42:54 +03:00
|
|
|
|
2002-12-31 18:47:37 +03:00
|
|
|
return cmr;
|
2002-12-27 12:59:24 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2002-12-31 18:47:37 +03:00
|
|
|
/*
|
|
|
|
* Find an usnused port name in a given process.
|
2003-01-02 15:46:06 +03:00
|
|
|
* Right lists should be locked.
|
2002-12-31 18:47:37 +03:00
|
|
|
*/
|
|
|
|
mach_port_t
|
|
|
|
mach_right_newname(p, hint)
|
|
|
|
struct proc *p;
|
|
|
|
mach_port_t hint;
|
|
|
|
{
|
|
|
|
struct mach_emuldata *med;
|
|
|
|
struct mach_right *mr;
|
|
|
|
mach_port_t newname = -1;
|
|
|
|
|
|
|
|
med = p->p_emuldata;
|
|
|
|
|
|
|
|
if (hint == 0)
|
|
|
|
hint = med->med_nextright;
|
|
|
|
|
|
|
|
while (newname == -1) {
|
|
|
|
LIST_FOREACH(mr, &med->med_right, mr_list)
|
|
|
|
if (mr->mr_name == hint)
|
|
|
|
break;
|
|
|
|
if (mr == NULL)
|
|
|
|
newname = hint;
|
|
|
|
hint++;
|
|
|
|
}
|
|
|
|
|
2003-01-02 15:46:06 +03:00
|
|
|
med->med_nextright = hint;
|
2002-12-31 18:47:37 +03:00
|
|
|
|
|
|
|
return newname;
|
2002-12-15 03:40:24 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
#ifdef DEBUG_MACH
|
|
|
|
void
|
2002-12-30 21:44:33 +03:00
|
|
|
mach_debug_port(void)
|
2002-12-15 03:40:24 +03:00
|
|
|
{
|
2002-12-30 21:44:33 +03:00
|
|
|
struct proc *p;
|
2002-12-15 03:40:24 +03:00
|
|
|
struct mach_emuldata *med;
|
|
|
|
struct mach_right *mr;
|
2002-12-30 21:44:33 +03:00
|
|
|
struct mach_right *mrs;
|
|
|
|
|
|
|
|
LIST_FOREACH(p, &allproc, p_list) {
|
|
|
|
if ((p->p_emul != &emul_mach) &&
|
|
|
|
#ifdef COMPAT_DARWIN
|
|
|
|
(p->p_emul != &emul_darwin) &&
|
|
|
|
#endif
|
|
|
|
1)
|
2002-12-20 01:23:06 +03:00
|
|
|
continue;
|
2002-12-30 21:44:33 +03:00
|
|
|
|
|
|
|
med = p->p_emuldata;
|
|
|
|
LIST_FOREACH(mr, &med->med_right, mr_list) {
|
2002-12-30 22:32:15 +03:00
|
|
|
if ((mr->mr_type & MACH_PORT_TYPE_PORT_SET) == 0) {
|
2002-12-30 21:44:33 +03:00
|
|
|
printf("pid %d: %p(%x)=>%p",
|
|
|
|
p->p_pid, mr, mr->mr_type, mr->mr_port);
|
|
|
|
if (mr->mr_port != NULL)
|
|
|
|
printf("[%p]\n",
|
|
|
|
mr->mr_port->mp_recv->mr_sethead);
|
|
|
|
else
|
|
|
|
printf("[NULL]\n");
|
|
|
|
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Port set... */
|
|
|
|
printf("pid %d: set %p(%x) ",
|
|
|
|
p->p_pid, mr, mr->mr_type);
|
|
|
|
LIST_FOREACH(mrs, &mr->mr_set, mr_setlist) {
|
|
|
|
printf("%p(%x)=>%p",
|
|
|
|
mrs, mrs->mr_type, mrs->mr_port);
|
|
|
|
if (mrs->mr_port != NULL)
|
|
|
|
printf("[%p]",
|
|
|
|
mrs->mr_port->mp_recv->mr_sethead);
|
|
|
|
else
|
|
|
|
printf("[NULL]");
|
|
|
|
|
|
|
|
printf(" ");
|
|
|
|
}
|
|
|
|
printf("\n");
|
|
|
|
}
|
2002-12-15 03:40:24 +03:00
|
|
|
}
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2002-12-17 21:42:54 +03:00
|
|
|
#endif /* DEBUG_MACH */
|