blob: 1bafa5e487ab8abe2b555dee7ad58fa419140747 [file] [log] [blame]
Wichert Akkerman76baf7c1999-02-19 00:21:36 +00001/*
2 * Copyright (c) 1993, 1994, 1995 Rick Sladkey <jrs@world.std.com>
3 * All rights reserved.
4 *
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions
7 * are met:
8 * 1. Redistributions of source code must retain the above copyright
9 * notice, this list of conditions and the following disclaimer.
10 * 2. Redistributions in binary form must reproduce the above copyright
11 * notice, this list of conditions and the following disclaimer in the
12 * documentation and/or other materials provided with the distribution.
13 * 3. The name of the author may not be used to endorse or promote products
14 * derived from this software without specific prior written permission.
15 *
16 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
17 * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
18 * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
19 * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
20 * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
21 * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
22 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
23 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
24 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
25 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
26 *
27 * $Id$
28 */
29
30#include "defs.h"
31
32#ifdef SVR4
33
34static struct xlat proc_status_flags[] = {
35 { PR_STOPPED, "PR_STOPPED" },
36 { PR_ISTOP, "PR_ISTOP" },
37 { PR_DSTOP, "PR_DSTOP" },
38 { PR_ASLEEP, "PR_ASLEEP" },
39 { PR_FORK, "PR_FORK" },
40 { PR_RLC, "PR_RLC" },
41 { PR_PTRACE, "PR_PTRACE" },
42 { PR_PCINVAL, "PR_PCINVAL" },
43 { PR_ISSYS, "PR_ISSYS" },
44#ifdef PR_STEP
45 { PR_STEP, "PR_STEP" },
46#endif
47#ifdef PR_KLC
48 { PR_KLC, "PR_KLC" },
49#endif
50#ifdef PR_ASYNC
51 { PR_ASYNC, "PR_ASYNC" },
52#endif
53#ifdef PR_PCOMPAT
54 { PR_PCOMPAT, "PR_PCOMPAT" },
55#endif
56 { 0, NULL },
57};
58
59static struct xlat proc_status_why[] = {
60 { PR_REQUESTED, "PR_REQUESTED" },
61 { PR_SIGNALLED, "PR_SIGNALLED" },
62 { PR_SYSENTRY, "PR_SYSENTRY" },
63 { PR_SYSEXIT, "PR_SYSEXIT" },
64 { PR_JOBCONTROL,"PR_JOBCONTROL" },
65 { PR_FAULTED, "PR_FAULTED" },
66#ifdef PR_SUSPENDED
67 { PR_SUSPENDED, "PR_SUSPENDED" },
68#endif
69#ifdef PR_CHECKPOINT
70 { PR_CHECKPOINT,"PR_CHECKPOINT" },
71#endif
72 { 0, NULL },
73};
74
75static struct xlat proc_run_flags[] = {
76 { PRCSIG, "PRCSIG" },
77 { PRCFAULT, "PRCFAULT" },
78 { PRSTRACE, "PRSTRACE" },
79 { PRSHOLD, "PRSHOLD" },
80 { PRSFAULT, "PRSFAULT" },
81 { PRSVADDR, "PRSVADDR" },
82 { PRSTEP, "PRSTEP" },
83 { PRSABORT, "PRSABORT" },
84 { PRSTOP, "PRSTOP" },
85 { 0, NULL },
86};
87
Wichert Akkerman76baf7c1999-02-19 00:21:36 +000088int
89proc_ioctl(tcp, code, arg)
90struct tcb *tcp;
91int code, arg;
92{
93 int val;
94 prstatus_t status;
95 prrun_t run;
96
97 if (entering(tcp))
98 return 0;
99
100 switch (code) {
101 case PIOCSTATUS:
102 case PIOCSTOP:
103 case PIOCWSTOP:
104 if (arg == 0)
105 tprintf(", NULL");
106 else if (syserror(tcp))
107 tprintf(", %#x", arg);
108 else if (umove(tcp, arg, &status) < 0)
109 tprintf(", {...}");
110 else {
111 tprintf(", {pr_flags=");
112 if (!printflags(proc_status_flags, status.pr_flags))
113 tprintf("0");
114 if (status.pr_why) {
115 tprintf(", pr_why=");
116 printxval(proc_status_why, status.pr_why,
117 "PR_???");
118 }
119 switch (status.pr_why) {
120 case PR_SIGNALLED:
121 case PR_JOBCONTROL:
122 tprintf(", pr_what=");
123 printsignal(status.pr_what);
124 break;
125 case PR_FAULTED:
126 tprintf(", pr_what=%d", status.pr_what);
127 break;
128 case PR_SYSENTRY:
129 case PR_SYSEXIT:
130 tprintf(", pr_what=SYS_%s",
131 sysent[status.pr_what].sys_name);
132 break;
133 }
134 tprintf(", ...}");
135 }
136 return 1;
137 case PIOCRUN:
138 if (arg == 0)
139 tprintf(", NULL");
140 else if (umove(tcp, arg, &run) < 0)
141 tprintf(", {...}");
142 else {
143 tprintf(", {pr_flags=");
144 if (!printflags(proc_run_flags, run.pr_flags))
145 tprintf("0");
146 tprintf(", ...}");
147 }
148 return 1;
149#ifdef PIOCSET
150 case PIOCSET:
151 case PIOCRESET:
152 if (umove(tcp, arg, &val) < 0)
153 tprintf(", [?]");
154 else {
155 tprintf(", [");
156 if (!printflags(proc_status_flags, val))
157 tprintf("0");
158 tprintf("]");
159 }
160 return 1;
161#endif /* PIOCSET */
162 case PIOCKILL:
163 case PIOCUNKILL:
164 /* takes a pointer to a signal */
165 if (umove(tcp, arg, &val) < 0)
166 tprintf(", [?]");
167 else {
168 tprintf(", [");
169 printsignal(val);
170 tprintf("]");
171 }
172 return 1;
173 case PIOCSFORK:
174 case PIOCRFORK:
175 case PIOCSRLC:
176 case PIOCRRLC:
177 /* doesn't take an arg */
178 return 1;
179 default:
180 /* ad naseum */
181 return 0;
182 }
183}
184
185#endif /* SVR4 */
Wichert Akkerman5daa0281999-03-15 19:49:42 +0000186