1 /*
2 * CDDL HEADER START
3 *
4 * The contents of this file are subject to the terms of the
5 * Common Development and Distribution License (the "License").
6 * You may not use this file except in compliance with the License.
7 *
8 * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
9 * or http://www.opensolaris.org/os/licensing.
10 * See the License for the specific language governing permissions
11 * and limitations under the License.
12 *
13 * When distributing Covered Code, include this CDDL HEADER in each
14 * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
15 * If applicable, add the following below this CDDL HEADER, with the
16 * fields enclosed by brackets "[]" replaced with your own identifying
17 * information: Portions Copyright [yyyy] [name of copyright owner]
18 *
19 * CDDL HEADER END
20 */
21
22 /*
23 * Copyright 2008 Sun Microsystems, Inc. All rights reserved.
24 * Use is subject to license terms.
25 */
26
27 #pragma ident "%Z%%M% %I% %E% SMI"
28
29 #include <stdlib.h>
30 #include <unistd.h>
31 #include <errno.h>
32 #include <door.h>
33 #include "libproc.h"
34
35 /*
36 * door() system calls -- executed by subject process
37 */
38
39 int
pr_door_info(struct ps_prochandle * Pr,int did,door_info_t * di)40 pr_door_info(struct ps_prochandle *Pr, int did, door_info_t *di)
41 {
42 sysret_t rval; /* return value from door_info() */
43 argdes_t argd[6]; /* arg descriptors for door_info() */
44 argdes_t *adp = &argd[0]; /* first argument */
45 int error;
46
47 if (Pr == NULL) /* no subject process */
48 return (door_info(did, di));
49
50 adp->arg_value = did;
51 adp->arg_object = NULL;
52 adp->arg_type = AT_BYVAL;
53 adp->arg_inout = AI_INPUT;
54 adp->arg_size = 0;
55 adp++; /* move to door_info_t argument */
56
57 adp->arg_value = 0;
58 adp->arg_object = di;
59 adp->arg_type = AT_BYREF;
60 adp->arg_inout = AI_OUTPUT;
61 adp->arg_size = sizeof (door_info_t);
62 adp++; /* move to unused argument */
63
64 adp->arg_value = 0;
65 adp->arg_object = NULL;
66 adp->arg_type = AT_BYVAL;
67 adp->arg_inout = AI_INPUT;
68 adp->arg_size = 0;
69 adp++; /* move to unused argument */
70
71 adp->arg_value = 0;
72 adp->arg_object = NULL;
73 adp->arg_type = AT_BYVAL;
74 adp->arg_inout = AI_INPUT;
75 adp->arg_size = 0;
76 adp++; /* move to unused argument */
77
78 adp->arg_value = 0;
79 adp->arg_object = NULL;
80 adp->arg_type = AT_BYVAL;
81 adp->arg_inout = AI_INPUT;
82 adp->arg_size = 0;
83 adp++; /* move to subcode argument */
84
85 adp->arg_value = DOOR_INFO;
86 adp->arg_object = NULL;
87 adp->arg_type = AT_BYVAL;
88 adp->arg_inout = AI_INPUT;
89 adp->arg_size = 0;
90
91 error = Psyscall(Pr, &rval, SYS_door, 6, &argd[0]);
92
93 if (error) {
94 errno = (error < 0)? ENOSYS : error;
95 return (-1);
96 }
97 return (0);
98 }
99