xref: /titanic_52/usr/src/cmd/truss/systable.c (revision 67e3a03ed4a2813074d36330f062ed6e593a4937)
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 2007 Sun Microsystems, Inc.  All rights reserved.
24  * Use is subject to license terms.
25  */
26 
27 /*	Copyright (c) 1984, 1986, 1987, 1988, 1989 AT&T	*/
28 /*	  All Rights Reserved  	*/
29 
30 #pragma ident	"%Z%%M%	%I%	%E% SMI"
31 
32 #include <stdio.h>
33 #include <stdlib.h>
34 #include <fcntl.h>
35 #include <unistd.h>
36 #include <string.h>
37 #include <signal.h>
38 #include <sys/types.h>
39 #include <libproc.h>
40 #include <sys/aio.h>
41 #include <sys/port_impl.h>
42 #include "ramdata.h"
43 #include "systable.h"
44 #include "print.h"
45 #include "proto.h"
46 
47 /*
48  * Tables of information about system calls - read-only data.
49  */
50 
51 const	char *const	errcode[] = {	/* error code names */
52 	NULL,		/*  0 */
53 	"EPERM",	/*  1 */
54 	"ENOENT",	/*  2 */
55 	"ESRCH",	/*  3 */
56 	"EINTR",	/*  4 */
57 	"EIO",		/*  5 */
58 	"ENXIO",	/*  6 */
59 	"E2BIG",	/*  7 */
60 	"ENOEXEC",	/*  8 */
61 	"EBADF",	/*  9 */
62 	"ECHILD",	/* 10 */
63 	"EAGAIN",	/* 11 */
64 	"ENOMEM",	/* 12 */
65 	"EACCES",	/* 13 */
66 	"EFAULT",	/* 14 */
67 	"ENOTBLK",	/* 15 */
68 	"EBUSY",	/* 16 */
69 	"EEXIST",	/* 17 */
70 	"EXDEV",	/* 18 */
71 	"ENODEV",	/* 19 */
72 	"ENOTDIR",	/* 20 */
73 	"EISDIR",	/* 21 */
74 	"EINVAL",	/* 22 */
75 	"ENFILE",	/* 23 */
76 	"EMFILE",	/* 24 */
77 	"ENOTTY",	/* 25 */
78 	"ETXTBSY",	/* 26 */
79 	"EFBIG",	/* 27 */
80 	"ENOSPC",	/* 28 */
81 	"ESPIPE",	/* 29 */
82 	"EROFS",	/* 30 */
83 	"EMLINK",	/* 31 */
84 	"EPIPE",	/* 32 */
85 	"EDOM",		/* 33 */
86 	"ERANGE",	/* 34 */
87 	"ENOMSG",	/* 35 */
88 	"EIDRM",	/* 36 */
89 	"ECHRNG",	/* 37 */
90 	"EL2NSYNC",	/* 38 */
91 	"EL3HLT",	/* 39 */
92 	"EL3RST",	/* 40 */
93 	"ELNRNG",	/* 41 */
94 	"EUNATCH",	/* 42 */
95 	"ENOCSI",	/* 43 */
96 	"EL2HLT",	/* 44 */
97 	"EDEADLK",	/* 45 */
98 	"ENOLCK",	/* 46 */
99 	"ECANCELED",	/* 47 */
100 	"ENOTSUP",	/* 48 */
101 	"EDQUOT",	/* 49 */
102 	"EBADE",	/* 50 */
103 	"EBADR",	/* 51 */
104 	"EXFULL",	/* 52 */
105 	"ENOANO",	/* 53 */
106 	"EBADRQC",	/* 54 */
107 	"EBADSLT",	/* 55 */
108 	"EDEADLOCK",	/* 56 */
109 	"EBFONT",	/* 57 */
110 	"EOWNERDEAD",	/* 58 */
111 	"ENOTRECOVERABLE",	/* 59 */
112 	"ENOSTR",	/* 60 */
113 	"ENODATA",	/* 61 */
114 	"ETIME",	/* 62 */
115 	"ENOSR",	/* 63 */
116 	"ENONET",	/* 64 */
117 	"ENOPKG",	/* 65 */
118 	"EREMOTE",	/* 66 */
119 	"ENOLINK",	/* 67 */
120 	"EADV",		/* 68 */
121 	"ESRMNT",	/* 69 */
122 	"ECOMM",	/* 70 */
123 	"EPROTO",	/* 71 */
124 	"ELOCKUNMAPPED",	/* 72 */
125 	"ENOTACTIVE",	/* 73 */
126 	"EMULTIHOP",	/* 74 */
127 	NULL,		/* 75 */
128 	NULL,		/* 76 */
129 	"EBADMSG",	/* 77 */
130 	"ENAMETOOLONG",	/* 78 */
131 	"EOVERFLOW",	/* 79 */
132 	"ENOTUNIQ",	/* 80 */
133 	"EBADFD",	/* 81 */
134 	"EREMCHG",	/* 82 */
135 	"ELIBACC",	/* 83 */
136 	"ELIBBAD",	/* 84 */
137 	"ELIBSCN",	/* 85 */
138 	"ELIBMAX",	/* 86 */
139 	"ELIBEXEC",	/* 87 */
140 	"EILSEQ",	/* 88 */
141 	"ENOSYS",	/* 89 */
142 	"ELOOP",	/* 90 */
143 	"ERESTART",	/* 91 */
144 	"ESTRPIPE",	/* 92 */
145 	"ENOTEMPTY",	/* 93 */
146 	"EUSERS",	/* 94 */
147 	"ENOTSOCK",	/* 95 */
148 	"EDESTADDRREQ",	/* 96 */
149 	"EMSGSIZE",	/* 97 */
150 	"EPROTOTYPE",	/* 98 */
151 	"ENOPROTOOPT",	/* 99 */
152 	NULL,		/* 100 */
153 	NULL,		/* 101 */
154 	NULL,		/* 102 */
155 	NULL,		/* 103 */
156 	NULL,		/* 104 */
157 	NULL,		/* 105 */
158 	NULL,		/* 106 */
159 	NULL,		/* 107 */
160 	NULL,		/* 108 */
161 	NULL,		/* 109 */
162 	NULL,		/* 110 */
163 	NULL,		/* 111 */
164 	NULL,		/* 112 */
165 	NULL,		/* 113 */
166 	NULL,		/* 114 */
167 	NULL,		/* 115 */
168 	NULL,		/* 116 */
169 	NULL,		/* 117 */
170 	NULL,		/* 118 */
171 	NULL,		/* 119 */
172 	"EPROTONOSUPPORT",	/* 120 */
173 	"ESOCKTNOSUPPORT",	/* 121 */
174 	"EOPNOTSUPP",	/* 122 */
175 	"EPFNOSUPPORT",	/* 123 */
176 	"EAFNOSUPPORT",	/* 124 */
177 	"EADDRINUSE",	/* 125 */
178 	"EADDRNOTAVAIL", /* 126 */
179 	"ENETDOWN",	/* 127 */
180 	"ENETUNREACH",	/* 128 */
181 	"ENETRESET",	/* 129 */
182 	"ECONNABORTED",	/* 130 */
183 	"ECONNRESET",	/* 131 */
184 	"ENOBUFS",	/* 132 */
185 	"EISCONN",	/* 133 */
186 	"ENOTCONN",	/* 134 */
187 	NULL,		/* 135 */
188 	NULL,		/* 136 */
189 	NULL,		/* 137 */
190 	NULL,		/* 138 */
191 	NULL,		/* 139 */
192 	NULL,		/* 140 */
193 	NULL,		/* 141 */
194 	NULL,		/* 142 */
195 	"ESHUTDOWN",	/* 143 */
196 	"ETOOMANYREFS",	/* 144 */
197 	"ETIMEDOUT",	/* 145 */
198 	"ECONNREFUSED",	/* 146 */
199 	"EHOSTDOWN",	/* 147 */
200 	"EHOSTUNREACH",	/* 148 */
201 	"EALREADY",	/* 149 */
202 	"EINPROGRESS",	/* 150 */
203 	"ESTALE"	/* 151 */
204 };
205 
206 #define	NERRCODE	(sizeof (errcode) / sizeof (char *))
207 
208 
209 const char *
210 errname(int err)	/* return the error code name (NULL if none) */
211 {
212 	const char *ename = NULL;
213 
214 	if (err >= 0 && err < NERRCODE)
215 		ename = errcode[err];
216 
217 	return (ename);
218 }
219 
220 
221 const struct systable systable[] = {
222 { NULL,		8, HEX, HEX, HEX, HEX, HEX, HEX, HEX, HEX, HEX, HEX},
223 {"_exit",	1, DEC, NOV, DEC},				/*   1 */
224 {"forkall",	0, DEC, NOV},					/*   2 */
225 {"read",	3, DEC, NOV, DEC, IOB, UNS},			/*   3 */
226 {"write",	3, DEC, NOV, DEC, IOB, UNS},			/*   4 */
227 {"open",	3, DEC, NOV, STG, OPN, OCT},			/*   5 */
228 {"close",	1, DEC, NOV, DEC},				/*   6 */
229 {"wait",	0, DEC, HHX},					/*   7 */
230 {"creat",	2, DEC, NOV, STG, OCT},				/*   8 */
231 {"link",	2, DEC, NOV, STG, STG},				/*   9 */
232 {"unlink",	1, DEC, NOV, STG},				/*  10 */
233 {"exec",	2, DEC, NOV, STG, DEC},				/*  11 */
234 {"chdir",	1, DEC, NOV, STG},				/*  12 */
235 {"time",	0, DEC, NOV},					/*  13 */
236 {"mknod",	3, DEC, NOV, STG, OCT, HEX},			/*  14 */
237 {"chmod",	2, DEC, NOV, STG, OCT},				/*  15 */
238 {"chown",	3, DEC, NOV, STG, DEC, DEC},			/*  16 */
239 {"brk",		1, DEC, NOV, HEX},				/*  17 */
240 {"stat",	2, DEC, NOV, STG, HEX},				/*  18 */
241 {"lseek",	3, DEC, NOV, DEC, DEX, WHN},			/*  19 */
242 {"getpid",	0, DEC, DEC},					/*  20 */
243 {"mount",	8, DEC, NOV, STG, STG, MTF, MFT, HEX, DEC, HEX, DEC},	/* 21 */
244 {"umount",	1, DEC, NOV, STG},				/*  22 */
245 {"setuid",	1, DEC, NOV, UNS},				/*  23 */
246 {"getuid",	0, UNS, UNS},					/*  24 */
247 {"stime",	1, DEC, NOV, DEC},				/*  25 */
248 {"pcsample",	2, DEC, NOV, HEX, DEC},				/*  26 */
249 {"alarm",	1, DEC, NOV, UNS},				/*  27 */
250 {"fstat",	2, DEC, NOV, DEC, HEX},				/*  28 */
251 {"pause",	0, DEC, NOV},					/*  29 */
252 {"utime",	2, DEC, NOV, STG, HEX},				/*  30 */
253 {"stty",	2, DEC, NOV, DEC, DEC},				/*  31 */
254 {"gtty",	2, DEC, NOV, DEC, DEC},				/*  32 */
255 {"access",	2, DEC, NOV, STG, ACC},				/*  33 */
256 {"nice",	1, DEC, NOV, DEC},				/*  34 */
257 {"statfs",	4, DEC, NOV, STG, HEX, DEC, DEC},		/*  35 */
258 {"sync",	0, DEC, NOV},					/*  36 */
259 {"kill",	2, DEC, NOV, DEC, SIG},				/*  37 */
260 {"fstatfs",	4, DEC, NOV, DEC, HEX, DEC, DEC},		/*  38 */
261 {"pgrpsys",	3, DEC, NOV, DEC, DEC, DEC},			/*  39 */
262 {"uucopystr",	3, DEC, NOV, STG, RST, UNS},			/*  40 */
263 {"dup",		1, DEC, NOV, DEC},				/*  41 */
264 {"pipe",	0, DEC, DEC},					/*  42 */
265 {"times",	1, DEC, NOV, HEX},				/*  43 */
266 {"profil",	4, DEC, NOV, HEX, UNS, HEX, OCT},		/*  44 */
267 {"plock",	1, DEC, NOV, PLK},				/*  45 */
268 {"setgid",	1, DEC, NOV, UNS},				/*  46 */
269 {"getgid",	0, UNS, UNS},					/*  47 */
270 {"signal",	2, HEX, NOV, SIG, ACT},				/*  48 */
271 {"msgsys",	6, DEC, NOV, DEC, DEC, DEC, DEC, DEC, DEC},	/*  49 */
272 {"sysi86",	4, HEX, NOV, S86, HEX, HEX, HEX, DEC, DEC},	/*  50 */
273 {"acct",	1, DEC, NOV, STG},				/*  51 */
274 {"shmsys",	4, DEC, NOV, DEC, HEX, HEX, HEX},		/*  52 */
275 {"semsys",	5, DEC, NOV, DEC, HEX, HEX, HEX, HEX},		/*  53 */
276 {"ioctl",	3, DEC, NOV, DEC, IOC, IOA},			/*  54 */
277 {"uadmin",	3, DEC, NOV, DEC, DEC, DEC},			/*  55 */
278 { NULL,		8, HEX, HEX, HEX, HEX, HEX, HEX, HEX, HEX, HEX, HEX},
279 {"utssys",	4, DEC, NOV, HEX, DEC, UTS, HEX},		/*  57 */
280 {"fdsync",	2, DEC, NOV, DEC, FFG},				/*  58 */
281 {"execve",	3, DEC, NOV, STG, HEX, HEX},			/*  59 */
282 {"umask",	1, OCT, NOV, OCT},				/*  60 */
283 {"chroot",	1, DEC, NOV, STG},				/*  61 */
284 {"fcntl",	3, DEC, NOV, DEC, FCN, HEX},			/*  62 */
285 {"ulimit",	2, DEX, NOV, ULM, DEC},				/*  63 */
286 
287 /*  The following 6 entries were reserved for the UNIX PC */
288 { NULL,		8, HEX, HEX, HEX, HEX, HEX, HEX, HEX, HEX, HEX, HEX},
289 { NULL,		8, HEX, HEX, HEX, HEX, HEX, HEX, HEX, HEX, HEX, HEX},
290 { NULL,		8, HEX, HEX, HEX, HEX, HEX, HEX, HEX, HEX, HEX, HEX},
291 { NULL,		8, HEX, HEX, HEX, HEX, HEX, HEX, HEX, HEX, HEX, HEX},
292 { NULL,		8, HEX, HEX, HEX, HEX, HEX, HEX, HEX, HEX, HEX, HEX},
293 { NULL,		8, HEX, HEX, HEX, HEX, HEX, HEX, HEX, HEX, HEX, HEX},
294 
295 {"tasksys",	5, DEC, NOV, DEC, DEC, DEC, HEX, DEC},		/*  70 */
296 {"acctctl",	3, DEC, NOV, HEX, HEX, UNS},			/*  71 */
297 {"exacctsys",	6, DEC, NOV, DEC, IDT, DEC, HEX, DEC, HEX},	/*  72 */
298 {"getpagesizes", 2, DEC, NOV, HEX, DEC},			/*  73 */
299 {"rctlsys",	6, DEC, NOV, RSC, STG, HEX, HEX, DEC, DEC},	/*  74 */
300 {"sidsys",	4, UNS, UNS, DEC, DEC, DEC, DEC},		/*  75 */
301 {"fsat",	6, DEC, NOV, HEX, HEX, HEX, HEX, HEX, HEX},	/*  76 */
302 {"lwp_park",	3, DEC, NOV, DEC, HEX, DEC},			/*  77 */
303 {"sendfilev",	5, DEC, NOV, DEC, DEC, HEX, DEC, HEX},		/*  78 */
304 {"rmdir",	1, DEC, NOV, STG},				/*  79 */
305 {"mkdir",	2, DEC, NOV, STG, OCT},				/*  80 */
306 {"getdents",	3, DEC, NOV, DEC, HEX, UNS},			/*  81 */
307 {"privsys",	5, HEX, NOV, DEC, DEC, DEC, HEX, DEC},		/*  82 */
308 {"ucredsys",	3, DEC, NOV, DEC, DEC, HEX},			/*  83 */
309 {"sysfs",	3, DEC, NOV, SFS, DEX, DEX},			/*  84 */
310 {"getmsg",	4, DEC, NOV, DEC, HEX, HEX, HEX},		/*  85 */
311 {"putmsg",	4, DEC, NOV, DEC, HEX, HEX, SMF},		/*  86 */
312 {"poll",	3, DEC, NOV, HEX, DEC, DEC},			/*  87 */
313 {"lstat",	2, DEC, NOV, STG, HEX},				/*  88 */
314 {"symlink",	2, DEC, NOV, STG, STG},				/*  89 */
315 {"readlink",	3, DEC, NOV, STG, RLK, UNS},			/*  90 */
316 {"setgroups",	2, DEC, NOV, DEC, HEX},				/*  91 */
317 {"getgroups",	2, DEC, NOV, DEC, HEX},				/*  92 */
318 {"fchmod",	2, DEC, NOV, DEC, OCT},				/*  93 */
319 {"fchown",	3, DEC, NOV, DEC, DEC, DEC},			/*  94 */
320 {"sigprocmask",	3, DEC, NOV, SPM, HEX, HEX},			/*  95 */
321 {"sigsuspend",	1, DEC, NOV, HEX},				/*  96 */
322 {"sigaltstack",	2, DEC, NOV, HEX, HEX},				/*  97 */
323 {"sigaction",	3, DEC, NOV, SIG, HEX, HEX},			/*  98 */
324 {"sigpendsys",	2, DEC, NOV, DEC, HEX},				/*  99 */
325 {"context",	2, DEC, NOV, DEC, HEX},				/* 100 */
326 {"evsys",	3, DEC, NOV, DEC, DEC, HEX},			/* 101 */
327 {"evtrapret",	0, DEC, NOV},					/* 102 */
328 {"statvfs",	2, DEC, NOV, STG, HEX},				/* 103 */
329 {"fstatvfs",	2, DEC, NOV, DEC, HEX},				/* 104 */
330 {"getloadavg",	2, DEC, NOV, HEX, DEC},				/* 105 */
331 {"nfssys",	2, DEC, NOV, DEC, HEX},				/* 106 */
332 {"waitid",	4, DEC, NOV, IDT, DEC, HEX, WOP},		/* 107 */
333 {"sigsendsys",	2, DEC, NOV, HEX, SIG},				/* 108 */
334 {"hrtsys",	5, DEC, NOV, DEC, HEX, HEX, HEX, HEX},		/* 109 */
335 { NULL,		8, HEX, HEX, HEX, HEX, HEX, HEX, HEX, HEX, HEX, HEX},
336 {"sigresend",	3, DEC, NOV, SIG, HEX, HEX},			/* 111 */
337 {"priocntlsys",	5, DEC, NOV, DEC, HEX, DEC, PC4, PC5},		/* 112 */
338 {"pathconf",	2, DEC, NOV, STG, PTC},				/* 113 */
339 {"mincore",	3, DEC, NOV, HEX, UNS, HEX},			/* 114 */
340 {"mmap",	6, HEX, NOV, HEX, UNS, MPR, MTY, DEC, DEC},	/* 115 */
341 {"mprotect",	3, DEC, NOV, HEX, UNS, MPR},			/* 116 */
342 {"munmap",	2, DEC, NOV, HEX, UNS},				/* 117 */
343 {"fpathconf",	2, DEC, NOV, DEC, PTC},				/* 118 */
344 {"vfork",	0, DEC, NOV},					/* 119 */
345 {"fchdir",	1, DEC, NOV, DEC},				/* 120 */
346 {"readv",	3, DEC, NOV, DEC, HEX, DEC},			/* 121 */
347 {"writev",	3, DEC, NOV, DEC, HEX, DEC},			/* 122 */
348 {"xstat",	3, DEC, NOV, DEC, STG, HEX},			/* 123 */
349 {"lxstat",	3, DEC, NOV, DEC, STG, HEX},			/* 124 */
350 {"fxstat",	3, DEC, NOV, DEC, DEC, HEX},			/* 125 */
351 {"xmknod",	4, DEC, NOV, DEC, STG, OCT, HEX},		/* 126 */
352 { NULL,		8, HEX, HEX, HEX, HEX, HEX, HEX, HEX, HEX, HEX, HEX},
353 {"setrlimit",	2, DEC, NOV, RLM, HEX},				/* 128 */
354 {"getrlimit",	2, DEC, NOV, RLM, HEX},				/* 129 */
355 {"lchown",	3, DEC, NOV, STG, DEC, DEC},			/* 130 */
356 {"memcntl",	6, DEC, NOV, HEX, UNS, MCF, MC4, MC5, DEC},	/* 131 */
357 {"getpmsg",	5, DEC, NOV, DEC, HEX, HEX, HEX, HEX},		/* 132 */
358 {"putpmsg",	5, DEC, NOV, DEC, HEX, HEX, DEC, HHX},		/* 133 */
359 {"rename",	2, DEC, NOV, STG, STG},				/* 134 */
360 {"uname",	1, DEC, NOV, HEX},				/* 135 */
361 {"setegid",	1, DEC, NOV, UNS},				/* 136 */
362 {"sysconfig",	1, DEC, NOV, CNF},				/* 137 */
363 {"adjtime",	2, DEC, NOV, HEX, HEX},				/* 138 */
364 {"sysinfo",	3, DEC, NOV, INF, RST, DEC},			/* 139 */
365 {"sharefs",	3, DEC, NOV, DEC, HEX, DEC},			/* 140 */
366 {"seteuid",	1, DEC, NOV, UNS},				/* 141 */
367 {"forksys",	2, DEC, NOV, DEC, HHX},				/* 142 */
368 {"fork1",	0, DEC, NOV},					/* 143 */
369 {"sigtimedwait", 3, DEC, NOV, HEX, HEX, HEX},			/* 144 */
370 {"lwp_info",	1, DEC, NOV, HEX},				/* 145 */
371 {"yield",	0, DEC, NOV},					/* 146 */
372 {"lwp_sema_wait", 1, DEC, NOV, HEX},				/* 147 */
373 {"lwp_sema_post", 1, DEC, NOV, HEX},				/* 148 */
374 {"lwp_sema_trywait", 1, DEC, NOV, HEX},				/* 149 */
375 {"lwp_detach",	1, DEC, NOV, DEC},				/* 150 */
376 {"corectl",	4, DEC, NOV, DEC, HEX, HEX, HEX},		/* 151 */
377 {"modctl",	5, DEC, NOV, MOD, HEX, HEX, HEX, HEX},		/* 152 */
378 {"fchroot",	1, DEC, NOV, DEC},				/* 153 */
379 {"utimes",	2, DEC, NOV, STG, HEX},				/* 154 */
380 {"vhangup",	0, DEC, NOV},					/* 155 */
381 {"gettimeofday", 1, DEC, NOV, HEX},				/* 156 */
382 {"getitimer",	2, DEC, NOV, ITM, HEX},				/* 157 */
383 {"setitimer",	3, DEC, NOV, ITM, HEX, HEX},			/* 158 */
384 {"lwp_create",	3, DEC, NOV, HEX, LWF, HEX},			/* 159 */
385 {"lwp_exit",	0, DEC, NOV},					/* 160 */
386 {"lwp_suspend",	1, DEC, NOV, DEC},				/* 161 */
387 {"lwp_continue", 1, DEC, NOV, DEC},				/* 162 */
388 {"lwp_kill",	2, DEC, NOV, DEC, SIG},				/* 163 */
389 {"lwp_self",	0, DEC, NOV},					/* 164 */
390 {"lwp_sigmask",	3, HEX, HEX, SPM, HEX, HEX},			/* 165 */
391 {"lwp_private",	3, HEX, NOV, DEC, DEC, HEX},			/* 166 */
392 {"lwp_wait",	2, DEC, NOV, DEC, HEX},				/* 167 */
393 {"lwp_mutex_wakeup", 2, DEC, NOV, HEX, DEC},			/* 168 */
394 {"lwp_mutex_lock", 1, DEC, NOV, HEX},				/* 169 */
395 {"lwp_cond_wait", 4, DEC, NOV, HEX, HEX, HEX, DEC},		/* 170 */
396 {"lwp_cond_signal", 1, DEC, NOV, HEX},				/* 171 */
397 {"lwp_cond_broadcast", 1, DEC, NOV, HEX},			/* 172 */
398 {"pread",	4, DEC, NOV, DEC, IOB, UNS, DEX},		/* 173 */
399 {"pwrite",	4, DEC, NOV, DEC, IOB, UNS, DEX},		/* 174 */
400 {"llseek",	4, LLO, NOV, DEC, LLO, HID, WHN},		/* 175 */
401 {"inst_sync",	2, DEC, NOV, STG, DEC},				/* 176 */
402 {"brand",	6, DEC, NOV, DEC, HEX, HEX, HEX, HEX, HEX},	/* 177 */
403 {"kaio",	7, DEC, NOV, AIO, HEX, HEX, HEX, HEX, HEX, HEX}, /* 178 */
404 {"cpc",		5, DEC, NOV, CPC, DEC, HEX, HEX, HEX},		/* 179 */
405 {"lgrpsys",	3, DEC, NOV, DEC, DEC, HEX},			/* 180 */
406 {"rusagesys",	5, DEC, NOV, DEC, HEX, DEC, HEX, HEX},		/* 181 */
407 {"portfs",	6, HEX, HEX, DEC, HEX, HEX, HEX, HEX, HEX},	/* 182 */
408 {"pollsys",	4, DEC, NOV, HEX, DEC, HEX, HEX},		/* 183 */
409 {"labelsys",	2, DEC, NOV, DEC, HEX},				/* 184 */
410 {"acl",		4, DEC, NOV, STG, ACL, DEC, HEX},		/* 185 */
411 {"auditsys",	4, DEC, NOV, AUD, HEX, HEX, HEX},		/* 186 */
412 {"processor_bind", 4, DEC, NOV, IDT, DEC, DEC, HEX},		/* 187 */
413 {"processor_info", 2, DEC, NOV, DEC, HEX},			/* 188 */
414 {"p_online",	2, DEC, NOV, DEC, DEC},				/* 189 */
415 {"sigqueue",	5, DEC, NOV, DEC, SIG, HEX, SQC, DEC},		/* 190 */
416 {"clock_gettime", 2, DEC, NOV, DEC, HEX},			/* 191 */
417 {"clock_settime", 2, DEC, NOV, DEC, HEX},			/* 192 */
418 {"clock_getres", 2, DEC, NOV, DEC, HEX},			/* 193 */
419 {"timer_create", 3, DEC, NOV, DEC, HEX, HEX},			/* 194 */
420 {"timer_delete", 1, DEC, NOV, DEC},				/* 195 */
421 {"timer_settime", 4, DEC, NOV, DEC, DEC, HEX, HEX},		/* 196 */
422 {"timer_gettime", 2, DEC, NOV, DEC, HEX},			/* 197 */
423 {"timer_getoverrun", 1, DEC, NOV, DEC},				/* 198 */
424 {"nanosleep",	2, DEC, NOV, HEX, HEX},				/* 199 */
425 {"facl",	4, DEC, NOV, DEC, ACL, DEC, HEX},		/* 200 */
426 {"door",	6, DEC, NOV, DEC, HEX, HEX, HEX, HEX, DEC},	/* 201 */
427 {"setreuid",	2, DEC, NOV, UN1, UN1},				/* 202 */
428 {"setregid",	2, DEC, NOV, UN1, UN1},				/* 203 */
429 {"install_utrap", 3, DEC, NOV, DEC, HEX, HEX},			/* 204 */
430 {"signotify",	3, DEC, NOV, DEC, HEX, HEX},			/* 205 */
431 {"schedctl",	0, HEX, NOV},					/* 206 */
432 {"pset",	5, DEC, NOV, DEC, HEX, HEX, HEX, HEX},		/* 207 */
433 {"sparc_utrap_install", 5, DEC, NOV, UTT, UTH, UTH, HEX, HEX},	/* 208 */
434 {"resolvepath",	3, DEC, NOV, STG, RLK, DEC},			/* 209 */
435 {"lwp_mutex_timedlock", 2, DEC, NOV, HEX, HEX},			/* 210 */
436 {"lwp_sema_timedwait", 3, DEC, NOV, HEX, HEX, DEC},		/* 211 */
437 {"lwp_rwlock_sys", 3, DEC, NOV, DEC, HEX, HEX},			/* 212 */
438 {"getdents64",	3, DEC, NOV, DEC, HEX, UNS},			/* 213 */
439 {"mmap64",	7, HEX, NOV, HEX, UNS, MPR, MTY, DEC, LLO, HID}, /* 214 */
440 {"stat64",	2, DEC, NOV, STG, HEX},				/* 215 */
441 {"lstat64",	2, DEC, NOV, STG, HEX},				/* 216 */
442 {"fstat64",	2, DEC, NOV, DEC, HEX},				/* 217 */
443 {"statvfs64",	2, DEC, NOV, STG, HEX},				/* 218 */
444 {"fstatvfs64",	2, DEC, NOV, DEC, HEX},				/* 219 */
445 {"setrlimit64",	2, DEC, NOV, RLM, HEX},				/* 220 */
446 {"getrlimit64",	2, DEC, NOV, RLM, HEX},				/* 221 */
447 {"pread64",	5, DEC, NOV, DEC, IOB, UNS, LLO, HID},		/* 222 */
448 {"pwrite64",	5, DEC, NOV, DEC, IOB, UNS, LLO, HID},		/* 223 */
449 {"creat64",	2, DEC, NOV, STG, OCT},				/* 224 */
450 {"open64",	3, DEC, NOV, STG, OPN, OCT},			/* 225 */
451 {"rpcmod",	3, DEC, NOV, DEC, HEX},				/* 226 */
452 {"zone",	5, DEC, NOV, DEC, HEX, HEX, HEX, HEX},		/* 227 */
453 {"autofssys",	2, DEC, NOV, DEC, HEX},				/* 228 */
454 {"getcwd",	3, DEC, NOV, RST, DEC},				/* 229 */
455 {"so_socket",	5, DEC, NOV, PFM, SKT, SKP, STG, SKV},		/* 230 */
456 {"so_socketpair", 1, DEC, NOV, HEX},				/* 231 */
457 {"bind",	4, DEC, NOV, DEC, HEX, DEC, SKV},		/* 232 */
458 {"listen",	3, DEC, NOV, DEC, DEC, SKV},			/* 233 */
459 {"accept",	4, DEC, NOV, DEC, HEX, HEX, SKV},		/* 234 */
460 {"connect",	4, DEC, NOV, DEC, HEX, DEC, SKV},		/* 235 */
461 {"shutdown",	3, DEC, NOV, DEC, SHT, SKV},			/* 236 */
462 {"recv",	4, DEC, NOV, DEC, IOB, DEC, DEC},		/* 237 */
463 {"recvfrom",	6, DEC, NOV, DEC, IOB, DEC, DEC, HEX, HEX},	/* 238 */
464 {"recvmsg",	3, DEC, NOV, DEC, HEX, DEC},			/* 239 */
465 {"send",	4, DEC, NOV, DEC, IOB, DEC, DEC},		/* 240 */
466 {"sendmsg",	3, DEC, NOV, DEC, HEX, DEC},			/* 241 */
467 {"sendto",	6, DEC, NOV, DEC, IOB, DEC, DEC, HEX, DEC},	/* 242 */
468 {"getpeername", 4, DEC, NOV, DEC, HEX, HEX, SKV},		/* 243 */
469 {"getsockname", 4, DEC, NOV, DEC, HEX, HEX, SKV},		/* 244 */
470 {"getsockopt",	6, DEC, NOV, DEC, SOL, SON, HEX, HEX, SKV},	/* 245 */
471 {"setsockopt",	6, DEC, NOV, DEC, SOL, SON, HEX, DEC, SKV},	/* 246 */
472 {"sockconfig",	4, DEC, NOV, DEC, DEC, DEC, STG},		/* 247 */
473 {"ntp_gettime",	1, DEC, NOV, HEX},				/* 248 */
474 {"ntp_adjtime",	1, DEC, NOV, HEX},				/* 249 */
475 {"lwp_mutex_unlock", 1, DEC, NOV, HEX},				/* 250 */
476 {"lwp_mutex_trylock", 1, DEC, NOV, HEX},			/* 251 */
477 {"lwp_mutex_register", 1, DEC, NOV, HEX},			/* 252 */
478 {"cladm",	3, DEC, NOV, CLC, CLF, HEX},			/* 253 */
479 {"uucopy",	3, DEC, NOV, HEX, HEX, UNS},			/* 254 */
480 {"umount2",	2, DEC, NOV, STG, MTF},				/* 255 */
481 { NULL, -1, DEC, NOV},
482 };
483 
484 /* SYSEND == max syscall number + 1 */
485 #define	SYSEND	((sizeof (systable) / sizeof (struct systable))-1)
486 
487 
488 /*
489  * The following are for interpreting syscalls with sub-codes.
490  */
491 
492 const	struct systable opentable[] = {
493 {"open",	2, DEC, NOV, STG, OPN},				/* 0 */
494 {"open",	3, DEC, NOV, STG, OPN, OCT},			/* 1 */
495 };
496 #define	NOPENCODE	(sizeof (opentable) / sizeof (struct systable))
497 
498 const	struct systable open64table[] = {
499 {"open64",	2, DEC, NOV, STG, OPN},				/* 0 */
500 {"open64",	3, DEC, NOV, STG, OPN, OCT},			/* 1 */
501 };
502 #define	NOPEN64CODE	(sizeof (open64table) / sizeof (struct systable))
503 
504 const	struct systable fcntltable[] = {
505 {"fcntl",	3, DEC, NOV, DEC, FCN, HEX},			/* 0: default */
506 {"fcntl",	2, DEC, NOV, DEC, FCN},				/* 1: no arg */
507 {"fcntl",	3, DEC, NOV, DEC, FCN, FFG},			/* 2: F_SETFL */
508 };
509 #define	NFCNTLCODE	(sizeof (fcntltable) / sizeof (struct systable))
510 
511 const	struct systable sigtable[] = {
512 {"signal",	2, HEX, NOV, SIG, ACT},				/* 0 */
513 {"sigset",	2, HEX, NOV, SIX, ACT},				/* 1 */
514 {"sighold",	1, HEX, NOV, SIX},				/* 2 */
515 {"sigrelse",	1, HEX, NOV, SIX},				/* 3 */
516 {"sigignore",	1, HEX, NOV, SIX},				/* 4 */
517 {"sigpause",	1, HEX, NOV, SIX},				/* 5 */
518 };
519 #define	NSIGCODE	(sizeof (sigtable) / sizeof (struct systable))
520 
521 const	struct systable msgtable[] = {
522 {"msgget",	3, DEC, NOV, HID, KEY, MSF},			/* 0 */
523 {"msgctl",	4, DEC, NOV, HID, DEC, MSC, HEX},		/* 1 */
524 {"msgrcv",	6, DEC, NOV, HID, DEC, HEX, UNS, DEC, MSF},	/* 2 */
525 {"msgsnd",	5, DEC, NOV, HID, DEC, HEX, UNS, MSF},		/* 3 */
526 {"msgids",	4, DEC, NOV, HID, HEX, UNS, HEX},		/* 4 */
527 {"msgsnap",	5, DEC, NOV, HID, DEC, HEX, UNS, DEC},		/* 5 */
528 };
529 #define	NMSGCODE	(sizeof (msgtable) / sizeof (struct systable))
530 
531 const	struct systable semtable[] = {
532 {"semctl",	5, DEC, NOV, HID, DEC, DEC, SMC, DEX},		/* 0 */
533 {"semget",	4, DEC, NOV, HID, KEY, DEC, SEF},		/* 1 */
534 {"semop",	4, DEC, NOV, HID, DEC, HEX, UNS},		/* 2 */
535 {"semids",	4, DEC, NOV, HID, HEX, UNS, HEX},		/* 3 */
536 {"semtimedop",	5, DEC, NOV, HID, DEC, HEX, UNS, HEX},		/* 4 */
537 };
538 #define	NSEMCODE	(sizeof (semtable) / sizeof (struct systable))
539 
540 const	struct systable shmtable[] = {
541 {"shmat",	4, HEX, NOV, HID, DEC, DEX, SHF},		/* 0 */
542 {"shmctl",	4, DEC, NOV, HID, DEC, SHC, DEX},		/* 1 */
543 {"shmdt",	2, DEC, NOV, HID, HEX},				/* 2 */
544 {"shmget",	4, DEC, NOV, HID, KEY, UNS, SHF},		/* 3 */
545 {"shmids",	4, DEC, NOV, HID, HEX, UNS, HEX},		/* 4 */
546 };
547 #define	NSHMCODE	(sizeof (shmtable) / sizeof (struct systable))
548 
549 const	struct systable pidtable[] = {
550 {"getpgrp",	1, DEC, NOV, HID},				/* 0 */
551 {"setpgrp",	1, DEC, NOV, HID},				/* 1 */
552 {"getsid",	2, DEC, NOV, HID, DEC},				/* 2 */
553 {"setsid",	1, DEC, NOV, HID},				/* 3 */
554 {"getpgid",	2, DEC, NOV, HID, DEC},				/* 4 */
555 {"setpgid",	3, DEC, NOV, HID, DEC, DEC},			/* 5 */
556 };
557 #define	NPIDCODE	(sizeof (pidtable) / sizeof (struct systable))
558 
559 const	struct systable sfstable[] = {
560 {"sysfs",	3, DEC, NOV, SFS, DEX, DEX},			/* 0 */
561 {"sysfs",	2, DEC, NOV, SFS, STG},				/* 1 */
562 {"sysfs",	3, DEC, NOV, SFS, DEC, RST},			/* 2 */
563 {"sysfs",	1, DEC, NOV, SFS},				/* 3 */
564 };
565 #define	NSFSCODE	(sizeof (sfstable) / sizeof (struct systable))
566 
567 const	struct systable utstable[] = {
568 {"utssys",	3, DEC, NOV, HEX, DEC, UTS},			/* 0 */
569 {"utssys",	4, DEC, NOV, HEX, HEX, HEX, HEX},		/* err */
570 {"utssys",	3, DEC, NOV, HEX, HHX, UTS},			/* 2 */
571 {"utssys",	4, DEC, NOV, STG, FUI, UTS, HEX}		/* 3 */
572 };
573 #define	NUTSCODE	(sizeof (utstable) / sizeof (struct systable))
574 
575 const	struct systable rctltable[] = {
576 {"getrctl",	6, DEC, NOV, HID, STG, HEX, HEX, HID, RGF},	/* 0 */
577 {"setrctl",	6, DEC, NOV, HID, STG, HEX, HEX, HID, RSF},	/* 1 */
578 {"rctlsys_lst",	6, DEC, NOV, HID, HID, HEX, HID, HEX, HID},	/* 2 */
579 {"rctlsys_ctl",	6, DEC, NOV, HID, STG, HEX, HID, HID, RCF},	/* 3 */
580 {"setprojrctl",	6, DEC, NOV, HID, STG, HID, HEX, HEX, SPF},	/* 4 */
581 };
582 #define	NRCTLCODE	(sizeof (rctltable) / sizeof (struct systable))
583 
584 const	struct systable sgptable[] = {
585 {"sigpendsys",	2, DEC, NOV, DEC, HEX},				/* err */
586 {"sigpending",	2, DEC, NOV, HID, HEX},				/* 1 */
587 {"sigfillset",	2, DEC, NOV, HID, HEX},				/* 2 */
588 };
589 #define	NSGPCODE	(sizeof (sgptable) / sizeof (struct systable))
590 
591 const	struct systable ctxtable[] = {
592 {"getcontext",	2, DEC, NOV, HID, HEX},				/* 0 */
593 {"setcontext",	2, DEC, NOV, HID, HEX},				/* 1 */
594 {"getustack",	2, DEC, NOV, HID, HEX},				/* 2 */
595 {"setustack",	2, DEC, NOV, HID, HEX},				/* 3 */
596 };
597 #define	NCTXCODE	(sizeof (ctxtable) / sizeof (struct systable))
598 
599 const	struct systable hrttable[] = {
600 {"hrtcntl",	5, DEC, NOV, HID, DEC, DEC, HEX, HEX},		/* 0 */
601 {"hrtalarm",	3, DEC, NOV, HID, HEX, DEC},			/* 1 */
602 {"hrtsleep",	2, DEC, NOV, HID, HEX},				/* 2 */
603 {"hrtcancel",	3, DEC, NOV, HID, HEX, DEC},			/* 3 */
604 };
605 #define	NHRTCODE	(sizeof (hrttable) / sizeof (struct systable))
606 
607 const	struct systable cortable[] = {
608 {"corectl",	4, DEC, NOV, COR, HEX, HEX, HEX},		/* 0 */
609 {"corectl",	2, DEC, NOV, COR, CCO},				/* 1 */
610 {"corectl",	1, HHX, NOV, COR},				/* 2 */
611 {"corectl",	3, DEC, NOV, COR, STG, DEC},			/* 3 */
612 {"corectl",	3, DEC, NOV, COR, RST, DEC},			/* 4 */
613 {"corectl",	4, DEC, NOV, COR, STG, DEC, DEC},		/* 5 */
614 {"corectl",	4, DEC, NOV, COR, RST, DEC, DEC},		/* 6 */
615 {"corectl",	2, DEC, NOV, COR, CCC},				/* 7 */
616 {"corectl",	2, DEC, NOV, COR, RCC},				/* 8 */
617 {"corectl",	3, DEC, NOV, COR, CCC, DEC},			/* 9 */
618 {"corectl",	3, DEC, NOV, COR, RCC, DEC},			/* 10 */
619 {"corectl",	3, DEC, NOV, COR, STG, DEC},			/* 11 */
620 {"corectl",	3, DEC, NOV, COR, RST, DEC},			/* 12 */
621 {"corectl",	2, DEC, NOV, COR, CCC},				/* 13 */
622 {"corectl",	2, DEC, NOV, COR, RCC},				/* 14 */
623 };
624 #define	NCORCODE	(sizeof (cortable) / sizeof (struct systable))
625 
626 const	struct systable aiotable[] = {
627 {"kaio",	7, DEC, NOV, AIO, DEC, HEX, DEC, LLO, HID, HEX}, /* 0 */
628 {"kaio",	7, DEC, NOV, AIO, DEC, HEX, DEC, LLO, HID, HEX}, /* 1 */
629 {"kaio",	3, DEC, NOV, AIO, HEX, DEC},			/* 2 */
630 {"kaio",	3, DEC, NOV, AIO, DEC, HEX},			/* 3 */
631 {"kaio",	1, DEC, NOV, AIO},				/* 4 */
632 {"kaio",	1, DEC, NOV, AIO},				/* 5 */
633 {"kaio",	1, DEC, NOV, AIO},				/* 6 */
634 {"kaio",	5, DEC, NOV, AIO, LIO, HEX, DEC, HEX},		/* 7 */
635 {"kaio",	5, DEC, NOV, AIO, HEX, DEC, HEX, DEC},		/* 8 */
636 {"kaio",	2, DEC, NOV, AIO, HEX},				/* 9 */
637 {"kaio",	5, DEC, NOV, AIO, LIO, HEX, DEC, HEX},		/* 10 */
638 {"kaio",	2, DEC, NOV, AIO, HEX},				/* 11 */
639 {"kaio",	2, DEC, NOV, AIO, HEX},				/* 12 */
640 {"kaio",	5, DEC, NOV, AIO, LIO, HEX, DEC, HEX},		/* 13 */
641 {"kaio",	5, DEC, NOV, AIO, HEX, DEC, HEX, DEC},		/* 14 */
642 {"kaio",	2, DEC, NOV, AIO, HEX},				/* 15 */
643 {"kaio",	5, DEC, NOV, AIO, LIO, HEX, DEC, HEX},		/* 16 */
644 {"kaio",	2, DEC, NOV, AIO, HEX},				/* 17 */
645 {"kaio",	2, DEC, NOV, AIO, HEX},				/* 18 */
646 {"kaio",	3, DEC, NOV, AIO, DEC, HEX},			/* 19 */
647 {"kaio",	1, DEC, NOV, AIO},				/* 20 */
648 {"kaio",	5, DEC, NOV, AIO, HEX, DEC, HEX, HEX},		/* 21 */
649 };
650 #define	NAIOCODE	(sizeof (aiotable) / sizeof (struct systable))
651 
652 const	struct systable doortable[] = {
653 {"door_create", 3, DEC, NOV, HEX, HEX, DFL},			/* 0 */
654 {"door_revoke", 1, DEC, NOV, DEC},				/* 1 */
655 {"door_info",	2, DEC, NOV, DEC, HEX},				/* 2 */
656 {"door_call",	2, DEC, NOV, DEC, HEX},				/* 3 */
657 {"door_return", 4, DEC, NOV, HEX, DEC, HEX, DEC},		/* 4 (old) */
658 {"door_cred",	1, DEC, NOV, HEX},				/* 5 (old) */
659 {"door_bind",	1, DEC, NOV, DEC},				/* 6 */
660 {"door_unbind", 0, DEC, NOV},					/* 7 */
661 {"door_unref",	0, DEC, NOV},					/* 8 */
662 {"door_ucred",	1, DEC, NOV, HEX},				/* 9 */
663 {"door_return", 5, DEC, NOV, HEX, DEC, HEX, HEX, DEC},		/* 10 */
664 {"door_getparam", 3, DEC, NOV, DEC, DPM, HEX},			/* 11 */
665 {"door_setparam", 3, DEC, NOV, DEC, DPM, DEC},			/* 12 */
666 };
667 #define	NDOORCODE	(sizeof (doortable) / sizeof (struct systable))
668 
669 const	struct systable psettable[] = {
670 {"pset_create", 2, DEC, NOV, HID, HEX},				/* 0 */
671 {"pset_destroy", 2, DEC, NOV, HID, PST},			/* 1 */
672 {"pset_assign",	4, DEC, NOV, HID, PST, DEC, HEX},		/* 2 */
673 {"pset_info",	5, DEC, NOV, HID, PST, HEX, HEX, HEX},		/* 3 */
674 {"pset_bind",	5, DEC, NOV, HID, PST, IDT, DEC, HEX},		/* 4 */
675 {"pset_getloadavg", 4, DEC, NOV, HID, PST, HEX, DEC},		/* 5 */
676 {"pset_list",	3, DEC, NOV, HID, HEX, HEX},			/* 6 */
677 {"pset_setattr", 3, DEC, NOV, HID, PST, HEX},			/* 7 */
678 {"pset_getattr", 3, DEC, NOV, HID, PST, HEX},			/* 8 */
679 {"pset_assign_forced",	4, DEC, NOV, HID, PST, DEC, HEX},	/* 9 */
680 };
681 #define	NPSETCODE	(sizeof (psettable) / sizeof (struct systable))
682 
683 const	struct systable lwpcreatetable[] = {
684 {"lwp_create",	3, DEC, NOV, HEX, LWF, HEX},			/* 0 */
685 {"lwp_create",	0, DEC, NOV},					/* 1 */
686 };
687 #define	NLWPCREATECODE	(sizeof (lwpcreatetable) / sizeof (struct systable))
688 
689 static	const	struct systable tasksystable[] = {
690 {"settaskid",	3, DEC, NOV, HID, DEC, HEX},			/* 0 */
691 {"gettaskid",	1, DEC, NOV, HID},				/* 1 */
692 {"getprojid",	1, DEC, NOV, HID},				/* 2 */
693 };
694 #define	NTASKSYSCODE	(sizeof (tasksystable) / sizeof (struct systable))
695 
696 static const	struct systable privsystable[] = {
697 {"setppriv",		4, DEC, NOV, HID, PRO, PRN, PRS},	/* 0 */
698 {"getppriv",		4, DEC, NOV, HID, HID, PRN, PRS},	/* 1 */
699 {"getprivimplinfo",	5, DEC, NOV, HID, HID, HID, HEX, DEC},	/* 2 */
700 {"setpflags",		3, DEC, NOV, HID, PFL, DEC},		/* 3 */
701 {"getpflags",		2, DEC, NOV, HID, PFL},			/* 4 */
702 {"issetugid",		0, DEC, NOV, HID},			/* 5 */
703 };
704 #define	NPRIVSYSCODE	(sizeof (privsystable) / sizeof (struct systable))
705 
706 static	const	struct systable exacctsystable[] = {
707 {"getacct",	5, DEC, NOV, HID, IDT, DEC, HEX, UNS},		/* 0 */
708 {"putacct",	6, DEC, NOV, HID, IDT, DEC, HEX, UNS, HEX},	/* 1 */
709 {"wracct",	4, DEC, NOV, HID, IDT, DEC, HEX},		/* 2 */
710 };
711 #define	NEXACCTSYSCODE	(sizeof (exacctsystable) / sizeof (struct systable))
712 
713 static const	struct systable fsatsystable[] = {
714 {"openat",	5, DEC, NOV, HID, ATC, STG, OPN, OCT},		/* 0 */
715 {"openat64",	5, DEC, NOV, HID, ATC, STG, OPN, OCT},		/* 1 */
716 {"fstatat64",	5, DEC, NOV, HID, ATC, STG, HEX, HEX},		/* 2 */
717 {"fstatat",	5, DEC, NOV, HID, ATC, STG, HEX, HEX},		/* 3 */
718 {"fchownat",	6, DEC, NOV, HID, ATC, STG, HEX, HEX, HEX},	/* 4 */
719 {"unlinkat",	4, DEC, NOV, HID, ATC, STG, HEX},		/* 5 */
720 {"futimesat",	4, DEC, NOV, HID, ATC, STG, HEX},		/* 6 */
721 {"renameat",	5, DEC, NOV, HID, ATC, STG, DEC, STG},		/* 7 */
722 {"__accessat",	5, DEC, NOV, HID, ATC, STG, ACC},		/* 8 */
723 {"__openattrdirat", 3, DEC, NOV, HID, ATC, STG},		/* 9 */
724 {"openat",	4, DEC, NOV, HID, ATC, STG, OPN},		/* N - 2 */
725 {"openat64",	4, DEC, NOV, HID, ATC, STG, OPN},		/* N - 1 */
726 };
727 #define	NFSATSYSCODE	(sizeof (fsatsystable) / sizeof (struct systable))
728 
729 static	const	struct systable lwpparktable[] = {
730 {"lwp_park",	3, DEC, NOV, HID, HEX, DEC},			/* 0 */
731 {"lwp_unpark",	2, DEC, NOV, HID, DEC},				/* 1 */
732 {"lwp_unpark_all", 3, DEC, NOV, HID, HEX, DEC},			/* 2 */
733 {"lwp_unpark_cancel",	2, DEC, NOV, HID, DEC},			/* 3 */
734 {"lwp_set_park",	3, DEC, NOV, HID, HEX, DEC},		/* 4 */
735 };
736 #define	NLWPPARKCODE	(sizeof (lwpparktable) / sizeof (struct systable))
737 
738 static	const	struct systable lwprwlocktable[] = {
739 {"lwp_rwlock_rdlock", 3, DEC, NOV, HID, HEX, HEX},		/* 0 */
740 {"lwp_rwlock_wrlock", 3, DEC, NOV, HID, HEX, HEX},		/* 1 */
741 {"lwp_rwlock_tryrdlock", 2, DEC, NOV, HID, HEX},		/* 2 */
742 {"lwp_rwlock_trywrlock", 2, DEC, NOV, HID, HEX},		/* 3 */
743 {"lwp_rwlock_unlock", 2, DEC, NOV, HID, HEX},			/* 4 */
744 };
745 #define	NLWPRWLOCKCODE	(sizeof (lwprwlocktable) / sizeof (struct systable))
746 
747 static	const	struct systable sendfilevsystable[] = {
748 {"sendfilev",	5, DEC, NOV, DEC, DEC, HEX, DEC, HEX},		/* 0 */
749 {"sendfilev64",	5, DEC, NOV, DEC, DEC, HEX, DEC, HEX},		/* 1 */
750 };
751 #define	NSENDFILESYSCODE \
752 		(sizeof (sendfilevsystable) / sizeof (struct systable))
753 
754 static	const	struct systable lgrpsystable[] = {
755 {"meminfo",		3, DEC, NOV, HID, NOV, MIF},		/* 0 */
756 {"_lgrpsys",		3, DEC, NOV, DEC, DEC, NOV},		/* 1 */
757 {"lgrp_version",	3, DEC, NOV, HID, DEC, NOV},		/* 2 */
758 {"_lgrpsys",		3, DEC, NOV, DEC, HEX, HEX},		/* 3 */
759 {"lgrp_affinity_get",	3, DEC, NOV, HID, NOV, LAF},		/* 4 */
760 {"lgrp_affinity_set",	3, DEC, NOV, HID, NOV, LAF},		/* 5 */
761 {"lgrp_latency",	3, DEC, NOV, HID, DEC, DEC},		/* 6 */
762 };
763 #define	NLGRPSYSCODE	(sizeof (lgrpsystable) / sizeof (struct systable))
764 
765 static	const	struct systable rusagesystable[] = {
766 {"getrusage",		2, DEC, NOV, HID, HEX},			/* 0 */
767 {"getrusage_chld",	2, DEC, NOV, HID, HEX},			/* 1 */
768 {"getrusage_lwp",	2, DEC, NOV, HID, HEX},			/* 2 */
769 {"getvmusage",		5, DEC, NOV, HID, HEX, DEC, HEX, HEX},	/* 3 */
770 };
771 #define	NRUSAGESYSCODE \
772 		(sizeof (rusagesystable) / sizeof (struct systable))
773 
774 static const	struct systable ucredsystable[] = {
775 {"ucred_get",	3, DEC, NOV, HID, DEC, HEX},
776 {"getpeerucred", 3, DEC, NOV, HID, DEC, HEX},
777 };
778 #define	NUCREDSYSCODE \
779 		(sizeof (ucredsystable) / sizeof (struct systable))
780 
781 const	struct systable portfstable[] = {
782 {"port_create",	2, DEC, NOV, HID, DEC},				/* 0 */
783 {"port_associate",	6, DEC, NOV, HID, DEC, DEC, HEX, HEX, HEX}, /* 1 */
784 {"port_dissociate",	4, DEC, NOV, HID, DEC, DEC, HEX}, 	/* 2 */
785 {"port_send",	4, DEC, NOV, HID, DEC, HEX, HEX},		/* 3 */
786 {"port_sendn",	6, DEC, DEC, HID, HEX, HEX, DEC, HEX, HEX},	/* 4 */
787 {"port_get",	4, DEC, NOV, HID, DEC, HEX, HEX},		/* 5 */
788 {"port_getn",	6, DEC, DEC, HID, DEC, HEX, DEC, DEC, HEX},	/* 6 */
789 {"port_alert",	5, DEC, NOV, HID, DEC, HEX, HEX, HEX},		/* 7 */
790 {"port_dispatch", 6, DEC, NOV, HID, DEC, DEC, HEX, HEX, HEX},	/* 8 */
791 };
792 #define	NPORTCODE	(sizeof (portfstable) / sizeof (struct systable))
793 
794 static const struct systable zonetable[] = {
795 {"zone_create",	2, DEC, NOV, HID, HEX},				/* 0 */
796 {"zone_destroy", 2, DEC, NOV, HID, DEC},			/* 1 */
797 {"zone_getattr", 5, DEC, NOV, HID, DEC, ZGA, HEX, DEC},		/* 2 */
798 {"zone_enter",	2, DEC, NOV, HID, DEC},				/* 3 */
799 {"zone_list",	3, DEC, NOV, HID, HEX, HEX},			/* 4 */
800 {"zone_shutdown", 2, DEC, NOV, HID, DEC},			/* 5 */
801 {"zone_lookup",	2, DEC, NOV, HID, STG},				/* 6 */
802 {"zone_boot",	2, DEC, NOV, HID, DEC},				/* 7 */
803 {"zone_version", 2, HEX, NOV, HID, DEC},			/* 8 */
804 {"zone_setattr", 5, DEC, NOV, HID, DEC, ZGA, HEX, DEC},		/* 9 */
805 {"zone_add_datalink", 3, DEC, NOV, HID, DEC, STG},		/* 10 */
806 {"zone_remove_datalink", 3, DEC, NOV, HID, DEC, STG},		/* 11 */
807 {"zone_check_datalink", 3, DEC, NOV, HID, HEX, STG},		/* 12 */
808 {"zone_list_datalink", 4, DEC, NOV, HID, DEC, HEX, HEX},	/* 13 */
809 };
810 #define	NZONECODE	(sizeof (zonetable) / sizeof (struct systable))
811 
812 static const struct systable labeltable[] = {
813 {"labelsys",	3, DEC, NOV, HID, HEX, HEX},			/* 0 */
814 {"is_system_labeled", 1, DEC, NOV, HID},			/* 1 */
815 {"tnrh",	3, DEC, NOV, HID, TND, HEX},			/* 2 */
816 {"tnrhtp",	3, DEC, NOV, HID, TND, HEX},			/* 3 */
817 {"tnmlp",	3, DEC, NOV, HID, TND, HEX},			/* 4 */
818 {"getlabel",	3, DEC, NOV, HID, STG, HEX},			/* 5 */
819 {"fgetlabel",	3, DEC, NOV, HID, DEC, HEX},			/* 6 */
820 };
821 #define	NLABELCODE	(sizeof (labeltable) / sizeof (struct systable))
822 
823 const	struct systable forktable[] = {
824 /* parent codes */
825 {"forkx",	2, DEC, NOV, HID, FXF},				/* 0 */
826 {"forkallx",	2, DEC, NOV, HID, FXF},				/* 1 */
827 {"vforkx",	2, DEC, NOV, HID, FXF},				/* 2 */
828 /* child codes */
829 {"forkx",	0, DEC, NOV},					/* 3 */
830 {"forkallx",	0, DEC, NOV},					/* 4 */
831 {"vforkx",	0, DEC, NOV},					/* 5 */
832 };
833 #define	NFORKCODE	(sizeof (forktable) / sizeof (struct systable))
834 
835 const	struct systable sidsystable[] = {
836 {"allocids",	4, UNS, UNS, HID, DEC, DEC, DEC},		/* 0 */
837 {"idmap_reg",	2, DEC, NOV, HID, DEC},				/* 1 */
838 {"idmap_unreg",	2, DEC, NOV, HID, DEC},				/* 2 */
839 };
840 #define	NSIDSYSCODE	(sizeof (sidsystable) / sizeof (struct systable))
841 
842 const	struct sysalias sysalias[] = {
843 	{ "exit",	SYS_exit	},
844 	{ "fork",	SYS_forksys	},
845 	{ "forkx",	SYS_forksys	},
846 	{ "forkallx",	SYS_forksys	},
847 	{ "vforkx",	SYS_forksys	},
848 	{ "sbrk",	SYS_brk		},
849 	{ "getppid",	SYS_getpid	},
850 	{ "geteuid",	SYS_getuid	},
851 	{ "getpgrp",	SYS_pgrpsys	},
852 	{ "setpgrp",	SYS_pgrpsys	},
853 	{ "getsid",	SYS_pgrpsys	},
854 	{ "setsid",	SYS_pgrpsys	},
855 	{ "getpgid",	SYS_pgrpsys	},
856 	{ "setpgid",	SYS_pgrpsys	},
857 	{ "getegid",	SYS_getgid	},
858 	{ "sigset",	SYS_signal	},
859 	{ "sighold",	SYS_signal	},
860 	{ "sigrelse",	SYS_signal	},
861 	{ "sigignore",	SYS_signal	},
862 	{ "sigpause",	SYS_signal	},
863 	{ "msgget",	SYS_msgsys	},
864 	{ "msgctl",	SYS_msgsys	},
865 	{ "msgctl64",	SYS_msgsys	},
866 	{ "msgrcv",	SYS_msgsys	},
867 	{ "msgsnd",	SYS_msgsys	},
868 	{ "msgids",	SYS_msgsys	},
869 	{ "msgsnap",	SYS_msgsys	},
870 	{ "msgop",	SYS_msgsys	},
871 	{ "shmat",	SYS_shmsys	},
872 	{ "shmctl",	SYS_shmsys	},
873 	{ "shmctl64",	SYS_shmsys	},
874 	{ "shmdt",	SYS_shmsys	},
875 	{ "shmget",	SYS_shmsys	},
876 	{ "shmids",	SYS_shmsys	},
877 	{ "shmop",	SYS_shmsys	},
878 	{ "semctl",	SYS_semsys	},
879 	{ "semctl64",	SYS_semsys	},
880 	{ "semget",	SYS_semsys	},
881 	{ "semids",	SYS_semsys	},
882 	{ "semop",	SYS_semsys	},
883 	{ "semtimedop",	SYS_semsys	},
884 	{ "uname",	SYS_utssys	},
885 	{ "ustat",	SYS_utssys	},
886 	{ "fusers",	SYS_utssys	},
887 	{ "exec",	SYS_execve	},
888 	{ "execl",	SYS_execve	},
889 	{ "execv",	SYS_execve	},
890 	{ "execle",	SYS_execve	},
891 	{ "execlp",	SYS_execve	},
892 	{ "execvp",	SYS_execve	},
893 	{ "sigfillset",	SYS_sigpending	},
894 	{ "getcontext",	SYS_context	},
895 	{ "setcontext",	SYS_context	},
896 	{ "getustack",	SYS_context	},
897 	{ "setustack",	SYS_context	},
898 	{ "hrtcntl",	SYS_hrtsys	},
899 	{ "hrtalarm",	SYS_hrtsys	},
900 	{ "hrtsleep",	SYS_hrtsys	},
901 	{ "hrtcancel",	SYS_hrtsys	},
902 	{ "aioread",	SYS_kaio	},
903 	{ "aiowrite",	SYS_kaio	},
904 	{ "aiowait",	SYS_kaio	},
905 	{ "aiocancel",	SYS_kaio	},
906 	{ "aionotify",	SYS_kaio	},
907 	{ "audit",	SYS_auditsys	},
908 	{ "door_create",	SYS_door	},
909 	{ "door_revoke",	SYS_door	},
910 	{ "door_info",		SYS_door	},
911 	{ "door_call",		SYS_door	},
912 	{ "door_return",	SYS_door	},
913 	{ "door_bind",		SYS_door	},
914 	{ "door_unbind",	SYS_door	},
915 	{ "door_unref",		SYS_door	},
916 	{ "door_ucred",		SYS_door	},
917 	{ "door_getparam",	SYS_door	},
918 	{ "door_setparam",	SYS_door	},
919 	{ "pset_create",	SYS_pset	},
920 	{ "pset_destroy",	SYS_pset	},
921 	{ "pset_assign",	SYS_pset	},
922 	{ "pset_info",		SYS_pset	},
923 	{ "pset_bind",		SYS_pset	},
924 	{ "pset_getloadavg",	SYS_pset	},
925 	{ "pset_list",		SYS_pset	},
926 	{ "pset_setattr",	SYS_pset	},
927 	{ "pset_getattr",	SYS_pset	},
928 	{ "pset_assign_forced",	SYS_pset	},
929 	{ "settaskid",		SYS_tasksys	},
930 	{ "gettaskid",		SYS_tasksys	},
931 	{ "getprojid",		SYS_tasksys	},
932 	{ "setppriv",		SYS_privsys	},
933 	{ "getppriv",		SYS_privsys	},
934 	{ "getprivimplinfo",	SYS_privsys	},
935 	{ "setpflags",		SYS_privsys	},
936 	{ "getpflags",		SYS_privsys	},
937 	{ "getacct",		SYS_exacctsys	},
938 	{ "putacct",		SYS_exacctsys	},
939 	{ "wracct",		SYS_exacctsys	},
940 	{ "lwp_cond_timedwait",	SYS_lwp_cond_wait },
941 	{ "lwp_park",		SYS_lwp_park	},
942 	{ "lwp_unpark",		SYS_lwp_park	},
943 	{ "lwp_unpark_all",	SYS_lwp_park	},
944 	{ "lwp_rwlock_rdlock",	SYS_lwp_rwlock_sys },
945 	{ "lwp_rwlock_wrlock",	SYS_lwp_rwlock_sys },
946 	{ "lwp_rwlock_tryrdlock", SYS_lwp_rwlock_sys },
947 	{ "lwp_rwlock_trywrlock", SYS_lwp_rwlock_sys },
948 	{ "lwp_rwlock_unlock",	SYS_lwp_rwlock_sys },
949 	{ "sendfilev64",	SYS_sendfilev	},
950 	{ "openat",		SYS_fsat	},
951 	{ "openat64",		SYS_fsat	},
952 	{ "fstatat64",		SYS_fsat	},
953 	{ "fstatat",		SYS_fsat	},
954 	{ "fchownat",		SYS_fsat	},
955 	{ "unlinkat",		SYS_fsat	},
956 	{ "futimesat",		SYS_fsat	},
957 	{ "renameat",		SYS_fsat	},
958 	{ "__accessat",		SYS_fsat	},
959 	{ "__openattrdirat",	SYS_fsat	},
960 	{ "lgrpsys",		SYS_lgrpsys	},
961 	{ "getrusage",		SYS_rusagesys	},
962 	{ "getrusage_chld",	SYS_rusagesys	},
963 	{ "getrusage_lwp",	SYS_rusagesys	},
964 	{ "getvmusage",		SYS_rusagesys	},
965 	{ "getpeerucred",	SYS_ucredsys	},
966 	{ "ucred_get",		SYS_ucredsys	},
967 	{ "port_create",	SYS_port	},
968 	{ "port_associate",	SYS_port	},
969 	{ "port_dissociate",	SYS_port	},
970 	{ "port_send",		SYS_port	},
971 	{ "port_sendn",		SYS_port	},
972 	{ "port_get",		SYS_port	},
973 	{ "port_getn",		SYS_port	},
974 	{ "port_alert",		SYS_port	},
975 	{ "port_dispatch",	SYS_port	},
976 	{ "zone_create",	SYS_zone	},
977 	{ "zone_destroy",	SYS_zone	},
978 	{ "zone_getattr",	SYS_zone	},
979 	{ "zone_setattr",	SYS_zone	},
980 	{ "zone_enter",		SYS_zone	},
981 	{ "getzoneid",		SYS_zone	},
982 	{ "zone_list",		SYS_zone	},
983 	{ "zone_shutdown",	SYS_zone	},
984 	{ "zone_add_datalink",	SYS_zone	},
985 	{ "zone_remove_datalink", SYS_zone	},
986 	{ "zone_check_datalink", SYS_zone	},
987 	{ "zone_list_datalink",	SYS_zone	},
988 	{ "is_system_labeled",	SYS_labelsys	},
989 	{ "tnrh",		SYS_labelsys	},
990 	{ "tnrhtp",		SYS_labelsys	},
991 	{ "tnmlp",		SYS_labelsys	},
992 	{ "getlabel",		SYS_labelsys	},
993 	{ "fgetlabel",		SYS_labelsys	},
994 	{ "getrctl",		SYS_rctlsys	},
995 	{ "setrctl",		SYS_rctlsys	},
996 	{ "rctlsys_lst",	SYS_rctlsys	},
997 	{ "rctlsys_ctl",	SYS_rctlsys	},
998 	{ "allocids",		SYS_sidsys	},
999 	{  NULL,	0	}	/* end-of-list */
1000 };
1001 
1002 /*
1003  * Return structure to interpret system call with sub-codes.
1004  */
1005 const struct systable *
1006 subsys(int syscall, int subcode)
1007 {
1008 	const struct systable *stp = NULL;
1009 
1010 	if (subcode != -1) {
1011 		switch (syscall) {
1012 		case SYS_open:
1013 			if ((unsigned)subcode < NOPENCODE)
1014 				stp = &opentable[subcode];
1015 			break;
1016 		case SYS_open64:
1017 			if ((unsigned)subcode < NOPEN64CODE)
1018 				stp = &open64table[subcode];
1019 			break;
1020 		case SYS_signal:	/* signal() + sigset() family */
1021 			if ((unsigned)subcode < NSIGCODE)
1022 				stp = &sigtable[subcode];
1023 			break;
1024 		case SYS_msgsys:	/* msgsys() */
1025 			if ((unsigned)subcode < NMSGCODE)
1026 				stp = &msgtable[subcode];
1027 			break;
1028 		case SYS_semsys:	/* semsys() */
1029 			if ((unsigned)subcode < NSEMCODE)
1030 				stp = &semtable[subcode];
1031 			break;
1032 		case SYS_shmsys:	/* shmsys() */
1033 			if ((unsigned)subcode < NSHMCODE)
1034 				stp = &shmtable[subcode];
1035 			break;
1036 		case SYS_pgrpsys:	/* pgrpsys() */
1037 			if ((unsigned)subcode < NPIDCODE)
1038 				stp = &pidtable[subcode];
1039 			break;
1040 		case SYS_utssys:	/* utssys() */
1041 			if ((unsigned)subcode < NUTSCODE)
1042 				stp = &utstable[subcode];
1043 			break;
1044 		case SYS_sysfs:		/* sysfs() */
1045 			if ((unsigned)subcode < NSFSCODE)
1046 				stp = &sfstable[subcode];
1047 			break;
1048 		case SYS_sigpending:	/* sigpending()/sigfillset() */
1049 			if ((unsigned)subcode < NSGPCODE)
1050 				stp = &sgptable[subcode];
1051 			break;
1052 		case SYS_context:	/* [get|set]context() */
1053 			if ((unsigned)subcode < NCTXCODE)
1054 				stp = &ctxtable[subcode];
1055 			break;
1056 		case SYS_hrtsys:	/* hrtsys() */
1057 			if ((unsigned)subcode < NHRTCODE)
1058 				stp = &hrttable[subcode];
1059 			break;
1060 		case SYS_corectl:	/* corectl() */
1061 			if ((unsigned)subcode < NCORCODE)
1062 				stp = &cortable[subcode];
1063 			break;
1064 		case SYS_kaio:		/* kaio() */
1065 			if ((unsigned)subcode < NAIOCODE)
1066 				stp = &aiotable[subcode];
1067 			break;
1068 		case SYS_door:		/* doors */
1069 			if ((unsigned)subcode < NDOORCODE)
1070 				stp = &doortable[subcode];
1071 			break;
1072 		case SYS_pset:		/* pset() */
1073 			if ((unsigned)subcode < NPSETCODE)
1074 				stp = &psettable[subcode];
1075 			break;
1076 		case SYS_lwp_create:	/* lwp_create() */
1077 			if ((unsigned)subcode < NLWPCREATECODE)
1078 				stp = &lwpcreatetable[subcode];
1079 			break;
1080 		case SYS_tasksys:	/* tasks */
1081 			if ((unsigned)subcode < NTASKSYSCODE)
1082 				stp = &tasksystable[subcode];
1083 			break;
1084 		case SYS_exacctsys:	/* exacct */
1085 			if ((unsigned)subcode < NEXACCTSYSCODE)
1086 				stp = &exacctsystable[subcode];
1087 			break;
1088 		case SYS_fsat:
1089 			if ((unsigned)subcode < NFSATSYSCODE)
1090 				stp = &fsatsystable[subcode];
1091 			break;
1092 		case SYS_privsys:	/* privileges */
1093 			if ((unsigned)subcode < NPRIVSYSCODE)
1094 				stp = &privsystable[subcode];
1095 			break;
1096 		case SYS_lwp_park:	/* lwp_park */
1097 			if ((unsigned)subcode < NLWPPARKCODE)
1098 				stp = &lwpparktable[subcode];
1099 			break;
1100 		case SYS_lwp_rwlock_sys:
1101 			if ((unsigned)subcode < NLWPRWLOCKCODE)
1102 				stp = &lwprwlocktable[subcode];
1103 			break;
1104 		case SYS_sendfilev:	/* sendfilev */
1105 			if ((unsigned)subcode < NSENDFILESYSCODE)
1106 				stp = &sendfilevsystable[subcode];
1107 			break;
1108 		case SYS_lgrpsys:	/* lgrpsys */
1109 			if ((unsigned)subcode < NLGRPSYSCODE)
1110 				stp = &lgrpsystable[subcode];
1111 			break;
1112 		case SYS_rusagesys:	/* rusagesys */
1113 			if ((unsigned)subcode < NRUSAGESYSCODE)
1114 				stp = &rusagesystable[subcode];
1115 			break;
1116 		case SYS_fcntl:		/* fcntl */
1117 			if ((unsigned)subcode < NFCNTLCODE)
1118 				stp = &fcntltable[subcode];
1119 			break;
1120 		case SYS_ucredsys:
1121 			if ((unsigned)subcode < NUCREDSYSCODE)
1122 				stp = &ucredsystable[subcode];
1123 			break;
1124 		case SYS_port:	/* portfs */
1125 			if ((unsigned)subcode < NPORTCODE)
1126 				stp = &portfstable[subcode];
1127 			break;
1128 		case SYS_zone:		/* zone family */
1129 			if ((unsigned)subcode < NZONECODE)
1130 				stp = &zonetable[subcode];
1131 			break;
1132 		case SYS_labelsys:	/* label family */
1133 			if ((unsigned)subcode < NLABELCODE)
1134 				stp = &labeltable[subcode];
1135 			break;
1136 		case SYS_rctlsys:	/* rctl family */
1137 			if ((unsigned)subcode < NRCTLCODE)
1138 				stp = &rctltable[subcode];
1139 			break;
1140 		case SYS_forksys:	/* fork family */
1141 			if ((unsigned)subcode < NFORKCODE)
1142 				stp = &forktable[subcode];
1143 			break;
1144 		case SYS_sidsys:	/* SID family */
1145 			if ((unsigned)subcode < NSIDSYSCODE)
1146 				stp = &sidsystable[subcode];
1147 			break;
1148 		}
1149 	}
1150 
1151 	if (stp == NULL)
1152 		stp = &systable[((unsigned)syscall < SYSEND)? syscall : 0];
1153 
1154 	return (stp);
1155 }
1156 
1157 /*
1158  * Return the name of the system call.
1159  */
1160 const char *
1161 sysname(private_t *pri, int syscall, int subcode)
1162 {
1163 	const struct systable *stp = subsys(syscall, subcode);
1164 	const char *name = stp->name;	/* may be NULL */
1165 
1166 	if (name == NULL) {		/* manufacture a name */
1167 		(void) sprintf(pri->sys_name, "sys#%d", syscall);
1168 		name = pri->sys_name;
1169 	}
1170 
1171 	return (name);
1172 }
1173 
1174 /*
1175  * Return the name of the signal.
1176  * Return NULL if unknown signal.
1177  */
1178 const char *
1179 rawsigname(private_t *pri, int sig)
1180 {
1181 	/*
1182 	 * The C library function sig2str() omits the leading "SIG".
1183 	 */
1184 	(void) strcpy(pri->raw_sig_name, "SIG");
1185 
1186 	if (sig > 0 && sig2str(sig, pri->raw_sig_name+3) == 0)
1187 		return (pri->raw_sig_name);
1188 	return (NULL);
1189 }
1190 
1191 /*
1192  * Return the name of the signal.
1193  * Manufacture a name for unknown signal.
1194  */
1195 const char *
1196 signame(private_t *pri, int sig)
1197 {
1198 	const char *name = rawsigname(pri, sig);
1199 
1200 	if (name == NULL) {			/* manufacture a name */
1201 		(void) sprintf(pri->sig_name, "SIG#%d", sig);
1202 		name = pri->sig_name;
1203 	}
1204 
1205 	return (name);
1206 }
1207 
1208 /*
1209  * Determine the subcode for this syscall, if any.
1210  */
1211 int
1212 getsubcode(private_t *pri)
1213 {
1214 	const lwpstatus_t *Lsp = pri->lwpstat;
1215 	int syscall = Lsp->pr_syscall;
1216 	int nsysarg = Lsp->pr_nsysarg;
1217 	int subcode = -1;
1218 	int arg0;
1219 
1220 	if (syscall > 0 && nsysarg > 0) {
1221 		arg0 = Lsp->pr_sysarg[0];
1222 		switch (syscall) {
1223 		case SYS_utssys:	/* utssys() */
1224 			if (nsysarg > 2)
1225 				subcode = Lsp->pr_sysarg[2];
1226 			break;
1227 		case SYS_open:		/* open() w/ and w/o O_CREAT */
1228 		case SYS_open64:
1229 			if (nsysarg > 1)
1230 				subcode = (Lsp->pr_sysarg[1] & O_CREAT)? 1 : 0;
1231 			break;
1232 		case SYS_fsat:
1233 			switch (arg0) {
1234 			case 0:  /* openat */
1235 				if (nsysarg > 3)
1236 					subcode =
1237 					    (Lsp->pr_sysarg[3] & O_CREAT) ?
1238 					    0 : NFSATSYSCODE - 2;
1239 				break;
1240 			case 1: /* openat64 */
1241 				if (nsysarg > 3)
1242 					subcode =
1243 					    (Lsp->pr_sysarg[3] & O_CREAT) ?
1244 					    1 : NFSATSYSCODE - 1;
1245 				break;
1246 			case 2:
1247 			case 3:
1248 			case 4:
1249 			case 5:
1250 			case 6:
1251 			case 7:
1252 			case 8:
1253 			case 9:
1254 				subcode = arg0;
1255 			}
1256 			break;
1257 		case SYS_signal:	/* signal() + sigset() family */
1258 			switch (arg0 & ~SIGNO_MASK) {
1259 			default:	subcode = 0;	break;
1260 			case SIGDEFER:	subcode = 1;	break;
1261 			case SIGHOLD:	subcode = 2;	break;
1262 			case SIGRELSE:	subcode = 3;	break;
1263 			case SIGIGNORE:	subcode = 4;	break;
1264 			case SIGPAUSE:	subcode = 5;	break;
1265 			}
1266 			break;
1267 		case SYS_kaio:		/* kaio() */
1268 			subcode = arg0 & ~AIO_POLL_BIT;
1269 			break;
1270 		case SYS_door:		/* doors */
1271 			if (nsysarg > 5)
1272 				subcode = Lsp->pr_sysarg[5];
1273 			break;
1274 		case SYS_lwp_create:	/* lwp_create() */
1275 			subcode =	/* 0 for parent, 1 for child */
1276 			    (Lsp->pr_why == PR_SYSEXIT && Lsp->pr_errno == 0 &&
1277 			    Lsp->pr_rval1 == 0);
1278 			break;
1279 		case SYS_forksys:	/* forksys */
1280 			subcode = arg0;
1281 			if (Lsp->pr_why == PR_SYSEXIT && Lsp->pr_errno == 0 &&
1282 			    pri->Rval2 != 0)	/* this is the child */
1283 				subcode += 3;
1284 			break;
1285 		case SYS_msgsys:	/* msgsys() */
1286 		case SYS_semsys:	/* semsys() */
1287 		case SYS_shmsys:	/* shmsys() */
1288 		case SYS_pgrpsys:	/* pgrpsys() */
1289 		case SYS_sysfs:		/* sysfs() */
1290 		case SYS_sigpending:	/* sigpending()/sigfillset() */
1291 		case SYS_context:	/* [get|set]context() */
1292 		case SYS_hrtsys:	/* hrtsys() */
1293 		case SYS_corectl:	/* corectl() */
1294 		case SYS_pset:		/* pset() */
1295 		case SYS_tasksys:	/* tasks */
1296 		case SYS_privsys:	/* privileges */
1297 		case SYS_exacctsys:	/* exacct */
1298 		case SYS_lwp_park:	/* lwp_park */
1299 		case SYS_lwp_rwlock_sys: /* lwp_rwlock_*() */
1300 		case SYS_sendfilev:	/* sendfilev */
1301 		case SYS_lgrpsys:	/* lgrpsys */
1302 		case SYS_rusagesys:	/* rusagesys */
1303 		case SYS_ucredsys:	/* ucredsys */
1304 		case SYS_zone:		/* zone */
1305 		case SYS_labelsys:	/* labelsys */
1306 		case SYS_rctlsys:	/* rctlsys */
1307 		case SYS_sidsys:	/* sidsys */
1308 			subcode = arg0;
1309 			break;
1310 		case SYS_fcntl:		/* fcntl() */
1311 			if (nsysarg > 2) {
1312 				switch (Lsp->pr_sysarg[1]) {
1313 				default:	subcode = 0; break;
1314 				case F_GETFL:
1315 				case F_GETOWN:
1316 				case F_GETXFL:	subcode = 1; break;
1317 				case F_SETFL:	subcode = 2; break;
1318 				}
1319 			}
1320 			break;
1321 		case SYS_port:		/* portfs */
1322 			subcode = arg0 & PORT_CODE_MASK;
1323 			break;
1324 		}
1325 	}
1326 
1327 	return (subcode);
1328 }
1329 
1330 /*
1331  * Return the maximum number of system calls, counting
1332  * all system calls with subcodes as separate calls.
1333  */
1334 int
1335 maxsyscalls()
1336 {
1337 	return (PRMAXSYS + 1
1338 	    + NOPENCODE - 1
1339 	    + NOPEN64CODE - 1
1340 	    + NSIGCODE - 1
1341 	    + NMSGCODE - 1
1342 	    + NSEMCODE - 1
1343 	    + NSHMCODE - 1
1344 	    + NPIDCODE - 1
1345 	    + NSFSCODE - 1
1346 	    + NUTSCODE - 1
1347 	    + NSGPCODE - 1
1348 	    + NCTXCODE - 1
1349 	    + NHRTCODE - 1
1350 	    + NCORCODE - 1
1351 	    + NAIOCODE - 1
1352 	    + NDOORCODE - 1
1353 	    + NPSETCODE - 1
1354 	    + NLWPCREATECODE - 1
1355 	    + NTASKSYSCODE - 1
1356 	    + NEXACCTSYSCODE - 1
1357 	    + NFSATSYSCODE - 1
1358 	    + NLWPPARKCODE - 1
1359 	    + NLWPRWLOCKCODE - 1
1360 	    + NSENDFILESYSCODE - 1
1361 	    + NLGRPSYSCODE - 1
1362 	    + NRUSAGESYSCODE - 1
1363 	    + NFCNTLCODE - 1
1364 	    + NPRIVSYSCODE - 1
1365 	    + NUCREDSYSCODE - 1
1366 	    + NPORTCODE - 1
1367 	    + NZONECODE - 1
1368 	    + NLABELCODE - 1
1369 	    + NRCTLCODE - 1
1370 	    + NFORKCODE - 1
1371 	    + NSIDSYSCODE - 1);
1372 }
1373 
1374 /*
1375  * Return the number of subcodes for the specified system call number.
1376  */
1377 int
1378 nsubcodes(int syscall)
1379 {
1380 	switch (syscall) {
1381 	case SYS_open:
1382 		return (NOPENCODE);
1383 	case SYS_open64:
1384 		return (NOPEN64CODE);
1385 	case SYS_signal:	/* signal() + sigset() family */
1386 		return (NSIGCODE);
1387 	case SYS_msgsys:	/* msgsys() */
1388 		return (NMSGCODE);
1389 	case SYS_semsys:	/* semsys() */
1390 		return (NSEMCODE);
1391 	case SYS_shmsys:	/* shmsys() */
1392 		return (NSHMCODE);
1393 	case SYS_pgrpsys:	/* pgrpsys() */
1394 		return (NPIDCODE);
1395 	case SYS_utssys:	/* utssys() */
1396 		return (NUTSCODE);
1397 	case SYS_sysfs:		/* sysfs() */
1398 		return (NSFSCODE);
1399 	case SYS_sigpending:	/* sigpending()/sigfillset() */
1400 		return (NSGPCODE);
1401 	case SYS_context:	/* [get|set]context() */
1402 		return (NCTXCODE);
1403 	case SYS_hrtsys:	/* hrtsys() */
1404 		return (NHRTCODE);
1405 	case SYS_corectl:	/* corectl() */
1406 		return (NCORCODE);
1407 	case SYS_kaio:		/* kaio() */
1408 		return (NAIOCODE);
1409 	case SYS_door:		/* doors */
1410 		return (NDOORCODE);
1411 	case SYS_pset:		/* pset() */
1412 		return (NPSETCODE);
1413 	case SYS_lwp_create:	/* lwp_create() */
1414 		return (NLWPCREATECODE);
1415 	case SYS_tasksys:	/* tasks */
1416 		return (NTASKSYSCODE);
1417 	case SYS_exacctsys:	/* exacct */
1418 		return (NEXACCTSYSCODE);
1419 	case SYS_fsat:
1420 		return (NFSATSYSCODE);
1421 	case SYS_privsys:	/* privileges */
1422 		return (NPRIVSYSCODE);
1423 	case SYS_lwp_park:	/* lwp_park */
1424 		return (NLWPPARKCODE);
1425 	case SYS_lwp_rwlock_sys:
1426 		return (NLWPRWLOCKCODE);
1427 	case SYS_sendfilev:	/* sendfilev */
1428 		return (NSENDFILESYSCODE);
1429 	case SYS_lgrpsys:	/* lgrpsys */
1430 		return (NLGRPSYSCODE);
1431 	case SYS_rusagesys:
1432 		return (NRUSAGESYSCODE);
1433 	case SYS_fcntl:
1434 		return (NFCNTLCODE);
1435 	case SYS_ucredsys:
1436 		return (NUCREDSYSCODE);
1437 	case SYS_port:
1438 		return (NPORTCODE);
1439 	case SYS_zone:		/* zone */
1440 		return (NZONECODE);
1441 	case SYS_labelsys:
1442 		return (NLABELCODE);
1443 	case SYS_rctlsys:
1444 		return (NRCTLCODE);
1445 	case SYS_forksys:
1446 		return (NFORKCODE);
1447 	case SYS_sidsys:
1448 		return (NSIDSYSCODE);
1449 	default:
1450 		return (1);
1451 	}
1452 }
1453 
1454 
1455 
1456 /* Socket address families (and protocol families) */
1457 const char * const afcodes[] = {
1458 	"UNSPEC",	/* 0 */
1459 	"UNIX",		/* 1 */
1460 	"INET",		/* 2 */
1461 	"IMPLINK",	/* 3 */
1462 	"PUP",		/* 4 */
1463 	"CHAOS",	/* 5 */
1464 	"NS",		/* 6 */
1465 	"NBS",		/* 7 */
1466 	"ECMA",		/* 8 */
1467 	"DATAKIT",	/* 9 */
1468 	"CCITT",	/* 10 */
1469 	"SNA",		/* 11 */
1470 	"DECnet",	/* 12 */
1471 	"DLI",		/* 13 */
1472 	"LAT",		/* 14 */
1473 	"HYLINK",	/* 15 */
1474 	"APPLETALK",	/* 16 */
1475 	"NIT",		/* 17 */
1476 	"802",		/* 18 */
1477 	"OSI",		/* 19 */
1478 	"X25",		/* 20 */
1479 	"OSINET",	/* 21 */
1480 	"GOSIP",	/* 22 */
1481 	"IPX",		/* 23 */
1482 	"ROUTE",	/* 24 */
1483 	"LINK",		/* 25 */
1484 	"INET6",	/* 26 */
1485 	"KEY",		/* 27 */
1486 	"NCA",		/* 28 */
1487 	"POLICY",	/* 29 */
1488 	"RDS"		/* 30 */
1489 };
1490 #if MAX_AFCODES != 31
1491 #error Need to update address-family table
1492 #endif
1493 
1494 
1495 const char * const socktype_codes[] = {		/* cf socket.h */
1496 	NULL,
1497 	"SOCK_DGRAM",		/* 1 */
1498 	"SOCK_STREAM",		/* 2 */
1499 	NULL,
1500 	"SOCK_RAW",		/* 4 */
1501 	"SOCK_RDM",		/* 5 */
1502 	"SOCK_SEQPACKET"	/* 6 */
1503 };
1504 #if MAX_SOCKTYPES != 7
1505 #error Need to update socket-type table
1506 #endif
1507