mach_port_get_attributes (incomplete and untested)

This commit is contained in:
manu 2003-11-03 22:17:42 +00:00
parent 90b3ec4640
commit 10d03389ac
3 changed files with 116 additions and 10 deletions

View File

@ -1,4 +1,4 @@
/* $NetBSD: mach_namemap.c,v 1.32 2003/09/06 23:52:24 manu Exp $ */
/* $NetBSD: mach_namemap.c,v 1.33 2003/11/03 22:17:42 manu Exp $ */
/*-
* Copyright (c) 2002-2003 The NetBSD Foundation, Inc.
@ -37,7 +37,7 @@
*/
#include <sys/cdefs.h>
__KERNEL_RCSID(0, "$NetBSD: mach_namemap.c,v 1.32 2003/09/06 23:52:24 manu Exp $");
__KERNEL_RCSID(0, "$NetBSD: mach_namemap.c,v 1.33 2003/11/03 22:17:42 manu Exp $");
#include <sys/types.h>
#include <sys/param.h>
@ -118,6 +118,7 @@ struct mach_subsystem_namemap mach_namemap[] = {
{ 3212, mach_port_move_member, "port_move_member" },
{ 3213, mach_port_request_notification, "port_request_notification" },
{ 3214, mach_port_insert_right, "port_insert_right" },
{ 3217, mach_port_get_attributes, "port_get_attribute" },
{ 3218, mach_port_set_attributes, "port_set_attributes" },
{ 3226, mach_port_insert_member, "port_insert_member" },
{ 3402, mach_task_threads, "task_threads" },

View File

@ -1,4 +1,4 @@
/* $NetBSD: mach_port.c,v 1.39 2003/09/11 23:18:10 manu Exp $ */
/* $NetBSD: mach_port.c,v 1.40 2003/11/03 22:17:42 manu Exp $ */
/*-
* Copyright (c) 2002-2003 The NetBSD Foundation, Inc.
@ -39,7 +39,7 @@
#include "opt_compat_darwin.h"
#include <sys/cdefs.h>
__KERNEL_RCSID(0, "$NetBSD: mach_port.c,v 1.39 2003/09/11 23:18:10 manu Exp $");
__KERNEL_RCSID(0, "$NetBSD: mach_port.c,v 1.40 2003/11/03 22:17:42 manu Exp $");
#include <sys/types.h>
#include <sys/param.h>
@ -342,7 +342,7 @@ mach_port_set_attributes(args)
case MACH_PORT_DNREQUESTS_SIZE:
break;
default:
uprintf("mach_port_get_attributes: unknown flavor %d\n",
uprintf("mach_port_set_attributes: unknown flavor %d\n",
req->req_flavor);
break;
}
@ -358,6 +358,86 @@ mach_port_set_attributes(args)
return 0;
}
int
mach_port_get_attributes(args)
struct mach_trap_args *args;
{
mach_port_get_attributes_request_t *req = args->smsg;
mach_port_get_attributes_reply_t *rep = args->rmsg;
size_t *msglen = args->rsize;
struct lwp *l = args->l;
mach_port_t mn;
struct mach_right *mr;
mn = req->req_msgh.msgh_remote_port;
if ((mr = mach_right_check(mn, l, MACH_PORT_TYPE_ALL_RIGHTS)) == NULL)
return mach_msg_error(args, EPERM);
switch (req->req_flavor) {
case MACH_PORT_LIMITS_INFO: {
struct mach_port_limits *mpl;
if (req->req_count < sizeof(*mpl))
return mach_msg_error(args, EINVAL);
mpl = (struct mach_port_limits *)&rep->rep_info[0];
mpl->mpl_qlimit = MACH_PORT_QLIMIT_DEFAULT; /* XXX fake limit */
rep->rep_count = sizeof(*mpl);
break;
}
case MACH_PORT_RECEIVE_STATUS: {
struct mach_port_status *mps;
struct mach_port *mp;
if (req->req_count < sizeof(*mps))
return mach_msg_error(args, EINVAL);
mps = (struct mach_port_status *)&rep->rep_info[0];
memset(mps, 0, sizeof(*mps));
if (mr->mr_sethead != NULL)
mps->mps_pset = mr->mr_sethead->mr_name;
mps->mps_seqno = 0; /* XXX */
mps->mps_mscount = mp->mp_refcount; /* XXX */
mps->mps_qlimit = MACH_PORT_QLIMIT_DEFAULT; /* XXX fake limit */
if ((mp = mr->mr_port) != NULL)
mps->mps_msgcount = mp->mp_count;
mps->mps_sorights = 0; /* XXX */
mps->mps_srights = 0; /* XXX */
if (mr->mr_notify_destroyed != NULL)
mps->mps_pdrequest = 1;
if (mr->mr_notify_no_senders != NULL)
mps->mps_nsrequest = 1;
mps->mps_flags = 0; /* XXX */
rep->rep_count = sizeof(*mps);
break;
}
default:
printf("mach_port_get_attributes: unknwo flavor %d\n",
req->req_flavor);
return mach_msg_error(args, EINVAL);
break;
};
*msglen = sizeof(*rep) - 10 + rep->rep_count;
rep->rep_msgh.msgh_bits =
MACH_MSGH_REPLY_LOCAL_BITS(MACH_MSG_TYPE_MOVE_SEND_ONCE);
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_info[rep->rep_count + 1] = 8;
return 0;
}
/* XXX insert a recv right into a port set without removing it from another */
int
mach_port_insert_member(args)

View File

@ -1,4 +1,4 @@
/* $NetBSD: mach_port.h,v 1.27 2003/11/03 20:58:18 manu Exp $ */
/* $NetBSD: mach_port.h,v 1.28 2003/11/03 22:17:42 manu Exp $ */
/*-
* Copyright (c) 2002-2003 The NetBSD Foundation, Inc.
@ -63,7 +63,6 @@
#define MACH_PORT_TYPE_REF_RIGHTS \
(MACH_PORT_TYPE_SEND | MACH_PORT_TYPE_SEND_ONCE | MACH_PORT_TYPE_DEAD_NAME)
/* port_deallocate */
typedef struct {
@ -128,9 +127,12 @@ typedef struct {
mach_msg_trailer_t rep_trailer;
} mach_port_type_reply_t;
/* port_get_attributes */
/* port_set_attributes */
#define MACH_PORT_LIMITS_INFO 1
#define MACH_PORT_RECEIVE_STATUS 2
#define MACH_PORT_DNREQUESTS_SIZE 3
typedef struct mach_port_status {
mach_port_name_t mps_pset;
mach_port_seqno_t mps_seqno;
@ -143,11 +145,10 @@ typedef struct mach_port_status {
mach_boolean_t mps_nsrequest;
unsigned int mps_flags;
} mach_port_status_t;
#define MACH_PORT_RECEIVE_STATUS 2
typedef struct mach_port_limits {
mach_port_msgcount_t mpl_qlimit;
} mach_port_limits_t;
#define MACH_PORT_DNREQUESTS_SIZE 3
typedef struct {
mach_msg_header_t req_msgh;
@ -165,6 +166,28 @@ typedef struct {
mach_msg_trailer_t rep_trailer;
} mach_port_set_attributes_reply_t;
/* port_get_attributes */
#define MACH_PORT_QLIMIT_DEFAULT ((mach_port_msgcount_t) 5)
#define MACH_PORT_QLIMIT_MAX ((mach_port_msgcount_t) 16)
typedef struct {
mach_msg_header_t req_msgh;
mach_ndr_record_t req_ndr;
mach_port_name_t req_name;
mach_port_flavor_t req_flavor;
mach_msg_type_number_t req_count;
} mach_port_get_attributes_request_t;
typedef struct {
mach_msg_header_t rep_msgh;
mach_ndr_record_t rep_ndr;
mach_kern_return_t rep_retval;
mach_msg_type_number_t rep_count;
mach_integer_t rep_info[10];
mach_msg_trailer_t rep_trailer;
} mach_port_get_attributes_reply_t;
/* port_insert_member */
typedef struct {
@ -231,6 +254,7 @@ typedef struct {
mach_msg_trailer_t rep_trailer;
} mach_port_request_notification_reply_t;
int mach_port_deallocate(struct mach_trap_args *);
int mach_port_allocate(struct mach_trap_args *);
int mach_port_insert_right(struct mach_trap_args *);
@ -240,6 +264,7 @@ int mach_port_insert_member(struct mach_trap_args *);
int mach_port_move_member(struct mach_trap_args *);
int mach_port_destroy(struct mach_trap_args *);
int mach_port_request_notification(struct mach_trap_args *);
int mach_port_get_attributes(struct mach_trap_args *);
extern struct mach_port *mach_clock_port;
extern struct mach_port *mach_io_master_port;