xref: /titanic_52/usr/src/cmd/truss/print.c (revision 7c478bd95313f5f23a4c958a745db2134aa03244)
1*7c478bd9Sstevel@tonic-gate /*
2*7c478bd9Sstevel@tonic-gate  * CDDL HEADER START
3*7c478bd9Sstevel@tonic-gate  *
4*7c478bd9Sstevel@tonic-gate  * The contents of this file are subject to the terms of the
5*7c478bd9Sstevel@tonic-gate  * Common Development and Distribution License, Version 1.0 only
6*7c478bd9Sstevel@tonic-gate  * (the "License").  You may not use this file except in compliance
7*7c478bd9Sstevel@tonic-gate  * with the License.
8*7c478bd9Sstevel@tonic-gate  *
9*7c478bd9Sstevel@tonic-gate  * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
10*7c478bd9Sstevel@tonic-gate  * or http://www.opensolaris.org/os/licensing.
11*7c478bd9Sstevel@tonic-gate  * See the License for the specific language governing permissions
12*7c478bd9Sstevel@tonic-gate  * and limitations under the License.
13*7c478bd9Sstevel@tonic-gate  *
14*7c478bd9Sstevel@tonic-gate  * When distributing Covered Code, include this CDDL HEADER in each
15*7c478bd9Sstevel@tonic-gate  * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
16*7c478bd9Sstevel@tonic-gate  * If applicable, add the following below this CDDL HEADER, with the
17*7c478bd9Sstevel@tonic-gate  * fields enclosed by brackets "[]" replaced with your own identifying
18*7c478bd9Sstevel@tonic-gate  * information: Portions Copyright [yyyy] [name of copyright owner]
19*7c478bd9Sstevel@tonic-gate  *
20*7c478bd9Sstevel@tonic-gate  * CDDL HEADER END
21*7c478bd9Sstevel@tonic-gate  */
22*7c478bd9Sstevel@tonic-gate /*
23*7c478bd9Sstevel@tonic-gate  * Copyright 2005 Sun Microsystems, Inc.  All rights reserved.
24*7c478bd9Sstevel@tonic-gate  * Use is subject to license terms.
25*7c478bd9Sstevel@tonic-gate  */
26*7c478bd9Sstevel@tonic-gate 
27*7c478bd9Sstevel@tonic-gate /*	Copyright (c) 1984, 1986, 1987, 1988, 1989 AT&T	*/
28*7c478bd9Sstevel@tonic-gate /*	  All Rights Reserved  	*/
29*7c478bd9Sstevel@tonic-gate 
30*7c478bd9Sstevel@tonic-gate 
31*7c478bd9Sstevel@tonic-gate #pragma ident	"%Z%%M%	%I%	%E% SMI"
32*7c478bd9Sstevel@tonic-gate 
33*7c478bd9Sstevel@tonic-gate #define	_SYSCALL32	/* make 32-bit compat headers visible */
34*7c478bd9Sstevel@tonic-gate 
35*7c478bd9Sstevel@tonic-gate #include <stdio.h>
36*7c478bd9Sstevel@tonic-gate #include <stdlib.h>
37*7c478bd9Sstevel@tonic-gate #include <unistd.h>
38*7c478bd9Sstevel@tonic-gate #include <string.h>
39*7c478bd9Sstevel@tonic-gate #include <signal.h>
40*7c478bd9Sstevel@tonic-gate #include <termio.h>
41*7c478bd9Sstevel@tonic-gate #include <stddef.h>
42*7c478bd9Sstevel@tonic-gate #include <limits.h>
43*7c478bd9Sstevel@tonic-gate #include <ctype.h>
44*7c478bd9Sstevel@tonic-gate #include <sys/types.h>
45*7c478bd9Sstevel@tonic-gate #include <sys/mman.h>
46*7c478bd9Sstevel@tonic-gate #include <sys/resource.h>
47*7c478bd9Sstevel@tonic-gate #include <sys/ulimit.h>
48*7c478bd9Sstevel@tonic-gate #include <sys/utsname.h>
49*7c478bd9Sstevel@tonic-gate #include <sys/kstat.h>
50*7c478bd9Sstevel@tonic-gate #include <sys/modctl.h>
51*7c478bd9Sstevel@tonic-gate #include <sys/acl.h>
52*7c478bd9Sstevel@tonic-gate #include <stropts.h>
53*7c478bd9Sstevel@tonic-gate #include <sys/isa_defs.h>
54*7c478bd9Sstevel@tonic-gate #include <sys/systeminfo.h>
55*7c478bd9Sstevel@tonic-gate #include <sys/cladm.h>
56*7c478bd9Sstevel@tonic-gate #include <sys/lwp.h>
57*7c478bd9Sstevel@tonic-gate #include <bsm/audit.h>
58*7c478bd9Sstevel@tonic-gate #include <libproc.h>
59*7c478bd9Sstevel@tonic-gate #include <priv.h>
60*7c478bd9Sstevel@tonic-gate #include <sys/aio.h>
61*7c478bd9Sstevel@tonic-gate #include <sys/aiocb.h>
62*7c478bd9Sstevel@tonic-gate #include <sys/corectl.h>
63*7c478bd9Sstevel@tonic-gate #include <sys/cpc_impl.h>
64*7c478bd9Sstevel@tonic-gate #include <sys/priocntl.h>
65*7c478bd9Sstevel@tonic-gate #include <sys/tspriocntl.h>
66*7c478bd9Sstevel@tonic-gate #include <sys/iapriocntl.h>
67*7c478bd9Sstevel@tonic-gate #include <sys/rtpriocntl.h>
68*7c478bd9Sstevel@tonic-gate #include <sys/fsspriocntl.h>
69*7c478bd9Sstevel@tonic-gate #include <sys/fxpriocntl.h>
70*7c478bd9Sstevel@tonic-gate #include <netdb.h>
71*7c478bd9Sstevel@tonic-gate #include <nss_dbdefs.h>
72*7c478bd9Sstevel@tonic-gate #include <sys/socketvar.h>
73*7c478bd9Sstevel@tonic-gate #include <netinet/in.h>
74*7c478bd9Sstevel@tonic-gate #include <netinet/tcp.h>
75*7c478bd9Sstevel@tonic-gate #include <netinet/udp.h>
76*7c478bd9Sstevel@tonic-gate #include <netinet/sctp.h>
77*7c478bd9Sstevel@tonic-gate #include <sys/utrap.h>
78*7c478bd9Sstevel@tonic-gate #include <sys/lgrp_user.h>
79*7c478bd9Sstevel@tonic-gate #include <sys/door.h>
80*7c478bd9Sstevel@tonic-gate #include "ramdata.h"
81*7c478bd9Sstevel@tonic-gate #include "print.h"
82*7c478bd9Sstevel@tonic-gate #include "proto.h"
83*7c478bd9Sstevel@tonic-gate #include "systable.h"
84*7c478bd9Sstevel@tonic-gate 
85*7c478bd9Sstevel@tonic-gate void grow(private_t *, int nbyte);
86*7c478bd9Sstevel@tonic-gate 
87*7c478bd9Sstevel@tonic-gate #define	GROW(nb) if (pri->sys_leng + (nb) >= pri->sys_ssize) grow(pri, (nb))
88*7c478bd9Sstevel@tonic-gate 
89*7c478bd9Sstevel@tonic-gate 
90*7c478bd9Sstevel@tonic-gate /*ARGSUSED*/
91*7c478bd9Sstevel@tonic-gate void
92*7c478bd9Sstevel@tonic-gate prt_nov(private_t *pri, int raw, long val)	/* print nothing */
93*7c478bd9Sstevel@tonic-gate {
94*7c478bd9Sstevel@tonic-gate }
95*7c478bd9Sstevel@tonic-gate 
96*7c478bd9Sstevel@tonic-gate /*ARGSUSED*/
97*7c478bd9Sstevel@tonic-gate void
98*7c478bd9Sstevel@tonic-gate prt_dec(private_t *pri, int raw, long val)	/* print as decimal */
99*7c478bd9Sstevel@tonic-gate {
100*7c478bd9Sstevel@tonic-gate 	GROW(24);
101*7c478bd9Sstevel@tonic-gate 	if (data_model == PR_MODEL_ILP32)
102*7c478bd9Sstevel@tonic-gate 		pri->sys_leng += sprintf(pri->sys_string + pri->sys_leng,
103*7c478bd9Sstevel@tonic-gate 			"%d", (int)val);
104*7c478bd9Sstevel@tonic-gate 	else
105*7c478bd9Sstevel@tonic-gate 		pri->sys_leng += sprintf(pri->sys_string + pri->sys_leng,
106*7c478bd9Sstevel@tonic-gate 			"%ld", val);
107*7c478bd9Sstevel@tonic-gate }
108*7c478bd9Sstevel@tonic-gate 
109*7c478bd9Sstevel@tonic-gate /*ARGSUSED*/
110*7c478bd9Sstevel@tonic-gate void
111*7c478bd9Sstevel@tonic-gate prt_uns(private_t *pri, int raw, long val)	/* print as unsigned decimal */
112*7c478bd9Sstevel@tonic-gate {
113*7c478bd9Sstevel@tonic-gate 	GROW(24);
114*7c478bd9Sstevel@tonic-gate 	if (data_model == PR_MODEL_ILP32)
115*7c478bd9Sstevel@tonic-gate 		pri->sys_leng += sprintf(pri->sys_string + pri->sys_leng,
116*7c478bd9Sstevel@tonic-gate 			"%u", (int)val);
117*7c478bd9Sstevel@tonic-gate 	else
118*7c478bd9Sstevel@tonic-gate 		pri->sys_leng += sprintf(pri->sys_string + pri->sys_leng,
119*7c478bd9Sstevel@tonic-gate 			"%lu", val);
120*7c478bd9Sstevel@tonic-gate }
121*7c478bd9Sstevel@tonic-gate 
122*7c478bd9Sstevel@tonic-gate /*ARGSUSED*/
123*7c478bd9Sstevel@tonic-gate void
124*7c478bd9Sstevel@tonic-gate prt_oct(private_t *pri, int raw, long val)	/* print as octal */
125*7c478bd9Sstevel@tonic-gate {
126*7c478bd9Sstevel@tonic-gate 	GROW(24);
127*7c478bd9Sstevel@tonic-gate 	if (data_model == PR_MODEL_ILP32)
128*7c478bd9Sstevel@tonic-gate 		pri->sys_leng += sprintf(pri->sys_string + pri->sys_leng,
129*7c478bd9Sstevel@tonic-gate 			"%#o", (int)val);
130*7c478bd9Sstevel@tonic-gate 	else
131*7c478bd9Sstevel@tonic-gate 		pri->sys_leng += sprintf(pri->sys_string + pri->sys_leng,
132*7c478bd9Sstevel@tonic-gate 			"%#lo", val);
133*7c478bd9Sstevel@tonic-gate }
134*7c478bd9Sstevel@tonic-gate 
135*7c478bd9Sstevel@tonic-gate /*ARGSUSED*/
136*7c478bd9Sstevel@tonic-gate void
137*7c478bd9Sstevel@tonic-gate prt_hex(private_t *pri, int raw, long val)	/* print as hexadecimal */
138*7c478bd9Sstevel@tonic-gate {
139*7c478bd9Sstevel@tonic-gate 	GROW(20);
140*7c478bd9Sstevel@tonic-gate 	if (data_model == PR_MODEL_ILP32)
141*7c478bd9Sstevel@tonic-gate 		pri->sys_leng += sprintf(pri->sys_string + pri->sys_leng,
142*7c478bd9Sstevel@tonic-gate 			"0x%.8X", (int)val);
143*7c478bd9Sstevel@tonic-gate 	else
144*7c478bd9Sstevel@tonic-gate 		pri->sys_leng += sprintf(pri->sys_string + pri->sys_leng,
145*7c478bd9Sstevel@tonic-gate 			"0x%.8lX", val);
146*7c478bd9Sstevel@tonic-gate }
147*7c478bd9Sstevel@tonic-gate 
148*7c478bd9Sstevel@tonic-gate /* print as hexadecimal (half size) */
149*7c478bd9Sstevel@tonic-gate /*ARGSUSED*/
150*7c478bd9Sstevel@tonic-gate void
151*7c478bd9Sstevel@tonic-gate prt_hhx(private_t *pri, int raw, long val)
152*7c478bd9Sstevel@tonic-gate {
153*7c478bd9Sstevel@tonic-gate 	GROW(20);
154*7c478bd9Sstevel@tonic-gate 	if (data_model == PR_MODEL_ILP32)
155*7c478bd9Sstevel@tonic-gate 		pri->sys_leng += sprintf(pri->sys_string + pri->sys_leng,
156*7c478bd9Sstevel@tonic-gate 			"0x%.4X", (int)val);
157*7c478bd9Sstevel@tonic-gate 	else
158*7c478bd9Sstevel@tonic-gate 		pri->sys_leng += sprintf(pri->sys_string + pri->sys_leng,
159*7c478bd9Sstevel@tonic-gate 			"0x%.4lX", val);
160*7c478bd9Sstevel@tonic-gate }
161*7c478bd9Sstevel@tonic-gate 
162*7c478bd9Sstevel@tonic-gate /* print as decimal if small, else hexadecimal */
163*7c478bd9Sstevel@tonic-gate /*ARGSUSED*/
164*7c478bd9Sstevel@tonic-gate void
165*7c478bd9Sstevel@tonic-gate prt_dex(private_t *pri, int raw, long val)
166*7c478bd9Sstevel@tonic-gate {
167*7c478bd9Sstevel@tonic-gate 	if (val & 0xff000000)
168*7c478bd9Sstevel@tonic-gate 		prt_hex(pri, 0, val);
169*7c478bd9Sstevel@tonic-gate 	else
170*7c478bd9Sstevel@tonic-gate 		prt_dec(pri, 0, val);
171*7c478bd9Sstevel@tonic-gate }
172*7c478bd9Sstevel@tonic-gate 
173*7c478bd9Sstevel@tonic-gate /* print long long offset */
174*7c478bd9Sstevel@tonic-gate /*ARGSUSED*/
175*7c478bd9Sstevel@tonic-gate void
176*7c478bd9Sstevel@tonic-gate prt_llo(private_t *pri, int raw, long val1, long val2)
177*7c478bd9Sstevel@tonic-gate {
178*7c478bd9Sstevel@tonic-gate 	int hival;
179*7c478bd9Sstevel@tonic-gate 	int loval;
180*7c478bd9Sstevel@tonic-gate 
181*7c478bd9Sstevel@tonic-gate #ifdef	_LONG_LONG_LTOH
182*7c478bd9Sstevel@tonic-gate 	hival = (int)val2;
183*7c478bd9Sstevel@tonic-gate 	loval = (int)val1;
184*7c478bd9Sstevel@tonic-gate #else
185*7c478bd9Sstevel@tonic-gate 	hival = (int)val1;
186*7c478bd9Sstevel@tonic-gate 	loval = (int)val2;
187*7c478bd9Sstevel@tonic-gate #endif
188*7c478bd9Sstevel@tonic-gate 
189*7c478bd9Sstevel@tonic-gate 	if (hival == 0)
190*7c478bd9Sstevel@tonic-gate 		prt_dex(pri, 0, loval);
191*7c478bd9Sstevel@tonic-gate 	else {
192*7c478bd9Sstevel@tonic-gate 		GROW(18);
193*7c478bd9Sstevel@tonic-gate 		pri->sys_leng +=
194*7c478bd9Sstevel@tonic-gate 			sprintf(pri->sys_string + pri->sys_leng, "0x%.8X%.8X",
195*7c478bd9Sstevel@tonic-gate 			hival, loval);
196*7c478bd9Sstevel@tonic-gate 	}
197*7c478bd9Sstevel@tonic-gate }
198*7c478bd9Sstevel@tonic-gate 
199*7c478bd9Sstevel@tonic-gate void
200*7c478bd9Sstevel@tonic-gate escape_string(private_t *pri, const char *s)
201*7c478bd9Sstevel@tonic-gate {
202*7c478bd9Sstevel@tonic-gate 	/*
203*7c478bd9Sstevel@tonic-gate 	 * We want to avoid outputting unprintable characters that may
204*7c478bd9Sstevel@tonic-gate 	 * destroy the user's terminal.  So we do one pass to find any
205*7c478bd9Sstevel@tonic-gate 	 * unprintable characters, size the array appropriately, and
206*7c478bd9Sstevel@tonic-gate 	 * then walk each character by hand.  Those that are unprintable
207*7c478bd9Sstevel@tonic-gate 	 * are replaced by a hex escape (\xNN).  We also escape quotes for
208*7c478bd9Sstevel@tonic-gate 	 * completeness.
209*7c478bd9Sstevel@tonic-gate 	 */
210*7c478bd9Sstevel@tonic-gate 	int i, unprintable, quotes;
211*7c478bd9Sstevel@tonic-gate 	size_t len = strlen(s);
212*7c478bd9Sstevel@tonic-gate 	for (i = 0, unprintable = 0, quotes = 0; i < len; i++) {
213*7c478bd9Sstevel@tonic-gate 		if (!isprint(s[i]))
214*7c478bd9Sstevel@tonic-gate 			unprintable++;
215*7c478bd9Sstevel@tonic-gate 		if (s[i] == '"')
216*7c478bd9Sstevel@tonic-gate 			quotes++;
217*7c478bd9Sstevel@tonic-gate 	}
218*7c478bd9Sstevel@tonic-gate 
219*7c478bd9Sstevel@tonic-gate 	GROW(len + 3 * unprintable + quotes + 2);
220*7c478bd9Sstevel@tonic-gate 
221*7c478bd9Sstevel@tonic-gate 	pri->sys_string[pri->sys_leng++] = '"';
222*7c478bd9Sstevel@tonic-gate 	for (i = 0; i < len; i++) {
223*7c478bd9Sstevel@tonic-gate 		if (s[i] == '"')
224*7c478bd9Sstevel@tonic-gate 			pri->sys_string[pri->sys_leng++] = '\\';
225*7c478bd9Sstevel@tonic-gate 
226*7c478bd9Sstevel@tonic-gate 		if (isprint(s[i])) {
227*7c478bd9Sstevel@tonic-gate 			pri->sys_string[pri->sys_leng++] = s[i];
228*7c478bd9Sstevel@tonic-gate 		} else {
229*7c478bd9Sstevel@tonic-gate 			pri->sys_leng += sprintf(pri->sys_string +
230*7c478bd9Sstevel@tonic-gate 			    pri->sys_leng, "\\x%02x", s[i]);
231*7c478bd9Sstevel@tonic-gate 		}
232*7c478bd9Sstevel@tonic-gate 	}
233*7c478bd9Sstevel@tonic-gate 	pri->sys_string[pri->sys_leng++] = '"';
234*7c478bd9Sstevel@tonic-gate }
235*7c478bd9Sstevel@tonic-gate 
236*7c478bd9Sstevel@tonic-gate void
237*7c478bd9Sstevel@tonic-gate prt_stg(private_t *pri, int raw, long val)	/* print as string */
238*7c478bd9Sstevel@tonic-gate {
239*7c478bd9Sstevel@tonic-gate 	char *s = raw? NULL : fetchstring(pri, (long)val, PATH_MAX);
240*7c478bd9Sstevel@tonic-gate 
241*7c478bd9Sstevel@tonic-gate 	if (s == NULL)
242*7c478bd9Sstevel@tonic-gate 		prt_hex(pri, 0, val);
243*7c478bd9Sstevel@tonic-gate 	else
244*7c478bd9Sstevel@tonic-gate 		escape_string(pri, s);
245*7c478bd9Sstevel@tonic-gate }
246*7c478bd9Sstevel@tonic-gate 
247*7c478bd9Sstevel@tonic-gate /* print as string returned from syscall */
248*7c478bd9Sstevel@tonic-gate void
249*7c478bd9Sstevel@tonic-gate prt_rst(private_t *pri, int raw, long val)
250*7c478bd9Sstevel@tonic-gate {
251*7c478bd9Sstevel@tonic-gate 	char *s = (raw || pri->Errno)? NULL :
252*7c478bd9Sstevel@tonic-gate 		fetchstring(pri, (long)val, PATH_MAX);
253*7c478bd9Sstevel@tonic-gate 
254*7c478bd9Sstevel@tonic-gate 	if (s == NULL)
255*7c478bd9Sstevel@tonic-gate 		prt_hex(pri, 0, val);
256*7c478bd9Sstevel@tonic-gate 	else {
257*7c478bd9Sstevel@tonic-gate 		GROW((int)strlen(s) + 2);
258*7c478bd9Sstevel@tonic-gate 		pri->sys_leng += snprintf(pri->sys_string + pri->sys_leng,
259*7c478bd9Sstevel@tonic-gate 		    pri->sys_ssize - pri->sys_leng, "\"%s\"", s);
260*7c478bd9Sstevel@tonic-gate 	}
261*7c478bd9Sstevel@tonic-gate }
262*7c478bd9Sstevel@tonic-gate 
263*7c478bd9Sstevel@tonic-gate /* print contents of readlink() buffer */
264*7c478bd9Sstevel@tonic-gate void
265*7c478bd9Sstevel@tonic-gate prt_rlk(private_t *pri, int raw, long val)
266*7c478bd9Sstevel@tonic-gate {
267*7c478bd9Sstevel@tonic-gate 	char *s = (raw || pri->Errno || pri->Rval1 <= 0)? NULL :
268*7c478bd9Sstevel@tonic-gate 		fetchstring(pri, (long)val,
269*7c478bd9Sstevel@tonic-gate 			(pri->Rval1 > PATH_MAX)? PATH_MAX : (int)pri->Rval1);
270*7c478bd9Sstevel@tonic-gate 
271*7c478bd9Sstevel@tonic-gate 	if (s == NULL)
272*7c478bd9Sstevel@tonic-gate 		prt_hex(pri, 0, val);
273*7c478bd9Sstevel@tonic-gate 	else {
274*7c478bd9Sstevel@tonic-gate 		GROW((int)strlen(s) + 2);
275*7c478bd9Sstevel@tonic-gate 		pri->sys_leng += snprintf(pri->sys_string + pri->sys_leng,
276*7c478bd9Sstevel@tonic-gate 		    pri->sys_ssize - pri->sys_leng, "\"%s\"", s);
277*7c478bd9Sstevel@tonic-gate 	}
278*7c478bd9Sstevel@tonic-gate }
279*7c478bd9Sstevel@tonic-gate 
280*7c478bd9Sstevel@tonic-gate void
281*7c478bd9Sstevel@tonic-gate prt_ioc(private_t *pri, int raw, long val)	/* print ioctl code */
282*7c478bd9Sstevel@tonic-gate {
283*7c478bd9Sstevel@tonic-gate 	const char *s = raw? NULL : ioctlname(pri, (int)val);
284*7c478bd9Sstevel@tonic-gate 
285*7c478bd9Sstevel@tonic-gate 	if (s == NULL)
286*7c478bd9Sstevel@tonic-gate 		prt_hex(pri, 0, val);
287*7c478bd9Sstevel@tonic-gate 	else
288*7c478bd9Sstevel@tonic-gate 		outstring(pri, s);
289*7c478bd9Sstevel@tonic-gate }
290*7c478bd9Sstevel@tonic-gate 
291*7c478bd9Sstevel@tonic-gate void
292*7c478bd9Sstevel@tonic-gate prt_ioa(private_t *pri, int raw, long val)	/* print ioctl argument */
293*7c478bd9Sstevel@tonic-gate {
294*7c478bd9Sstevel@tonic-gate 	const char *s;
295*7c478bd9Sstevel@tonic-gate 
296*7c478bd9Sstevel@tonic-gate 	/* cheating -- look at the ioctl() code */
297*7c478bd9Sstevel@tonic-gate 	switch (pri->sys_args[1]) {
298*7c478bd9Sstevel@tonic-gate 
299*7c478bd9Sstevel@tonic-gate 	/* kstat ioctl()s */
300*7c478bd9Sstevel@tonic-gate 	case KSTAT_IOC_READ:
301*7c478bd9Sstevel@tonic-gate 	case KSTAT_IOC_WRITE:
302*7c478bd9Sstevel@tonic-gate #ifdef _LP64
303*7c478bd9Sstevel@tonic-gate 		if (data_model == PR_MODEL_ILP32)
304*7c478bd9Sstevel@tonic-gate 			prt_stg(pri, raw,
305*7c478bd9Sstevel@tonic-gate 				val + offsetof(kstat32_t, ks_name[0]));
306*7c478bd9Sstevel@tonic-gate 		else
307*7c478bd9Sstevel@tonic-gate #endif
308*7c478bd9Sstevel@tonic-gate 			prt_stg(pri, raw,
309*7c478bd9Sstevel@tonic-gate 				val + offsetof(kstat_t, ks_name[0]));
310*7c478bd9Sstevel@tonic-gate 		break;
311*7c478bd9Sstevel@tonic-gate 
312*7c478bd9Sstevel@tonic-gate 	/* streams ioctl()s */
313*7c478bd9Sstevel@tonic-gate 	case I_LOOK:
314*7c478bd9Sstevel@tonic-gate 		prt_rst(pri, raw, val);
315*7c478bd9Sstevel@tonic-gate 		break;
316*7c478bd9Sstevel@tonic-gate 	case I_PUSH:
317*7c478bd9Sstevel@tonic-gate 	case I_FIND:
318*7c478bd9Sstevel@tonic-gate 		prt_stg(pri, raw, val);
319*7c478bd9Sstevel@tonic-gate 		break;
320*7c478bd9Sstevel@tonic-gate 	case I_LINK:
321*7c478bd9Sstevel@tonic-gate 	case I_UNLINK:
322*7c478bd9Sstevel@tonic-gate 	case I_SENDFD:
323*7c478bd9Sstevel@tonic-gate 		prt_dec(pri, 0, val);
324*7c478bd9Sstevel@tonic-gate 		break;
325*7c478bd9Sstevel@tonic-gate 	case I_SRDOPT:
326*7c478bd9Sstevel@tonic-gate 		if (raw || (s = strrdopt(val)) == NULL)
327*7c478bd9Sstevel@tonic-gate 			prt_dec(pri, 0, val);
328*7c478bd9Sstevel@tonic-gate 		else
329*7c478bd9Sstevel@tonic-gate 			outstring(pri, s);
330*7c478bd9Sstevel@tonic-gate 		break;
331*7c478bd9Sstevel@tonic-gate 	case I_SETSIG:
332*7c478bd9Sstevel@tonic-gate 		if (raw || (s = strevents(pri, val)) == NULL)
333*7c478bd9Sstevel@tonic-gate 			prt_hex(pri, 0, val);
334*7c478bd9Sstevel@tonic-gate 		else
335*7c478bd9Sstevel@tonic-gate 			outstring(pri, s);
336*7c478bd9Sstevel@tonic-gate 		break;
337*7c478bd9Sstevel@tonic-gate 	case I_FLUSH:
338*7c478bd9Sstevel@tonic-gate 		if (raw || (s = strflush(val)) == NULL)
339*7c478bd9Sstevel@tonic-gate 			prt_dec(pri, 0, val);
340*7c478bd9Sstevel@tonic-gate 		else
341*7c478bd9Sstevel@tonic-gate 			outstring(pri, s);
342*7c478bd9Sstevel@tonic-gate 		break;
343*7c478bd9Sstevel@tonic-gate 
344*7c478bd9Sstevel@tonic-gate 	/* tty ioctl()s */
345*7c478bd9Sstevel@tonic-gate 	case TCSBRK:
346*7c478bd9Sstevel@tonic-gate 	case TCXONC:
347*7c478bd9Sstevel@tonic-gate 	case TCFLSH:
348*7c478bd9Sstevel@tonic-gate 	case TCDSET:
349*7c478bd9Sstevel@tonic-gate 		prt_dec(pri, 0, val);
350*7c478bd9Sstevel@tonic-gate 		break;
351*7c478bd9Sstevel@tonic-gate 
352*7c478bd9Sstevel@tonic-gate 	default:
353*7c478bd9Sstevel@tonic-gate 		prt_hex(pri, 0, val);
354*7c478bd9Sstevel@tonic-gate 		break;
355*7c478bd9Sstevel@tonic-gate 	}
356*7c478bd9Sstevel@tonic-gate }
357*7c478bd9Sstevel@tonic-gate 
358*7c478bd9Sstevel@tonic-gate void
359*7c478bd9Sstevel@tonic-gate prt_fcn(private_t *pri, int raw, long val)	/* print fcntl code */
360*7c478bd9Sstevel@tonic-gate {
361*7c478bd9Sstevel@tonic-gate 	const char *s = raw? NULL : fcntlname(val);
362*7c478bd9Sstevel@tonic-gate 
363*7c478bd9Sstevel@tonic-gate 	if (s == NULL)
364*7c478bd9Sstevel@tonic-gate 		prt_dec(pri, 0, val);
365*7c478bd9Sstevel@tonic-gate 	else
366*7c478bd9Sstevel@tonic-gate 		outstring(pri, s);
367*7c478bd9Sstevel@tonic-gate }
368*7c478bd9Sstevel@tonic-gate 
369*7c478bd9Sstevel@tonic-gate void
370*7c478bd9Sstevel@tonic-gate prt_s86(private_t *pri, int raw, long val)	/* print sysi86 code */
371*7c478bd9Sstevel@tonic-gate {
372*7c478bd9Sstevel@tonic-gate 
373*7c478bd9Sstevel@tonic-gate 	const char *s = raw? NULL : si86name(val);
374*7c478bd9Sstevel@tonic-gate 
375*7c478bd9Sstevel@tonic-gate 	if (s == NULL)
376*7c478bd9Sstevel@tonic-gate 		prt_dec(pri, 0, val);
377*7c478bd9Sstevel@tonic-gate 	else
378*7c478bd9Sstevel@tonic-gate 		outstring(pri, s);
379*7c478bd9Sstevel@tonic-gate }
380*7c478bd9Sstevel@tonic-gate 
381*7c478bd9Sstevel@tonic-gate void
382*7c478bd9Sstevel@tonic-gate prt_uts(private_t *pri, int raw, long val)	/* print utssys code */
383*7c478bd9Sstevel@tonic-gate {
384*7c478bd9Sstevel@tonic-gate 	const char *s = raw? NULL : utscode(val);
385*7c478bd9Sstevel@tonic-gate 
386*7c478bd9Sstevel@tonic-gate 	if (s == NULL)
387*7c478bd9Sstevel@tonic-gate 		prt_dec(pri, 0, val);
388*7c478bd9Sstevel@tonic-gate 	else
389*7c478bd9Sstevel@tonic-gate 		outstring(pri, s);
390*7c478bd9Sstevel@tonic-gate }
391*7c478bd9Sstevel@tonic-gate 
392*7c478bd9Sstevel@tonic-gate void
393*7c478bd9Sstevel@tonic-gate prt_msc(private_t *pri, int raw, long val)	/* print msgsys command */
394*7c478bd9Sstevel@tonic-gate {
395*7c478bd9Sstevel@tonic-gate 	const char *s = raw? NULL : msgcmd(val);
396*7c478bd9Sstevel@tonic-gate 
397*7c478bd9Sstevel@tonic-gate 	if (s == NULL)
398*7c478bd9Sstevel@tonic-gate 		prt_dec(pri, 0, val);
399*7c478bd9Sstevel@tonic-gate 	else
400*7c478bd9Sstevel@tonic-gate 		outstring(pri, s);
401*7c478bd9Sstevel@tonic-gate }
402*7c478bd9Sstevel@tonic-gate 
403*7c478bd9Sstevel@tonic-gate void
404*7c478bd9Sstevel@tonic-gate prt_msf(private_t *pri, int raw, long val)	/* print msgsys flags */
405*7c478bd9Sstevel@tonic-gate {
406*7c478bd9Sstevel@tonic-gate 	const char *s = raw? NULL : msgflags(pri, (int)val);
407*7c478bd9Sstevel@tonic-gate 
408*7c478bd9Sstevel@tonic-gate 	if (s == NULL)
409*7c478bd9Sstevel@tonic-gate 		prt_oct(pri, 0, val);
410*7c478bd9Sstevel@tonic-gate 	else
411*7c478bd9Sstevel@tonic-gate 		outstring(pri, s);
412*7c478bd9Sstevel@tonic-gate }
413*7c478bd9Sstevel@tonic-gate 
414*7c478bd9Sstevel@tonic-gate void
415*7c478bd9Sstevel@tonic-gate prt_smc(private_t *pri, int raw, long val)	/* print semsys command */
416*7c478bd9Sstevel@tonic-gate {
417*7c478bd9Sstevel@tonic-gate 	const char *s = raw? NULL : semcmd(val);
418*7c478bd9Sstevel@tonic-gate 
419*7c478bd9Sstevel@tonic-gate 	if (s == NULL)
420*7c478bd9Sstevel@tonic-gate 		prt_dec(pri, 0, val);
421*7c478bd9Sstevel@tonic-gate 	else
422*7c478bd9Sstevel@tonic-gate 		outstring(pri, s);
423*7c478bd9Sstevel@tonic-gate }
424*7c478bd9Sstevel@tonic-gate 
425*7c478bd9Sstevel@tonic-gate void
426*7c478bd9Sstevel@tonic-gate prt_sef(private_t *pri, int raw, long val)	/* print semsys flags */
427*7c478bd9Sstevel@tonic-gate {
428*7c478bd9Sstevel@tonic-gate 	const char *s = raw? NULL : semflags(pri, (int)val);
429*7c478bd9Sstevel@tonic-gate 
430*7c478bd9Sstevel@tonic-gate 	if (s == NULL)
431*7c478bd9Sstevel@tonic-gate 		prt_oct(pri, 0, val);
432*7c478bd9Sstevel@tonic-gate 	else
433*7c478bd9Sstevel@tonic-gate 		outstring(pri, s);
434*7c478bd9Sstevel@tonic-gate }
435*7c478bd9Sstevel@tonic-gate 
436*7c478bd9Sstevel@tonic-gate void
437*7c478bd9Sstevel@tonic-gate prt_shc(private_t *pri, int raw, long val)	/* print shmsys command */
438*7c478bd9Sstevel@tonic-gate {
439*7c478bd9Sstevel@tonic-gate 	const char *s = raw? NULL : shmcmd(val);
440*7c478bd9Sstevel@tonic-gate 
441*7c478bd9Sstevel@tonic-gate 	if (s == NULL)
442*7c478bd9Sstevel@tonic-gate 		prt_dec(pri, 0, val);
443*7c478bd9Sstevel@tonic-gate 	else
444*7c478bd9Sstevel@tonic-gate 		outstring(pri, s);
445*7c478bd9Sstevel@tonic-gate }
446*7c478bd9Sstevel@tonic-gate 
447*7c478bd9Sstevel@tonic-gate void
448*7c478bd9Sstevel@tonic-gate prt_shf(private_t *pri, int raw, long val)	/* print shmsys flags */
449*7c478bd9Sstevel@tonic-gate {
450*7c478bd9Sstevel@tonic-gate 	const char *s = raw? NULL : shmflags(pri, (int)val);
451*7c478bd9Sstevel@tonic-gate 
452*7c478bd9Sstevel@tonic-gate 	if (s == NULL)
453*7c478bd9Sstevel@tonic-gate 		prt_oct(pri, 0, val);
454*7c478bd9Sstevel@tonic-gate 	else
455*7c478bd9Sstevel@tonic-gate 		outstring(pri, s);
456*7c478bd9Sstevel@tonic-gate }
457*7c478bd9Sstevel@tonic-gate 
458*7c478bd9Sstevel@tonic-gate void
459*7c478bd9Sstevel@tonic-gate prt_sfs(private_t *pri, int raw, long val)	/* print sysfs code */
460*7c478bd9Sstevel@tonic-gate {
461*7c478bd9Sstevel@tonic-gate 	const char *s = raw? NULL : sfsname(val);
462*7c478bd9Sstevel@tonic-gate 
463*7c478bd9Sstevel@tonic-gate 	if (s == NULL)
464*7c478bd9Sstevel@tonic-gate 		prt_dec(pri, 0, val);
465*7c478bd9Sstevel@tonic-gate 	else
466*7c478bd9Sstevel@tonic-gate 		outstring(pri, s);
467*7c478bd9Sstevel@tonic-gate }
468*7c478bd9Sstevel@tonic-gate 
469*7c478bd9Sstevel@tonic-gate void
470*7c478bd9Sstevel@tonic-gate prt_opn(private_t *pri, int raw, long val)	/* print open code */
471*7c478bd9Sstevel@tonic-gate {
472*7c478bd9Sstevel@tonic-gate 	const char *s = raw? NULL : openarg(pri, val);
473*7c478bd9Sstevel@tonic-gate 
474*7c478bd9Sstevel@tonic-gate 	if (s == NULL)
475*7c478bd9Sstevel@tonic-gate 		prt_oct(pri, 0, val);
476*7c478bd9Sstevel@tonic-gate 	else
477*7c478bd9Sstevel@tonic-gate 		outstring(pri, s);
478*7c478bd9Sstevel@tonic-gate }
479*7c478bd9Sstevel@tonic-gate 
480*7c478bd9Sstevel@tonic-gate void
481*7c478bd9Sstevel@tonic-gate prt_sig(private_t *pri, int raw, long val) /* print signal name plus flags */
482*7c478bd9Sstevel@tonic-gate {
483*7c478bd9Sstevel@tonic-gate 	const char *s = raw? NULL : sigarg(pri, (int)val);
484*7c478bd9Sstevel@tonic-gate 
485*7c478bd9Sstevel@tonic-gate 	if (s == NULL)
486*7c478bd9Sstevel@tonic-gate 		prt_hex(pri, 0, val);
487*7c478bd9Sstevel@tonic-gate 	else
488*7c478bd9Sstevel@tonic-gate 		outstring(pri, s);
489*7c478bd9Sstevel@tonic-gate }
490*7c478bd9Sstevel@tonic-gate 
491*7c478bd9Sstevel@tonic-gate /* print signal name, masked with SIGNO_MASK */
492*7c478bd9Sstevel@tonic-gate void
493*7c478bd9Sstevel@tonic-gate prt_six(private_t *pri, int raw, long val)
494*7c478bd9Sstevel@tonic-gate {
495*7c478bd9Sstevel@tonic-gate 	const char *s = raw? NULL : sigarg(pri, (int)val & SIGNO_MASK);
496*7c478bd9Sstevel@tonic-gate 
497*7c478bd9Sstevel@tonic-gate 	if (s == NULL)
498*7c478bd9Sstevel@tonic-gate 		prt_hex(pri, 0, val);
499*7c478bd9Sstevel@tonic-gate 	else
500*7c478bd9Sstevel@tonic-gate 		outstring(pri, s);
501*7c478bd9Sstevel@tonic-gate }
502*7c478bd9Sstevel@tonic-gate 
503*7c478bd9Sstevel@tonic-gate void
504*7c478bd9Sstevel@tonic-gate prt_act(private_t *pri, int raw, long val)	/* print signal action value */
505*7c478bd9Sstevel@tonic-gate {
506*7c478bd9Sstevel@tonic-gate 	const char *s;
507*7c478bd9Sstevel@tonic-gate 
508*7c478bd9Sstevel@tonic-gate 	if (raw)
509*7c478bd9Sstevel@tonic-gate 		s = NULL;
510*7c478bd9Sstevel@tonic-gate 	else if (val == (int)SIG_DFL)
511*7c478bd9Sstevel@tonic-gate 		s = "SIG_DFL";
512*7c478bd9Sstevel@tonic-gate 	else if (val == (int)SIG_IGN)
513*7c478bd9Sstevel@tonic-gate 		s = "SIG_IGN";
514*7c478bd9Sstevel@tonic-gate 	else if (val == (int)SIG_HOLD)
515*7c478bd9Sstevel@tonic-gate 		s = "SIG_HOLD";
516*7c478bd9Sstevel@tonic-gate 	else
517*7c478bd9Sstevel@tonic-gate 		s = NULL;
518*7c478bd9Sstevel@tonic-gate 
519*7c478bd9Sstevel@tonic-gate 	if (s == NULL)
520*7c478bd9Sstevel@tonic-gate 		prt_hex(pri, 0, val);
521*7c478bd9Sstevel@tonic-gate 	else
522*7c478bd9Sstevel@tonic-gate 		outstring(pri, s);
523*7c478bd9Sstevel@tonic-gate }
524*7c478bd9Sstevel@tonic-gate 
525*7c478bd9Sstevel@tonic-gate void
526*7c478bd9Sstevel@tonic-gate prt_smf(private_t *pri, int raw, long val) /* print streams message flags */
527*7c478bd9Sstevel@tonic-gate {
528*7c478bd9Sstevel@tonic-gate 	switch (val) {
529*7c478bd9Sstevel@tonic-gate 	case 0:
530*7c478bd9Sstevel@tonic-gate 		prt_dec(pri, 0, val);
531*7c478bd9Sstevel@tonic-gate 		break;
532*7c478bd9Sstevel@tonic-gate 	case RS_HIPRI:
533*7c478bd9Sstevel@tonic-gate 		if (raw)
534*7c478bd9Sstevel@tonic-gate 			prt_hhx(pri, 0, val);
535*7c478bd9Sstevel@tonic-gate 		else
536*7c478bd9Sstevel@tonic-gate 			outstring(pri, "RS_HIPRI");
537*7c478bd9Sstevel@tonic-gate 		break;
538*7c478bd9Sstevel@tonic-gate 	default:
539*7c478bd9Sstevel@tonic-gate 		prt_hhx(pri, 0, val);
540*7c478bd9Sstevel@tonic-gate 		break;
541*7c478bd9Sstevel@tonic-gate 	}
542*7c478bd9Sstevel@tonic-gate }
543*7c478bd9Sstevel@tonic-gate 
544*7c478bd9Sstevel@tonic-gate void
545*7c478bd9Sstevel@tonic-gate prt_plk(private_t *pri, int raw, long val)	/* print plock code */
546*7c478bd9Sstevel@tonic-gate {
547*7c478bd9Sstevel@tonic-gate 	const char *s = raw? NULL : plockname(val);
548*7c478bd9Sstevel@tonic-gate 
549*7c478bd9Sstevel@tonic-gate 	if (s == NULL)
550*7c478bd9Sstevel@tonic-gate 		prt_dec(pri, 0, val);
551*7c478bd9Sstevel@tonic-gate 	else
552*7c478bd9Sstevel@tonic-gate 		outstring(pri, s);
553*7c478bd9Sstevel@tonic-gate }
554*7c478bd9Sstevel@tonic-gate 
555*7c478bd9Sstevel@tonic-gate void
556*7c478bd9Sstevel@tonic-gate prt_mtf(private_t *pri, int raw, long val)	/* print mount flags */
557*7c478bd9Sstevel@tonic-gate {
558*7c478bd9Sstevel@tonic-gate 	const char *s = raw? NULL : mountflags(pri, val);
559*7c478bd9Sstevel@tonic-gate 
560*7c478bd9Sstevel@tonic-gate 	if (s == NULL)
561*7c478bd9Sstevel@tonic-gate 		prt_hex(pri, 0, val);
562*7c478bd9Sstevel@tonic-gate 	else
563*7c478bd9Sstevel@tonic-gate 		outstring(pri, s);
564*7c478bd9Sstevel@tonic-gate }
565*7c478bd9Sstevel@tonic-gate 
566*7c478bd9Sstevel@tonic-gate void
567*7c478bd9Sstevel@tonic-gate prt_mft(private_t *pri, int raw, long val) /* print mount file system type */
568*7c478bd9Sstevel@tonic-gate {
569*7c478bd9Sstevel@tonic-gate 	if (val >= 0 && val < 256)
570*7c478bd9Sstevel@tonic-gate 		prt_dec(pri, 0, val);
571*7c478bd9Sstevel@tonic-gate 	else if (raw)
572*7c478bd9Sstevel@tonic-gate 		prt_hex(pri, 0, val);
573*7c478bd9Sstevel@tonic-gate 	else
574*7c478bd9Sstevel@tonic-gate 		prt_stg(pri, raw, val);
575*7c478bd9Sstevel@tonic-gate }
576*7c478bd9Sstevel@tonic-gate 
577*7c478bd9Sstevel@tonic-gate #define	ISREAD(code) \
578*7c478bd9Sstevel@tonic-gate 	((code) == SYS_read || (code) == SYS_pread || (code) == SYS_pread64 || \
579*7c478bd9Sstevel@tonic-gate 	(code) == SYS_recv || (code) == SYS_recvfrom)
580*7c478bd9Sstevel@tonic-gate #define	ISWRITE(code) \
581*7c478bd9Sstevel@tonic-gate 	((code) == SYS_write || (code) == SYS_pwrite || \
582*7c478bd9Sstevel@tonic-gate 	(code) == SYS_pwrite64 || (code) == SYS_send || (code) == SYS_sendto)
583*7c478bd9Sstevel@tonic-gate 
584*7c478bd9Sstevel@tonic-gate /* print contents of read() or write() I/O buffer */
585*7c478bd9Sstevel@tonic-gate void
586*7c478bd9Sstevel@tonic-gate prt_iob(private_t *pri, int raw, long val)
587*7c478bd9Sstevel@tonic-gate {
588*7c478bd9Sstevel@tonic-gate 	const lwpstatus_t *Lsp = pri->lwpstat;
589*7c478bd9Sstevel@tonic-gate 	int syscall = Lsp->pr_what;
590*7c478bd9Sstevel@tonic-gate 	int fdp1 = pri->sys_args[0] + 1;
591*7c478bd9Sstevel@tonic-gate 	ssize_t nbyte = ISWRITE(syscall)? pri->sys_args[2] :
592*7c478bd9Sstevel@tonic-gate 		(pri->Errno? 0 : pri->Rval1);
593*7c478bd9Sstevel@tonic-gate 	int elsewhere = FALSE;		/* TRUE iff dumped elsewhere */
594*7c478bd9Sstevel@tonic-gate 	char buffer[IOBSIZE];
595*7c478bd9Sstevel@tonic-gate 
596*7c478bd9Sstevel@tonic-gate 	pri->iob_buf[0] = '\0';
597*7c478bd9Sstevel@tonic-gate 
598*7c478bd9Sstevel@tonic-gate 	if (Lsp->pr_why == PR_SYSEXIT && nbyte > IOBSIZE) {
599*7c478bd9Sstevel@tonic-gate 		if (ISREAD(syscall))
600*7c478bd9Sstevel@tonic-gate 			elsewhere = prismember(&readfd, fdp1);
601*7c478bd9Sstevel@tonic-gate 		else
602*7c478bd9Sstevel@tonic-gate 			elsewhere = prismember(&writefd, fdp1);
603*7c478bd9Sstevel@tonic-gate 	}
604*7c478bd9Sstevel@tonic-gate 
605*7c478bd9Sstevel@tonic-gate 	if (nbyte <= 0 || elsewhere)
606*7c478bd9Sstevel@tonic-gate 		prt_hex(pri, 0, val);
607*7c478bd9Sstevel@tonic-gate 	else {
608*7c478bd9Sstevel@tonic-gate 		int nb = nbyte > IOBSIZE? IOBSIZE : (int)nbyte;
609*7c478bd9Sstevel@tonic-gate 
610*7c478bd9Sstevel@tonic-gate 		if (Pread(Proc, buffer, (size_t)nb, (long)val) != nb)
611*7c478bd9Sstevel@tonic-gate 			prt_hex(pri, 0, val);
612*7c478bd9Sstevel@tonic-gate 		else {
613*7c478bd9Sstevel@tonic-gate 			pri->iob_buf[0] = '"';
614*7c478bd9Sstevel@tonic-gate 			showbytes(buffer, nb, pri->iob_buf + 1);
615*7c478bd9Sstevel@tonic-gate 			(void) strlcat(pri->iob_buf,
616*7c478bd9Sstevel@tonic-gate 				(nb == nbyte)?
617*7c478bd9Sstevel@tonic-gate 				    (const char *)"\"" : (const char *)"\"..",
618*7c478bd9Sstevel@tonic-gate 				sizeof (pri->iob_buf));
619*7c478bd9Sstevel@tonic-gate 			if (raw)
620*7c478bd9Sstevel@tonic-gate 				prt_hex(pri, 0, val);
621*7c478bd9Sstevel@tonic-gate 			else
622*7c478bd9Sstevel@tonic-gate 				outstring(pri, pri->iob_buf);
623*7c478bd9Sstevel@tonic-gate 		}
624*7c478bd9Sstevel@tonic-gate 	}
625*7c478bd9Sstevel@tonic-gate }
626*7c478bd9Sstevel@tonic-gate #undef	ISREAD
627*7c478bd9Sstevel@tonic-gate #undef	ISWRITE
628*7c478bd9Sstevel@tonic-gate 
629*7c478bd9Sstevel@tonic-gate void
630*7c478bd9Sstevel@tonic-gate prt_idt(private_t *pri, int raw, long val) /* print idtype_t, waitid() arg */
631*7c478bd9Sstevel@tonic-gate {
632*7c478bd9Sstevel@tonic-gate 	const char *s = raw? NULL : idtype_enum(pri, val);
633*7c478bd9Sstevel@tonic-gate 
634*7c478bd9Sstevel@tonic-gate 	if (s == NULL)
635*7c478bd9Sstevel@tonic-gate 		prt_dec(pri, 0, val);
636*7c478bd9Sstevel@tonic-gate 	else
637*7c478bd9Sstevel@tonic-gate 		outstring(pri, s);
638*7c478bd9Sstevel@tonic-gate }
639*7c478bd9Sstevel@tonic-gate 
640*7c478bd9Sstevel@tonic-gate void
641*7c478bd9Sstevel@tonic-gate prt_wop(private_t *pri, int raw, long val)	/* print waitid() options */
642*7c478bd9Sstevel@tonic-gate {
643*7c478bd9Sstevel@tonic-gate 	const char *s = raw? NULL : woptions(pri, (int)val);
644*7c478bd9Sstevel@tonic-gate 
645*7c478bd9Sstevel@tonic-gate 	if (s == NULL)
646*7c478bd9Sstevel@tonic-gate 		prt_oct(pri, 0, val);
647*7c478bd9Sstevel@tonic-gate 	else
648*7c478bd9Sstevel@tonic-gate 		outstring(pri, s);
649*7c478bd9Sstevel@tonic-gate }
650*7c478bd9Sstevel@tonic-gate 
651*7c478bd9Sstevel@tonic-gate void
652*7c478bd9Sstevel@tonic-gate prt_whn(private_t *pri, int raw, long val) /* print lseek() whence argument */
653*7c478bd9Sstevel@tonic-gate {
654*7c478bd9Sstevel@tonic-gate 	const char *s = raw? NULL : whencearg(val);
655*7c478bd9Sstevel@tonic-gate 
656*7c478bd9Sstevel@tonic-gate 	if (s == NULL)
657*7c478bd9Sstevel@tonic-gate 		prt_dec(pri, 0, val);
658*7c478bd9Sstevel@tonic-gate 	else
659*7c478bd9Sstevel@tonic-gate 		outstring(pri, s);
660*7c478bd9Sstevel@tonic-gate }
661*7c478bd9Sstevel@tonic-gate 
662*7c478bd9Sstevel@tonic-gate /*ARGSUSED*/
663*7c478bd9Sstevel@tonic-gate void
664*7c478bd9Sstevel@tonic-gate prt_spm(private_t *pri, int raw, long val)	/* print sigprocmask argument */
665*7c478bd9Sstevel@tonic-gate {
666*7c478bd9Sstevel@tonic-gate 	const char *s = NULL;
667*7c478bd9Sstevel@tonic-gate 
668*7c478bd9Sstevel@tonic-gate 	if (!raw) {
669*7c478bd9Sstevel@tonic-gate 		switch (val) {
670*7c478bd9Sstevel@tonic-gate 		case SIG_BLOCK:		s = "SIG_BLOCK";	break;
671*7c478bd9Sstevel@tonic-gate 		case SIG_UNBLOCK:	s = "SIG_UNBLOCK";	break;
672*7c478bd9Sstevel@tonic-gate 		case SIG_SETMASK:	s = "SIG_SETMASK";	break;
673*7c478bd9Sstevel@tonic-gate 		}
674*7c478bd9Sstevel@tonic-gate 	}
675*7c478bd9Sstevel@tonic-gate 
676*7c478bd9Sstevel@tonic-gate 	if (s == NULL)
677*7c478bd9Sstevel@tonic-gate 		prt_dec(pri, 0, val);
678*7c478bd9Sstevel@tonic-gate 	else
679*7c478bd9Sstevel@tonic-gate 		outstring(pri, s);
680*7c478bd9Sstevel@tonic-gate }
681*7c478bd9Sstevel@tonic-gate 
682*7c478bd9Sstevel@tonic-gate const char *
683*7c478bd9Sstevel@tonic-gate mmap_protect(private_t *pri, long arg)
684*7c478bd9Sstevel@tonic-gate {
685*7c478bd9Sstevel@tonic-gate 	char *str = pri->code_buf;
686*7c478bd9Sstevel@tonic-gate 
687*7c478bd9Sstevel@tonic-gate 	if (arg & ~(PROT_READ|PROT_WRITE|PROT_EXEC))
688*7c478bd9Sstevel@tonic-gate 		return ((char *)NULL);
689*7c478bd9Sstevel@tonic-gate 
690*7c478bd9Sstevel@tonic-gate 	if (arg == PROT_NONE)
691*7c478bd9Sstevel@tonic-gate 		return ("PROT_NONE");
692*7c478bd9Sstevel@tonic-gate 
693*7c478bd9Sstevel@tonic-gate 	*str = '\0';
694*7c478bd9Sstevel@tonic-gate 	if (arg & PROT_READ)
695*7c478bd9Sstevel@tonic-gate 		(void) strlcat(str, "|PROT_READ", sizeof (pri->code_buf));
696*7c478bd9Sstevel@tonic-gate 	if (arg & PROT_WRITE)
697*7c478bd9Sstevel@tonic-gate 		(void) strlcat(str, "|PROT_WRITE", sizeof (pri->code_buf));
698*7c478bd9Sstevel@tonic-gate 	if (arg & PROT_EXEC)
699*7c478bd9Sstevel@tonic-gate 		(void) strlcat(str, "|PROT_EXEC", sizeof (pri->code_buf));
700*7c478bd9Sstevel@tonic-gate 	return ((const char *)(str + 1));
701*7c478bd9Sstevel@tonic-gate }
702*7c478bd9Sstevel@tonic-gate 
703*7c478bd9Sstevel@tonic-gate const char *
704*7c478bd9Sstevel@tonic-gate mmap_type(private_t *pri, long arg)
705*7c478bd9Sstevel@tonic-gate {
706*7c478bd9Sstevel@tonic-gate 	char *str = pri->code_buf;
707*7c478bd9Sstevel@tonic-gate 	size_t used;
708*7c478bd9Sstevel@tonic-gate 
709*7c478bd9Sstevel@tonic-gate #define	CBSIZE	sizeof (pri->code_buf)
710*7c478bd9Sstevel@tonic-gate 	switch (arg & MAP_TYPE) {
711*7c478bd9Sstevel@tonic-gate 	case MAP_SHARED:
712*7c478bd9Sstevel@tonic-gate 		used = strlcpy(str, "MAP_SHARED", CBSIZE);
713*7c478bd9Sstevel@tonic-gate 		break;
714*7c478bd9Sstevel@tonic-gate 	case MAP_PRIVATE:
715*7c478bd9Sstevel@tonic-gate 		used = strlcpy(str, "MAP_PRIVATE", CBSIZE);
716*7c478bd9Sstevel@tonic-gate 		break;
717*7c478bd9Sstevel@tonic-gate 	default:
718*7c478bd9Sstevel@tonic-gate 		used = snprintf(str, CBSIZE, "%ld", arg&MAP_TYPE);
719*7c478bd9Sstevel@tonic-gate 		break;
720*7c478bd9Sstevel@tonic-gate 	}
721*7c478bd9Sstevel@tonic-gate 
722*7c478bd9Sstevel@tonic-gate 	arg &= ~(_MAP_NEW|MAP_TYPE);
723*7c478bd9Sstevel@tonic-gate 
724*7c478bd9Sstevel@tonic-gate 	if (arg & ~(MAP_FIXED|MAP_RENAME|MAP_NORESERVE|MAP_ANON|MAP_ALIGN|
725*7c478bd9Sstevel@tonic-gate 	    MAP_TEXT|MAP_INITDATA))
726*7c478bd9Sstevel@tonic-gate 		(void) snprintf(str + used, sizeof (pri->code_buf) - used,
727*7c478bd9Sstevel@tonic-gate 			    "|0x%lX", arg);
728*7c478bd9Sstevel@tonic-gate 	else {
729*7c478bd9Sstevel@tonic-gate 		if (arg & MAP_FIXED)
730*7c478bd9Sstevel@tonic-gate 			(void) strlcat(str, "|MAP_FIXED", CBSIZE);
731*7c478bd9Sstevel@tonic-gate 		if (arg & MAP_RENAME)
732*7c478bd9Sstevel@tonic-gate 			(void) strlcat(str, "|MAP_RENAME", CBSIZE);
733*7c478bd9Sstevel@tonic-gate 		if (arg & MAP_NORESERVE)
734*7c478bd9Sstevel@tonic-gate 			(void) strlcat(str, "|MAP_NORESERVE", CBSIZE);
735*7c478bd9Sstevel@tonic-gate 		if (arg & MAP_ANON)
736*7c478bd9Sstevel@tonic-gate 			(void) strlcat(str, "|MAP_ANON", CBSIZE);
737*7c478bd9Sstevel@tonic-gate 		if (arg & MAP_ALIGN)
738*7c478bd9Sstevel@tonic-gate 			(void) strlcat(str, "|MAP_ALIGN", CBSIZE);
739*7c478bd9Sstevel@tonic-gate 		if (arg & MAP_TEXT)
740*7c478bd9Sstevel@tonic-gate 			(void) strlcat(str, "|MAP_TEXT", CBSIZE);
741*7c478bd9Sstevel@tonic-gate 		if (arg & MAP_INITDATA)
742*7c478bd9Sstevel@tonic-gate 			(void) strlcat(str, "|MAP_INITDATA", CBSIZE);
743*7c478bd9Sstevel@tonic-gate 	}
744*7c478bd9Sstevel@tonic-gate 
745*7c478bd9Sstevel@tonic-gate 	return ((const char *)str);
746*7c478bd9Sstevel@tonic-gate #undef CBSIZE
747*7c478bd9Sstevel@tonic-gate }
748*7c478bd9Sstevel@tonic-gate 
749*7c478bd9Sstevel@tonic-gate void
750*7c478bd9Sstevel@tonic-gate prt_mpr(private_t *pri, int raw, long val) /* print mmap()/mprotect() flags */
751*7c478bd9Sstevel@tonic-gate {
752*7c478bd9Sstevel@tonic-gate 	const char *s = raw? NULL : mmap_protect(pri, val);
753*7c478bd9Sstevel@tonic-gate 
754*7c478bd9Sstevel@tonic-gate 	if (s == NULL)
755*7c478bd9Sstevel@tonic-gate 		prt_hhx(pri, 0, val);
756*7c478bd9Sstevel@tonic-gate 	else
757*7c478bd9Sstevel@tonic-gate 		outstring(pri, s);
758*7c478bd9Sstevel@tonic-gate }
759*7c478bd9Sstevel@tonic-gate 
760*7c478bd9Sstevel@tonic-gate void
761*7c478bd9Sstevel@tonic-gate prt_mty(private_t *pri, int raw, long val) /* print mmap() mapping type flags */
762*7c478bd9Sstevel@tonic-gate {
763*7c478bd9Sstevel@tonic-gate 	const char *s = raw? NULL : mmap_type(pri, val);
764*7c478bd9Sstevel@tonic-gate 
765*7c478bd9Sstevel@tonic-gate 	if (s == NULL)
766*7c478bd9Sstevel@tonic-gate 		prt_hhx(pri, 0, val);
767*7c478bd9Sstevel@tonic-gate 	else
768*7c478bd9Sstevel@tonic-gate 		outstring(pri, s);
769*7c478bd9Sstevel@tonic-gate }
770*7c478bd9Sstevel@tonic-gate 
771*7c478bd9Sstevel@tonic-gate /*ARGSUSED*/
772*7c478bd9Sstevel@tonic-gate void
773*7c478bd9Sstevel@tonic-gate prt_mcf(private_t *pri, int raw, long val)	/* print memcntl() function */
774*7c478bd9Sstevel@tonic-gate {
775*7c478bd9Sstevel@tonic-gate 	const char *s = NULL;
776*7c478bd9Sstevel@tonic-gate 
777*7c478bd9Sstevel@tonic-gate 	if (!raw) {
778*7c478bd9Sstevel@tonic-gate 		switch (val) {
779*7c478bd9Sstevel@tonic-gate 		case MC_SYNC:		s = "MC_SYNC";		break;
780*7c478bd9Sstevel@tonic-gate 		case MC_LOCK:		s = "MC_LOCK";		break;
781*7c478bd9Sstevel@tonic-gate 		case MC_UNLOCK:		s = "MC_UNLOCK";	break;
782*7c478bd9Sstevel@tonic-gate 		case MC_ADVISE:		s = "MC_ADVISE";	break;
783*7c478bd9Sstevel@tonic-gate 		case MC_LOCKAS:		s = "MC_LOCKAS";	break;
784*7c478bd9Sstevel@tonic-gate 		case MC_UNLOCKAS:	s = "MC_UNLOCKAS";	break;
785*7c478bd9Sstevel@tonic-gate 		case MC_HAT_ADVISE:	s = "MC_HAT_ADVISE";	break;
786*7c478bd9Sstevel@tonic-gate 		}
787*7c478bd9Sstevel@tonic-gate 	}
788*7c478bd9Sstevel@tonic-gate 
789*7c478bd9Sstevel@tonic-gate 	if (s == NULL)
790*7c478bd9Sstevel@tonic-gate 		prt_dec(pri, 0, val);
791*7c478bd9Sstevel@tonic-gate 	else
792*7c478bd9Sstevel@tonic-gate 		outstring(pri, s);
793*7c478bd9Sstevel@tonic-gate }
794*7c478bd9Sstevel@tonic-gate 
795*7c478bd9Sstevel@tonic-gate void
796*7c478bd9Sstevel@tonic-gate prt_mad(private_t *pri, int raw, long val)	/* print madvise() argument */
797*7c478bd9Sstevel@tonic-gate {
798*7c478bd9Sstevel@tonic-gate 	const char *s = NULL;
799*7c478bd9Sstevel@tonic-gate 
800*7c478bd9Sstevel@tonic-gate 	if (!raw) {
801*7c478bd9Sstevel@tonic-gate 		switch (val) {
802*7c478bd9Sstevel@tonic-gate 		case MADV_NORMAL:	s = "MADV_NORMAL";	break;
803*7c478bd9Sstevel@tonic-gate 		case MADV_RANDOM:	s = "MADV_RANDOM";	break;
804*7c478bd9Sstevel@tonic-gate 		case MADV_SEQUENTIAL:	s = "MADV_SEQUENTIAL";	break;
805*7c478bd9Sstevel@tonic-gate 		case MADV_WILLNEED:	s = "MADV_WILLNEED";	break;
806*7c478bd9Sstevel@tonic-gate 		case MADV_DONTNEED:	s = "MADV_DONTNEED";	break;
807*7c478bd9Sstevel@tonic-gate 		case MADV_FREE:		s = "MADV_FREE";	break;
808*7c478bd9Sstevel@tonic-gate 		case MADV_ACCESS_DEFAULT: s = "MADV_ACCESS_DEFAULT";	break;
809*7c478bd9Sstevel@tonic-gate 		case MADV_ACCESS_LWP:	s = "MADV_ACCESS_LWP";	break;
810*7c478bd9Sstevel@tonic-gate 		case MADV_ACCESS_MANY:	s = "MADV_ACCESS_MANY";	break;
811*7c478bd9Sstevel@tonic-gate 		}
812*7c478bd9Sstevel@tonic-gate 	}
813*7c478bd9Sstevel@tonic-gate 
814*7c478bd9Sstevel@tonic-gate 	if (s == NULL)
815*7c478bd9Sstevel@tonic-gate 		prt_dec(pri, 0, val);
816*7c478bd9Sstevel@tonic-gate 	else
817*7c478bd9Sstevel@tonic-gate 		outstring(pri, s);
818*7c478bd9Sstevel@tonic-gate }
819*7c478bd9Sstevel@tonic-gate 
820*7c478bd9Sstevel@tonic-gate void
821*7c478bd9Sstevel@tonic-gate prt_mc4(private_t *pri, int raw, long val) /* print memcntl() (4th) argument */
822*7c478bd9Sstevel@tonic-gate {
823*7c478bd9Sstevel@tonic-gate 	if (val == 0)
824*7c478bd9Sstevel@tonic-gate 		prt_dec(pri, 0, val);
825*7c478bd9Sstevel@tonic-gate 	else if (raw)
826*7c478bd9Sstevel@tonic-gate 		prt_hhx(pri, 0, val);
827*7c478bd9Sstevel@tonic-gate 	else {
828*7c478bd9Sstevel@tonic-gate 		char *s = NULL;
829*7c478bd9Sstevel@tonic-gate 
830*7c478bd9Sstevel@tonic-gate #define	CBSIZE	sizeof (pri->code_buf)
831*7c478bd9Sstevel@tonic-gate 		/* cheating -- look at memcntl func */
832*7c478bd9Sstevel@tonic-gate 		switch (pri->sys_args[2]) {
833*7c478bd9Sstevel@tonic-gate 		case MC_ADVISE:
834*7c478bd9Sstevel@tonic-gate 			prt_mad(pri, 0, val);
835*7c478bd9Sstevel@tonic-gate 			return;
836*7c478bd9Sstevel@tonic-gate 
837*7c478bd9Sstevel@tonic-gate 		case MC_SYNC:
838*7c478bd9Sstevel@tonic-gate 			if ((val & ~(MS_SYNC|MS_ASYNC|MS_INVALIDATE)) == 0) {
839*7c478bd9Sstevel@tonic-gate 				*(s = pri->code_buf) = '\0';
840*7c478bd9Sstevel@tonic-gate 				if (val & MS_SYNC)
841*7c478bd9Sstevel@tonic-gate 					(void) strlcat(s, "|MS_SYNC", CBSIZE);
842*7c478bd9Sstevel@tonic-gate 				if (val & MS_ASYNC)
843*7c478bd9Sstevel@tonic-gate 					(void) strlcat(s, "|MS_ASYNC", CBSIZE);
844*7c478bd9Sstevel@tonic-gate 				if (val & MS_INVALIDATE)
845*7c478bd9Sstevel@tonic-gate 					(void) strlcat(s, "|MS_INVALIDATE",
846*7c478bd9Sstevel@tonic-gate 						    CBSIZE);
847*7c478bd9Sstevel@tonic-gate 			}
848*7c478bd9Sstevel@tonic-gate 			break;
849*7c478bd9Sstevel@tonic-gate 
850*7c478bd9Sstevel@tonic-gate 		case MC_LOCKAS:
851*7c478bd9Sstevel@tonic-gate 		case MC_UNLOCKAS:
852*7c478bd9Sstevel@tonic-gate 			if ((val & ~(MCL_CURRENT|MCL_FUTURE)) == 0) {
853*7c478bd9Sstevel@tonic-gate 				*(s = pri->code_buf) = '\0';
854*7c478bd9Sstevel@tonic-gate 				if (val & MCL_CURRENT)
855*7c478bd9Sstevel@tonic-gate 					(void) strlcat(s, "|MCL_CURRENT",
856*7c478bd9Sstevel@tonic-gate 						    CBSIZE);
857*7c478bd9Sstevel@tonic-gate 				if (val & MCL_FUTURE)
858*7c478bd9Sstevel@tonic-gate 					(void) strlcat(s, "|MCL_FUTURE",
859*7c478bd9Sstevel@tonic-gate 						    CBSIZE);
860*7c478bd9Sstevel@tonic-gate 			}
861*7c478bd9Sstevel@tonic-gate 			break;
862*7c478bd9Sstevel@tonic-gate 		}
863*7c478bd9Sstevel@tonic-gate #undef CBSIZE
864*7c478bd9Sstevel@tonic-gate 
865*7c478bd9Sstevel@tonic-gate 		if (s == NULL || *s == '\0')
866*7c478bd9Sstevel@tonic-gate 			prt_hhx(pri, 0, val);
867*7c478bd9Sstevel@tonic-gate 		else
868*7c478bd9Sstevel@tonic-gate 			outstring(pri, ++s);
869*7c478bd9Sstevel@tonic-gate 	}
870*7c478bd9Sstevel@tonic-gate }
871*7c478bd9Sstevel@tonic-gate 
872*7c478bd9Sstevel@tonic-gate void
873*7c478bd9Sstevel@tonic-gate prt_mc5(private_t *pri, int raw, long val) /* print memcntl() (5th) argument */
874*7c478bd9Sstevel@tonic-gate {
875*7c478bd9Sstevel@tonic-gate 	char *s;
876*7c478bd9Sstevel@tonic-gate 
877*7c478bd9Sstevel@tonic-gate #define	CBSIZE	sizeof (pri->code_buf)
878*7c478bd9Sstevel@tonic-gate 	if (val == 0)
879*7c478bd9Sstevel@tonic-gate 		prt_dec(pri, 0, val);
880*7c478bd9Sstevel@tonic-gate 	else if (raw || (val & ~VALID_ATTR))
881*7c478bd9Sstevel@tonic-gate 		prt_hhx(pri, 0, val);
882*7c478bd9Sstevel@tonic-gate 	else {
883*7c478bd9Sstevel@tonic-gate 		s = pri->code_buf;
884*7c478bd9Sstevel@tonic-gate 		*s = '\0';
885*7c478bd9Sstevel@tonic-gate 		if (val & SHARED)
886*7c478bd9Sstevel@tonic-gate 			(void) strlcat(s, "|SHARED", CBSIZE);
887*7c478bd9Sstevel@tonic-gate 		if (val & PRIVATE)
888*7c478bd9Sstevel@tonic-gate 			(void) strlcat(s, "|PRIVATE", CBSIZE);
889*7c478bd9Sstevel@tonic-gate 		if (val & PROT_READ)
890*7c478bd9Sstevel@tonic-gate 			(void) strlcat(s, "|PROT_READ", CBSIZE);
891*7c478bd9Sstevel@tonic-gate 		if (val & PROT_WRITE)
892*7c478bd9Sstevel@tonic-gate 			(void) strlcat(s, "|PROT_WRITE", CBSIZE);
893*7c478bd9Sstevel@tonic-gate 		if (val & PROT_EXEC)
894*7c478bd9Sstevel@tonic-gate 			(void) strlcat(s, "|PROT_EXEC", CBSIZE);
895*7c478bd9Sstevel@tonic-gate 		if (*s == '\0')
896*7c478bd9Sstevel@tonic-gate 			prt_hhx(pri, 0, val);
897*7c478bd9Sstevel@tonic-gate 		else
898*7c478bd9Sstevel@tonic-gate 			outstring(pri, ++s);
899*7c478bd9Sstevel@tonic-gate 	}
900*7c478bd9Sstevel@tonic-gate #undef CBSIZE
901*7c478bd9Sstevel@tonic-gate }
902*7c478bd9Sstevel@tonic-gate 
903*7c478bd9Sstevel@tonic-gate void
904*7c478bd9Sstevel@tonic-gate prt_ulm(private_t *pri, int raw, long val)	/* print ulimit() argument */
905*7c478bd9Sstevel@tonic-gate {
906*7c478bd9Sstevel@tonic-gate 	const char *s = NULL;
907*7c478bd9Sstevel@tonic-gate 
908*7c478bd9Sstevel@tonic-gate 	if (!raw) {
909*7c478bd9Sstevel@tonic-gate 		switch (val) {
910*7c478bd9Sstevel@tonic-gate 		case UL_GFILLIM:	s = "UL_GFILLIM";	break;
911*7c478bd9Sstevel@tonic-gate 		case UL_SFILLIM:	s = "UL_SFILLIM";	break;
912*7c478bd9Sstevel@tonic-gate 		case UL_GMEMLIM:	s = "UL_GMEMLIM";	break;
913*7c478bd9Sstevel@tonic-gate 		case UL_GDESLIM:	s = "UL_GDESLIM";	break;
914*7c478bd9Sstevel@tonic-gate 		}
915*7c478bd9Sstevel@tonic-gate 	}
916*7c478bd9Sstevel@tonic-gate 
917*7c478bd9Sstevel@tonic-gate 	if (s == NULL)
918*7c478bd9Sstevel@tonic-gate 		prt_dec(pri, 0, val);
919*7c478bd9Sstevel@tonic-gate 	else
920*7c478bd9Sstevel@tonic-gate 		outstring(pri, s);
921*7c478bd9Sstevel@tonic-gate }
922*7c478bd9Sstevel@tonic-gate 
923*7c478bd9Sstevel@tonic-gate void
924*7c478bd9Sstevel@tonic-gate prt_rlm(private_t *pri, int raw, long val) /* print get/setrlimit() argument */
925*7c478bd9Sstevel@tonic-gate {
926*7c478bd9Sstevel@tonic-gate 	const char *s = NULL;
927*7c478bd9Sstevel@tonic-gate 
928*7c478bd9Sstevel@tonic-gate 	if (!raw) {
929*7c478bd9Sstevel@tonic-gate 		switch (val) {
930*7c478bd9Sstevel@tonic-gate 		case RLIMIT_CPU:	s = "RLIMIT_CPU";	break;
931*7c478bd9Sstevel@tonic-gate 		case RLIMIT_FSIZE:	s = "RLIMIT_FSIZE";	break;
932*7c478bd9Sstevel@tonic-gate 		case RLIMIT_DATA:	s = "RLIMIT_DATA";	break;
933*7c478bd9Sstevel@tonic-gate 		case RLIMIT_STACK:	s = "RLIMIT_STACK";	break;
934*7c478bd9Sstevel@tonic-gate 		case RLIMIT_CORE:	s = "RLIMIT_CORE";	break;
935*7c478bd9Sstevel@tonic-gate 		case RLIMIT_NOFILE:	s = "RLIMIT_NOFILE";	break;
936*7c478bd9Sstevel@tonic-gate 		case RLIMIT_VMEM:	s = "RLIMIT_VMEM";	break;
937*7c478bd9Sstevel@tonic-gate 		}
938*7c478bd9Sstevel@tonic-gate 	}
939*7c478bd9Sstevel@tonic-gate 
940*7c478bd9Sstevel@tonic-gate 	if (s == NULL)
941*7c478bd9Sstevel@tonic-gate 		prt_dec(pri, 0, val);
942*7c478bd9Sstevel@tonic-gate 	else
943*7c478bd9Sstevel@tonic-gate 		outstring(pri, s);
944*7c478bd9Sstevel@tonic-gate }
945*7c478bd9Sstevel@tonic-gate 
946*7c478bd9Sstevel@tonic-gate void
947*7c478bd9Sstevel@tonic-gate prt_cnf(private_t *pri, int raw, long val)	/* print sysconfig code */
948*7c478bd9Sstevel@tonic-gate {
949*7c478bd9Sstevel@tonic-gate 	const char *s = raw? NULL : sconfname(val);
950*7c478bd9Sstevel@tonic-gate 
951*7c478bd9Sstevel@tonic-gate 	if (s == NULL)
952*7c478bd9Sstevel@tonic-gate 		prt_dec(pri, 0, val);
953*7c478bd9Sstevel@tonic-gate 	else
954*7c478bd9Sstevel@tonic-gate 		outstring(pri, s);
955*7c478bd9Sstevel@tonic-gate }
956*7c478bd9Sstevel@tonic-gate 
957*7c478bd9Sstevel@tonic-gate void
958*7c478bd9Sstevel@tonic-gate prt_inf(private_t *pri, int raw, long val)	/* print sysinfo code */
959*7c478bd9Sstevel@tonic-gate {
960*7c478bd9Sstevel@tonic-gate 	const char *s = NULL;
961*7c478bd9Sstevel@tonic-gate 
962*7c478bd9Sstevel@tonic-gate 	if (!raw) {
963*7c478bd9Sstevel@tonic-gate 		switch (val) {
964*7c478bd9Sstevel@tonic-gate 		case SI_SYSNAME:	s = "SI_SYSNAME";	break;
965*7c478bd9Sstevel@tonic-gate 		case SI_HOSTNAME:	s = "SI_HOSTNAME";	break;
966*7c478bd9Sstevel@tonic-gate 		case SI_RELEASE:	s = "SI_RELEASE";	break;
967*7c478bd9Sstevel@tonic-gate 		case SI_VERSION:	s = "SI_VERSION";	break;
968*7c478bd9Sstevel@tonic-gate 		case SI_MACHINE:	s = "SI_MACHINE";	break;
969*7c478bd9Sstevel@tonic-gate 		case SI_ARCHITECTURE:	s = "SI_ARCHITECTURE";	break;
970*7c478bd9Sstevel@tonic-gate 		case SI_ARCHITECTURE_32:s = "SI_ARCHITECTURE_32"; break;
971*7c478bd9Sstevel@tonic-gate 		case SI_ARCHITECTURE_64:s = "SI_ARCHITECTURE_64"; break;
972*7c478bd9Sstevel@tonic-gate 		case SI_ARCHITECTURE_K:	s = "SI_ARCHITECTURE_K"; break;
973*7c478bd9Sstevel@tonic-gate 		case SI_HW_SERIAL:	s = "SI_HW_SERIAL";	break;
974*7c478bd9Sstevel@tonic-gate 		case SI_HW_PROVIDER:	s = "SI_HW_PROVIDER";	break;
975*7c478bd9Sstevel@tonic-gate 		case SI_SRPC_DOMAIN:	s = "SI_SRPC_DOMAIN";	break;
976*7c478bd9Sstevel@tonic-gate 		case SI_SET_HOSTNAME:	s = "SI_SET_HOSTNAME";	break;
977*7c478bd9Sstevel@tonic-gate 		case SI_SET_SRPC_DOMAIN: s = "SI_SET_SRPC_DOMAIN"; break;
978*7c478bd9Sstevel@tonic-gate 		case SI_PLATFORM:	s = "SI_PLATFORM";	break;
979*7c478bd9Sstevel@tonic-gate 		case SI_ISALIST:	s = "SI_ISALIST";	break;
980*7c478bd9Sstevel@tonic-gate 		case SI_DHCP_CACHE:	s = "SI_DHCP_CACHE";	break;
981*7c478bd9Sstevel@tonic-gate 		}
982*7c478bd9Sstevel@tonic-gate 	}
983*7c478bd9Sstevel@tonic-gate 
984*7c478bd9Sstevel@tonic-gate 	if (s == NULL)
985*7c478bd9Sstevel@tonic-gate 		prt_dec(pri, 0, val);
986*7c478bd9Sstevel@tonic-gate 	else
987*7c478bd9Sstevel@tonic-gate 		outstring(pri, s);
988*7c478bd9Sstevel@tonic-gate }
989*7c478bd9Sstevel@tonic-gate 
990*7c478bd9Sstevel@tonic-gate void
991*7c478bd9Sstevel@tonic-gate prt_ptc(private_t *pri, int raw, long val)	/* print pathconf code */
992*7c478bd9Sstevel@tonic-gate {
993*7c478bd9Sstevel@tonic-gate 	const char *s = raw? NULL : pathconfname(val);
994*7c478bd9Sstevel@tonic-gate 
995*7c478bd9Sstevel@tonic-gate 	if (s == NULL)
996*7c478bd9Sstevel@tonic-gate 		prt_dec(pri, 0, val);
997*7c478bd9Sstevel@tonic-gate 	else
998*7c478bd9Sstevel@tonic-gate 		outstring(pri, s);
999*7c478bd9Sstevel@tonic-gate }
1000*7c478bd9Sstevel@tonic-gate 
1001*7c478bd9Sstevel@tonic-gate void
1002*7c478bd9Sstevel@tonic-gate prt_fui(private_t *pri, int raw, long val) /* print fusers() input argument */
1003*7c478bd9Sstevel@tonic-gate {
1004*7c478bd9Sstevel@tonic-gate 	const char *s = raw? NULL : fuiname(val);
1005*7c478bd9Sstevel@tonic-gate 
1006*7c478bd9Sstevel@tonic-gate 	if (s == NULL)
1007*7c478bd9Sstevel@tonic-gate 		prt_hhx(pri, 0, val);
1008*7c478bd9Sstevel@tonic-gate 	else
1009*7c478bd9Sstevel@tonic-gate 		outstring(pri, s);
1010*7c478bd9Sstevel@tonic-gate }
1011*7c478bd9Sstevel@tonic-gate 
1012*7c478bd9Sstevel@tonic-gate void
1013*7c478bd9Sstevel@tonic-gate prt_lwf(private_t *pri, int raw, long val)	/* print lwp_create() flags */
1014*7c478bd9Sstevel@tonic-gate {
1015*7c478bd9Sstevel@tonic-gate 	char *s;
1016*7c478bd9Sstevel@tonic-gate 
1017*7c478bd9Sstevel@tonic-gate 	if (val == 0)
1018*7c478bd9Sstevel@tonic-gate 		prt_dec(pri, 0, val);
1019*7c478bd9Sstevel@tonic-gate 	else if (raw ||
1020*7c478bd9Sstevel@tonic-gate 	    (val & ~(LWP_DAEMON|LWP_DETACHED|LWP_SUSPENDED)))
1021*7c478bd9Sstevel@tonic-gate 		prt_hhx(pri, 0, val);
1022*7c478bd9Sstevel@tonic-gate 	else {
1023*7c478bd9Sstevel@tonic-gate #define	CBSIZE	sizeof (pri->code_buf)
1024*7c478bd9Sstevel@tonic-gate 		s = pri->code_buf;
1025*7c478bd9Sstevel@tonic-gate 		*s = '\0';
1026*7c478bd9Sstevel@tonic-gate 		if (val & LWP_DAEMON)
1027*7c478bd9Sstevel@tonic-gate 			(void) strlcat(s, "|LWP_DAEMON", CBSIZE);
1028*7c478bd9Sstevel@tonic-gate 		if (val & LWP_DETACHED)
1029*7c478bd9Sstevel@tonic-gate 			(void) strlcat(s, "|LWP_DETACHED", CBSIZE);
1030*7c478bd9Sstevel@tonic-gate 		if (val & LWP_SUSPENDED)
1031*7c478bd9Sstevel@tonic-gate 			(void) strlcat(s, "|LWP_SUSPENDED", CBSIZE);
1032*7c478bd9Sstevel@tonic-gate 		outstring(pri, ++s);
1033*7c478bd9Sstevel@tonic-gate #undef CBSIZE
1034*7c478bd9Sstevel@tonic-gate 	}
1035*7c478bd9Sstevel@tonic-gate }
1036*7c478bd9Sstevel@tonic-gate 
1037*7c478bd9Sstevel@tonic-gate void
1038*7c478bd9Sstevel@tonic-gate prt_itm(private_t *pri, int raw, long val) /* print [get|set]itimer() arg */
1039*7c478bd9Sstevel@tonic-gate {
1040*7c478bd9Sstevel@tonic-gate 	const char *s = NULL;
1041*7c478bd9Sstevel@tonic-gate 
1042*7c478bd9Sstevel@tonic-gate 	if (!raw) {
1043*7c478bd9Sstevel@tonic-gate 		switch (val) {
1044*7c478bd9Sstevel@tonic-gate 		case ITIMER_REAL:	s = "ITIMER_REAL";	break;
1045*7c478bd9Sstevel@tonic-gate 		case ITIMER_VIRTUAL:	s = "ITIMER_VIRTUAL";	break;
1046*7c478bd9Sstevel@tonic-gate 		case ITIMER_PROF:	s = "ITIMER_PROF";	break;
1047*7c478bd9Sstevel@tonic-gate #ifdef ITIMER_REALPROF
1048*7c478bd9Sstevel@tonic-gate 		case ITIMER_REALPROF:	s = "ITIMER_REALPROF";	break;
1049*7c478bd9Sstevel@tonic-gate #endif
1050*7c478bd9Sstevel@tonic-gate 		}
1051*7c478bd9Sstevel@tonic-gate 	}
1052*7c478bd9Sstevel@tonic-gate 
1053*7c478bd9Sstevel@tonic-gate 	if (s == NULL)
1054*7c478bd9Sstevel@tonic-gate 		prt_dec(pri, 0, val);
1055*7c478bd9Sstevel@tonic-gate 	else
1056*7c478bd9Sstevel@tonic-gate 		outstring(pri, s);
1057*7c478bd9Sstevel@tonic-gate }
1058*7c478bd9Sstevel@tonic-gate 
1059*7c478bd9Sstevel@tonic-gate void
1060*7c478bd9Sstevel@tonic-gate prt_mod(private_t *pri, int raw, long val)	/* print modctl() code */
1061*7c478bd9Sstevel@tonic-gate {
1062*7c478bd9Sstevel@tonic-gate 	const char *s = NULL;
1063*7c478bd9Sstevel@tonic-gate 
1064*7c478bd9Sstevel@tonic-gate 	if (!raw) {
1065*7c478bd9Sstevel@tonic-gate 		switch (val) {
1066*7c478bd9Sstevel@tonic-gate 		case MODLOAD:		s = "MODLOAD";		break;
1067*7c478bd9Sstevel@tonic-gate 		case MODUNLOAD:		s = "MODUNLOAD";	break;
1068*7c478bd9Sstevel@tonic-gate 		case MODINFO:		s = "MODINFO";		break;
1069*7c478bd9Sstevel@tonic-gate 		case MODRESERVED:	s = "MODRESERVED";	break;
1070*7c478bd9Sstevel@tonic-gate 		case MODSETMINIROOT:	s = "MODSETMINIROOT";	break;
1071*7c478bd9Sstevel@tonic-gate 		case MODADDMAJBIND:	s = "MODADDMAJBIND";	break;
1072*7c478bd9Sstevel@tonic-gate 		case MODGETPATH:	s = "MODGETPATH";	break;
1073*7c478bd9Sstevel@tonic-gate 		case MODGETPATHLEN:	s = "MODGETPATHLEN";	break;
1074*7c478bd9Sstevel@tonic-gate 		case MODREADSYSBIND:	s = "MODREADSYSBIND";	break;
1075*7c478bd9Sstevel@tonic-gate 		case MODGETMAJBIND:	s = "MODGETMAJBIND";	break;
1076*7c478bd9Sstevel@tonic-gate 		case MODGETNAME:	s = "MODGETNAME";	break;
1077*7c478bd9Sstevel@tonic-gate 		case MODSIZEOF_DEVID:	s = "MODSIZEOF_DEVID";	break;
1078*7c478bd9Sstevel@tonic-gate 		case MODGETDEVID:	s = "MODGETDEVID";	break;
1079*7c478bd9Sstevel@tonic-gate 		case MODSIZEOF_MINORNAME: s = "MODSIZEOF_MINORNAME"; break;
1080*7c478bd9Sstevel@tonic-gate 		case MODGETMINORNAME:	s = "MODGETMINORNAME";	break;
1081*7c478bd9Sstevel@tonic-gate 		case MODGETFBNAME:	s = "MODGETFBNAME";	break;
1082*7c478bd9Sstevel@tonic-gate 		case MODEVENTS:		s = "MODEVENTS";	break;
1083*7c478bd9Sstevel@tonic-gate 		case MODREREADDACF:	s = "MODREREADDACF";	break;
1084*7c478bd9Sstevel@tonic-gate 		case MODLOADDRVCONF:	s = "MODLOADDRVCONF";	break;
1085*7c478bd9Sstevel@tonic-gate 		case MODUNLOADDRVCONF:	s = "MODUNLOADDRVCONF";	break;
1086*7c478bd9Sstevel@tonic-gate 		case MODREMMAJBIND:	s = "MODREMMAJBIND";	break;
1087*7c478bd9Sstevel@tonic-gate 		case MODDEVT2INSTANCE:	s = "MODDEVT2INSTANCE";	break;
1088*7c478bd9Sstevel@tonic-gate 		case MODGETDEVFSPATH_LEN: s = "MODGETDEVFSPATH_LEN"; break;
1089*7c478bd9Sstevel@tonic-gate 		case MODGETDEVFSPATH:	s = "MODGETDEVFSPATH";	break;
1090*7c478bd9Sstevel@tonic-gate 		case MODDEVID2PATHS:	s = "MODDEVID2PATHS";	break;
1091*7c478bd9Sstevel@tonic-gate 		case MODSETDEVPOLICY:	s = "MODSETDEVPOLICY";	break;
1092*7c478bd9Sstevel@tonic-gate 		case MODGETDEVPOLICY:	s = "MODGETDEVPOLICY";	break;
1093*7c478bd9Sstevel@tonic-gate 		case MODALLOCPRIV:	s = "MODALLOCPRIV";	break;
1094*7c478bd9Sstevel@tonic-gate 		case MODGETDEVPOLICYBYNAME:
1095*7c478bd9Sstevel@tonic-gate 					s = "MODGETDEVPOLICYBYNAME"; break;
1096*7c478bd9Sstevel@tonic-gate 		case MODCLEANUP:	s = "MODCLEANUP"; break;
1097*7c478bd9Sstevel@tonic-gate 		case MODLOADMINORPERM:	s = "MODLOADMINORPERM"; break;
1098*7c478bd9Sstevel@tonic-gate 		case MODADDMINORPERM:	s = "MODADDMINORPERM"; break;
1099*7c478bd9Sstevel@tonic-gate 		case MODREMMINORPERM:	s = "MODREMMINORPERM"; break;
1100*7c478bd9Sstevel@tonic-gate 		case MODREMDRVCLEANUP:	s = "MODREMDRVCLEANUP"; break;
1101*7c478bd9Sstevel@tonic-gate 		}
1102*7c478bd9Sstevel@tonic-gate 	}
1103*7c478bd9Sstevel@tonic-gate 
1104*7c478bd9Sstevel@tonic-gate 	if (s == NULL)
1105*7c478bd9Sstevel@tonic-gate 		prt_dec(pri, 0, val);
1106*7c478bd9Sstevel@tonic-gate 	else
1107*7c478bd9Sstevel@tonic-gate 		outstring(pri, s);
1108*7c478bd9Sstevel@tonic-gate }
1109*7c478bd9Sstevel@tonic-gate 
1110*7c478bd9Sstevel@tonic-gate void
1111*7c478bd9Sstevel@tonic-gate prt_acl(private_t *pri, int raw, long val)	/* print acl() code */
1112*7c478bd9Sstevel@tonic-gate {
1113*7c478bd9Sstevel@tonic-gate 	const char *s = NULL;
1114*7c478bd9Sstevel@tonic-gate 
1115*7c478bd9Sstevel@tonic-gate 	if (!raw) {
1116*7c478bd9Sstevel@tonic-gate 		switch (val) {
1117*7c478bd9Sstevel@tonic-gate 		case GETACL:		s = "GETACL";		break;
1118*7c478bd9Sstevel@tonic-gate 		case SETACL:		s = "SETACL";		break;
1119*7c478bd9Sstevel@tonic-gate 		case GETACLCNT:		s = "GETACLCNT";	break;
1120*7c478bd9Sstevel@tonic-gate 		}
1121*7c478bd9Sstevel@tonic-gate 	}
1122*7c478bd9Sstevel@tonic-gate 
1123*7c478bd9Sstevel@tonic-gate 	if (s == NULL)
1124*7c478bd9Sstevel@tonic-gate 		prt_dec(pri, 0, val);
1125*7c478bd9Sstevel@tonic-gate 	else
1126*7c478bd9Sstevel@tonic-gate 		outstring(pri, s);
1127*7c478bd9Sstevel@tonic-gate }
1128*7c478bd9Sstevel@tonic-gate 
1129*7c478bd9Sstevel@tonic-gate void
1130*7c478bd9Sstevel@tonic-gate prt_aio(private_t *pri, int raw, long val)	/* print kaio() code */
1131*7c478bd9Sstevel@tonic-gate {
1132*7c478bd9Sstevel@tonic-gate 	const char *s = NULL;
1133*7c478bd9Sstevel@tonic-gate 	char buf[32];
1134*7c478bd9Sstevel@tonic-gate 
1135*7c478bd9Sstevel@tonic-gate 	if (!raw) {
1136*7c478bd9Sstevel@tonic-gate 		switch (val & ~AIO_POLL_BIT) {
1137*7c478bd9Sstevel@tonic-gate 		case AIOREAD:		s = "AIOREAD";		break;
1138*7c478bd9Sstevel@tonic-gate 		case AIOWRITE:		s = "AIOWRITE";		break;
1139*7c478bd9Sstevel@tonic-gate 		case AIOWAIT:		s = "AIOWAIT";		break;
1140*7c478bd9Sstevel@tonic-gate 		case AIOCANCEL:		s = "AIOCANCEL";	break;
1141*7c478bd9Sstevel@tonic-gate 		case AIONOTIFY:		s = "AIONOTIFY";	break;
1142*7c478bd9Sstevel@tonic-gate 		case AIOINIT:		s = "AIOINIT";		break;
1143*7c478bd9Sstevel@tonic-gate 		case AIOSTART:		s = "AIOSTART";		break;
1144*7c478bd9Sstevel@tonic-gate 		case AIOLIO:		s = "AIOLIO";		break;
1145*7c478bd9Sstevel@tonic-gate 		case AIOSUSPEND:	s = "AIOSUSPEND";	break;
1146*7c478bd9Sstevel@tonic-gate 		case AIOERROR:		s = "AIOERROR";		break;
1147*7c478bd9Sstevel@tonic-gate 		case AIOLIOWAIT:	s = "AIOLIOWAIT";	break;
1148*7c478bd9Sstevel@tonic-gate 		case AIOAREAD:		s = "AIOAREAD";		break;
1149*7c478bd9Sstevel@tonic-gate 		case AIOAWRITE:		s = "AIOAWRITE";	break;
1150*7c478bd9Sstevel@tonic-gate 		/*
1151*7c478bd9Sstevel@tonic-gate 		 * We have to hardcode the values for the 64-bit versions of
1152*7c478bd9Sstevel@tonic-gate 		 * these calls, because <sys/aio.h> defines them to be identical
1153*7c478bd9Sstevel@tonic-gate 		 * when compiled 64-bit.  If our target is 32-bit, we still need
1154*7c478bd9Sstevel@tonic-gate 		 * to decode them correctly.
1155*7c478bd9Sstevel@tonic-gate 		 */
1156*7c478bd9Sstevel@tonic-gate 		case 13:		s = "AIOLIO64";		break;
1157*7c478bd9Sstevel@tonic-gate 		case 14:		s = "AIOSUSPEND64";	break;
1158*7c478bd9Sstevel@tonic-gate 		case 15:		s = "AUIOERROR64";	break;
1159*7c478bd9Sstevel@tonic-gate 		case 16:		s = "AIOLIOWAIT64";	break;
1160*7c478bd9Sstevel@tonic-gate 		case 17:		s = "AIOAREAD64";	break;
1161*7c478bd9Sstevel@tonic-gate 		case 18:		s = "AIOAWRITE64";	break;
1162*7c478bd9Sstevel@tonic-gate 		case 19:		s = "AIOCANCEL64";	break;
1163*7c478bd9Sstevel@tonic-gate 
1164*7c478bd9Sstevel@tonic-gate 		/*
1165*7c478bd9Sstevel@tonic-gate 		 * AIOFSYNC doesn't correspond to a syscall.
1166*7c478bd9Sstevel@tonic-gate 		 */
1167*7c478bd9Sstevel@tonic-gate 		case AIOWAITN:		s = "AIOWAITN";		break;
1168*7c478bd9Sstevel@tonic-gate 		}
1169*7c478bd9Sstevel@tonic-gate 		if (s != NULL && (val & AIO_POLL_BIT)) {
1170*7c478bd9Sstevel@tonic-gate 			(void) strlcpy(buf, s, sizeof (buf));
1171*7c478bd9Sstevel@tonic-gate 			(void) strlcat(buf, "|AIO_POLL_BIT", sizeof (buf));
1172*7c478bd9Sstevel@tonic-gate 			s = (const char *)buf;
1173*7c478bd9Sstevel@tonic-gate 		}
1174*7c478bd9Sstevel@tonic-gate 	}
1175*7c478bd9Sstevel@tonic-gate 
1176*7c478bd9Sstevel@tonic-gate 	if (s == NULL)
1177*7c478bd9Sstevel@tonic-gate 		prt_dec(pri, 0, val);
1178*7c478bd9Sstevel@tonic-gate 	else
1179*7c478bd9Sstevel@tonic-gate 		outstring(pri, s);
1180*7c478bd9Sstevel@tonic-gate }
1181*7c478bd9Sstevel@tonic-gate 
1182*7c478bd9Sstevel@tonic-gate void
1183*7c478bd9Sstevel@tonic-gate prt_aud(private_t *pri, int raw, long val)	/* print auditsys() code */
1184*7c478bd9Sstevel@tonic-gate {
1185*7c478bd9Sstevel@tonic-gate 	const char *s = NULL;
1186*7c478bd9Sstevel@tonic-gate 
1187*7c478bd9Sstevel@tonic-gate 	if (!raw) {
1188*7c478bd9Sstevel@tonic-gate 		switch (val) {
1189*7c478bd9Sstevel@tonic-gate 		case BSM_GETAUID:	s = "BSM_GETAUID";	break;
1190*7c478bd9Sstevel@tonic-gate 		case BSM_SETAUID:	s = "BSM_SETAUID";	break;
1191*7c478bd9Sstevel@tonic-gate 		case BSM_GETAUDIT:	s = "BSM_GETAUDIT";	break;
1192*7c478bd9Sstevel@tonic-gate 		case BSM_SETAUDIT:	s = "BSM_SETAUDIT";	break;
1193*7c478bd9Sstevel@tonic-gate 		case BSM_GETUSERAUDIT:	s = "BSM_GETUSERAUDIT";	break;
1194*7c478bd9Sstevel@tonic-gate 		case BSM_SETUSERAUDIT:	s = "BSM_SETUSERAUDIT";	break;
1195*7c478bd9Sstevel@tonic-gate 		case BSM_AUDIT:		s = "BSM_AUDIT";	break;
1196*7c478bd9Sstevel@tonic-gate 		case BSM_AUDITUSER:	s = "BSM_AUDITUSER";	break;
1197*7c478bd9Sstevel@tonic-gate 		case BSM_AUDITSVC:	s = "BSM_AUDITSVC";	break;
1198*7c478bd9Sstevel@tonic-gate 		case BSM_AUDITON:	s = "BSM_AUDITON";	break;
1199*7c478bd9Sstevel@tonic-gate 		case BSM_AUDITCTL:	s = "BSM_AUDITCTL";	break;
1200*7c478bd9Sstevel@tonic-gate 		case BSM_GETKERNSTATE:	s = "BSM_GETKERNSTATE";	break;
1201*7c478bd9Sstevel@tonic-gate 		case BSM_SETKERNSTATE:	s = "BSM_SETKERNSTATE";	break;
1202*7c478bd9Sstevel@tonic-gate 		case BSM_GETPORTAUDIT:	s = "BSM_GETPORTAUDIT";	break;
1203*7c478bd9Sstevel@tonic-gate 		case BSM_REVOKE:	s = "BSM_REVOKE";	break;
1204*7c478bd9Sstevel@tonic-gate 		case BSM_AUDITSTAT:	s = "BSM_AUDITSTAT";	break;
1205*7c478bd9Sstevel@tonic-gate 		case BSM_GETAUDIT_ADDR:	s = "BSM_GETAUDIT_ADDR"; break;
1206*7c478bd9Sstevel@tonic-gate 		case BSM_SETAUDIT_ADDR:	s = "BSM_SETAUDIT_ADDR"; break;
1207*7c478bd9Sstevel@tonic-gate 		}
1208*7c478bd9Sstevel@tonic-gate 	}
1209*7c478bd9Sstevel@tonic-gate 
1210*7c478bd9Sstevel@tonic-gate 	if (s == NULL)
1211*7c478bd9Sstevel@tonic-gate 		prt_dec(pri, 0, val);
1212*7c478bd9Sstevel@tonic-gate 	else
1213*7c478bd9Sstevel@tonic-gate 		outstring(pri, s);
1214*7c478bd9Sstevel@tonic-gate }
1215*7c478bd9Sstevel@tonic-gate 
1216*7c478bd9Sstevel@tonic-gate void
1217*7c478bd9Sstevel@tonic-gate prt_cor(private_t *pri, int raw, long val)	/* print corectl() subcode */
1218*7c478bd9Sstevel@tonic-gate {
1219*7c478bd9Sstevel@tonic-gate 	const char *s = NULL;
1220*7c478bd9Sstevel@tonic-gate 
1221*7c478bd9Sstevel@tonic-gate 	if (!raw) {
1222*7c478bd9Sstevel@tonic-gate 		switch (val) {
1223*7c478bd9Sstevel@tonic-gate 		case CC_SET_OPTIONS:
1224*7c478bd9Sstevel@tonic-gate 			s = "CC_SET_OPTIONS";		break;
1225*7c478bd9Sstevel@tonic-gate 		case CC_GET_OPTIONS:
1226*7c478bd9Sstevel@tonic-gate 			s = "CC_GET_OPTIONS";		break;
1227*7c478bd9Sstevel@tonic-gate 		case CC_SET_GLOBAL_PATH:
1228*7c478bd9Sstevel@tonic-gate 			s = "CC_SET_GLOBAL_PATH";	break;
1229*7c478bd9Sstevel@tonic-gate 		case CC_GET_GLOBAL_PATH:
1230*7c478bd9Sstevel@tonic-gate 			s = "CC_GET_GLOBAL_PATH";	break;
1231*7c478bd9Sstevel@tonic-gate 		case CC_SET_PROCESS_PATH:
1232*7c478bd9Sstevel@tonic-gate 			s = "CC_SET_PROCESS_PATH";	break;
1233*7c478bd9Sstevel@tonic-gate 		case CC_GET_PROCESS_PATH:
1234*7c478bd9Sstevel@tonic-gate 			s = "CC_GET_PROCESS_PATH";	break;
1235*7c478bd9Sstevel@tonic-gate 		case CC_SET_GLOBAL_CONTENT:
1236*7c478bd9Sstevel@tonic-gate 			s = "CC_SET_GLOBAL_CONTENT";	break;
1237*7c478bd9Sstevel@tonic-gate 		case CC_GET_GLOBAL_CONTENT:
1238*7c478bd9Sstevel@tonic-gate 			s = "CC_GET_GLOBAL_CONTENT";	break;
1239*7c478bd9Sstevel@tonic-gate 		case CC_SET_PROCESS_CONTENT:
1240*7c478bd9Sstevel@tonic-gate 			s = "CC_SET_PROCESS_CONTENT";	break;
1241*7c478bd9Sstevel@tonic-gate 		case CC_GET_PROCESS_CONTENT:
1242*7c478bd9Sstevel@tonic-gate 			s = "CC_GET_PROCESS_CONTENT";	break;
1243*7c478bd9Sstevel@tonic-gate 		case CC_SET_DEFAULT_PATH:
1244*7c478bd9Sstevel@tonic-gate 			s = "CC_SET_DEFAULT_PATH";	break;
1245*7c478bd9Sstevel@tonic-gate 		case CC_GET_DEFAULT_PATH:
1246*7c478bd9Sstevel@tonic-gate 			s = "CC_GET_DEFAULT_PATH";	break;
1247*7c478bd9Sstevel@tonic-gate 		case CC_SET_DEFAULT_CONTENT:
1248*7c478bd9Sstevel@tonic-gate 			s = "CC_SET_DEFAULT_CONTENT";	break;
1249*7c478bd9Sstevel@tonic-gate 		case CC_GET_DEFAULT_CONTENT:
1250*7c478bd9Sstevel@tonic-gate 			s = "CC_GET_DEFAULT_CONTENT";	break;
1251*7c478bd9Sstevel@tonic-gate 		}
1252*7c478bd9Sstevel@tonic-gate 	}
1253*7c478bd9Sstevel@tonic-gate 
1254*7c478bd9Sstevel@tonic-gate 	if (s == NULL)
1255*7c478bd9Sstevel@tonic-gate 		prt_dec(pri, 0, val);
1256*7c478bd9Sstevel@tonic-gate 	else
1257*7c478bd9Sstevel@tonic-gate 		outstring(pri, s);
1258*7c478bd9Sstevel@tonic-gate }
1259*7c478bd9Sstevel@tonic-gate 
1260*7c478bd9Sstevel@tonic-gate void
1261*7c478bd9Sstevel@tonic-gate prt_cco(private_t *pri, int raw, long val)	/* print corectl() options */
1262*7c478bd9Sstevel@tonic-gate {
1263*7c478bd9Sstevel@tonic-gate 	char *s;
1264*7c478bd9Sstevel@tonic-gate 
1265*7c478bd9Sstevel@tonic-gate 	if (val == 0)
1266*7c478bd9Sstevel@tonic-gate 		prt_dec(pri, 0, val);
1267*7c478bd9Sstevel@tonic-gate 	else if (raw || (val & ~CC_OPTIONS))
1268*7c478bd9Sstevel@tonic-gate 		prt_hhx(pri, 0, val);
1269*7c478bd9Sstevel@tonic-gate 	else {
1270*7c478bd9Sstevel@tonic-gate #define	CBSIZE	sizeof (pri->code_buf)
1271*7c478bd9Sstevel@tonic-gate 		s = pri->code_buf;
1272*7c478bd9Sstevel@tonic-gate 		*s = '\0';
1273*7c478bd9Sstevel@tonic-gate 		if (val & CC_GLOBAL_PATH)
1274*7c478bd9Sstevel@tonic-gate 			(void) strlcat(s, "|CC_GLOBAL_PATH", CBSIZE);
1275*7c478bd9Sstevel@tonic-gate 		if (val & CC_PROCESS_PATH)
1276*7c478bd9Sstevel@tonic-gate 			(void) strlcat(s, "|CC_PROCESS_PATH", CBSIZE);
1277*7c478bd9Sstevel@tonic-gate 		if (val & CC_GLOBAL_SETID)
1278*7c478bd9Sstevel@tonic-gate 			(void) strlcat(s, "|CC_GLOBAL_SETID", CBSIZE);
1279*7c478bd9Sstevel@tonic-gate 		if (val & CC_PROCESS_SETID)
1280*7c478bd9Sstevel@tonic-gate 			(void) strlcat(s, "|CC_PROCESS_SETID", CBSIZE);
1281*7c478bd9Sstevel@tonic-gate 		if (val & CC_GLOBAL_LOG)
1282*7c478bd9Sstevel@tonic-gate 			(void) strlcat(s, "|CC_GLOBAL_LOG", CBSIZE);
1283*7c478bd9Sstevel@tonic-gate 		if (*s == '\0')
1284*7c478bd9Sstevel@tonic-gate 			prt_hhx(pri, 0, val);
1285*7c478bd9Sstevel@tonic-gate 		else
1286*7c478bd9Sstevel@tonic-gate 			outstring(pri, ++s);
1287*7c478bd9Sstevel@tonic-gate #undef CBSIZE
1288*7c478bd9Sstevel@tonic-gate 	}
1289*7c478bd9Sstevel@tonic-gate }
1290*7c478bd9Sstevel@tonic-gate 
1291*7c478bd9Sstevel@tonic-gate void
1292*7c478bd9Sstevel@tonic-gate prt_ccc(private_t *pri, int raw, long val)	/* print corectl() content */
1293*7c478bd9Sstevel@tonic-gate {
1294*7c478bd9Sstevel@tonic-gate 	core_content_t ccc;
1295*7c478bd9Sstevel@tonic-gate 
1296*7c478bd9Sstevel@tonic-gate 	if (Pread(Proc, &ccc, sizeof (ccc), val) != sizeof (ccc))
1297*7c478bd9Sstevel@tonic-gate 		prt_hex(pri, 0, val);
1298*7c478bd9Sstevel@tonic-gate 	else if (!raw && proc_content2str(ccc, pri->code_buf,
1299*7c478bd9Sstevel@tonic-gate 	    sizeof (pri->code_buf)) >= 0)
1300*7c478bd9Sstevel@tonic-gate 		outstring(pri, pri->code_buf);
1301*7c478bd9Sstevel@tonic-gate 	else
1302*7c478bd9Sstevel@tonic-gate 		prt_hhx(pri, 0, (long)ccc);
1303*7c478bd9Sstevel@tonic-gate }
1304*7c478bd9Sstevel@tonic-gate 
1305*7c478bd9Sstevel@tonic-gate void
1306*7c478bd9Sstevel@tonic-gate prt_rcc(private_t *pri, int raw, long val)	/* print corectl() ret. cont. */
1307*7c478bd9Sstevel@tonic-gate {
1308*7c478bd9Sstevel@tonic-gate 	core_content_t ccc;
1309*7c478bd9Sstevel@tonic-gate 
1310*7c478bd9Sstevel@tonic-gate 	if (pri->Errno || Pread(Proc, &ccc, sizeof (ccc), val) != sizeof (ccc))
1311*7c478bd9Sstevel@tonic-gate 		prt_hex(pri, 0, val);
1312*7c478bd9Sstevel@tonic-gate 	else if (!raw && proc_content2str(ccc, pri->code_buf,
1313*7c478bd9Sstevel@tonic-gate 	    sizeof (pri->code_buf)) >= 0)
1314*7c478bd9Sstevel@tonic-gate 		outstring(pri, pri->code_buf);
1315*7c478bd9Sstevel@tonic-gate 	else
1316*7c478bd9Sstevel@tonic-gate 		prt_hhx(pri, 0, (long)ccc);
1317*7c478bd9Sstevel@tonic-gate }
1318*7c478bd9Sstevel@tonic-gate 
1319*7c478bd9Sstevel@tonic-gate void
1320*7c478bd9Sstevel@tonic-gate prt_cpc(private_t *pri, int raw, long val)	/* print cpc() subcode */
1321*7c478bd9Sstevel@tonic-gate {
1322*7c478bd9Sstevel@tonic-gate 	const char *s = NULL;
1323*7c478bd9Sstevel@tonic-gate 
1324*7c478bd9Sstevel@tonic-gate 	if (!raw) {
1325*7c478bd9Sstevel@tonic-gate 		switch (val) {
1326*7c478bd9Sstevel@tonic-gate 		case CPC_BIND:		s = "CPC_BIND";		break;
1327*7c478bd9Sstevel@tonic-gate 		case CPC_SAMPLE:	s = "CPC_SAMPLE";	break;
1328*7c478bd9Sstevel@tonic-gate 		case CPC_INVALIDATE:	s = "CPC_INVALIDATE";	break;
1329*7c478bd9Sstevel@tonic-gate 		case CPC_RELE:		s = "CPC_RELE";		break;
1330*7c478bd9Sstevel@tonic-gate 		case CPC_EVLIST_SIZE:	s = "CPC_EVLIST_SIZE";	break;
1331*7c478bd9Sstevel@tonic-gate 		case CPC_LIST_EVENTS:	s = "CPC_LIST_EVENTS";	break;
1332*7c478bd9Sstevel@tonic-gate 		case CPC_ATTRLIST_SIZE:	s = "CPC_ATTRLIST_SIZE"; break;
1333*7c478bd9Sstevel@tonic-gate 		case CPC_LIST_ATTRS:	s = "CPC_LIST_ATTRS";	break;
1334*7c478bd9Sstevel@tonic-gate 		case CPC_IMPL_NAME:	s = "CPC_IMPL_NAME";	break;
1335*7c478bd9Sstevel@tonic-gate 		case CPC_CPUREF:	s = "CPC_CPUREF";	break;
1336*7c478bd9Sstevel@tonic-gate 		case CPC_USR_EVENTS:	s = "CPC_USR_EVENTS";	break;
1337*7c478bd9Sstevel@tonic-gate 		case CPC_SYS_EVENTS:	s = "CPC_SYS_EVENTS";	break;
1338*7c478bd9Sstevel@tonic-gate 		case CPC_NPIC:		s = "CPC_NPIC";		break;
1339*7c478bd9Sstevel@tonic-gate 		case CPC_CAPS:		s = "CPC_CAPS";		break;
1340*7c478bd9Sstevel@tonic-gate 		case CPC_ENABLE:	s = "CPC_ENABLE";	break;
1341*7c478bd9Sstevel@tonic-gate 		case CPC_DISABLE:	s = "CPC_DISABLE";	break;
1342*7c478bd9Sstevel@tonic-gate 		}
1343*7c478bd9Sstevel@tonic-gate 	}
1344*7c478bd9Sstevel@tonic-gate 
1345*7c478bd9Sstevel@tonic-gate 	if (s == NULL)
1346*7c478bd9Sstevel@tonic-gate 		prt_dec(pri, 0, val);
1347*7c478bd9Sstevel@tonic-gate 	else
1348*7c478bd9Sstevel@tonic-gate 		outstring(pri, s);
1349*7c478bd9Sstevel@tonic-gate }
1350*7c478bd9Sstevel@tonic-gate 
1351*7c478bd9Sstevel@tonic-gate void
1352*7c478bd9Sstevel@tonic-gate outstring(private_t *pri, const char *s)
1353*7c478bd9Sstevel@tonic-gate {
1354*7c478bd9Sstevel@tonic-gate 	int len = strlen(s);
1355*7c478bd9Sstevel@tonic-gate 
1356*7c478bd9Sstevel@tonic-gate 	GROW(len);
1357*7c478bd9Sstevel@tonic-gate 	(void) strcpy(pri->sys_string + pri->sys_leng, s);
1358*7c478bd9Sstevel@tonic-gate 	pri->sys_leng += len;
1359*7c478bd9Sstevel@tonic-gate }
1360*7c478bd9Sstevel@tonic-gate 
1361*7c478bd9Sstevel@tonic-gate void
1362*7c478bd9Sstevel@tonic-gate grow(private_t *pri, int nbyte)	/* reallocate format buffer if necessary */
1363*7c478bd9Sstevel@tonic-gate {
1364*7c478bd9Sstevel@tonic-gate 	while (pri->sys_leng + nbyte >= pri->sys_ssize)
1365*7c478bd9Sstevel@tonic-gate 		pri->sys_string = my_realloc(pri->sys_string,
1366*7c478bd9Sstevel@tonic-gate 			pri->sys_ssize *= 2, "format buffer");
1367*7c478bd9Sstevel@tonic-gate }
1368*7c478bd9Sstevel@tonic-gate 
1369*7c478bd9Sstevel@tonic-gate void
1370*7c478bd9Sstevel@tonic-gate prt_clc(private_t *pri, int raw, long val)
1371*7c478bd9Sstevel@tonic-gate {
1372*7c478bd9Sstevel@tonic-gate 	const char *s = NULL;
1373*7c478bd9Sstevel@tonic-gate 
1374*7c478bd9Sstevel@tonic-gate 	if (!raw) {
1375*7c478bd9Sstevel@tonic-gate 		switch (val) {
1376*7c478bd9Sstevel@tonic-gate 		case CL_INITIALIZE:	s = "CL_INITIALIZE";	break;
1377*7c478bd9Sstevel@tonic-gate 		case CL_CONFIG:		s = "CL_CONFIG";	break;
1378*7c478bd9Sstevel@tonic-gate 		}
1379*7c478bd9Sstevel@tonic-gate 	}
1380*7c478bd9Sstevel@tonic-gate 
1381*7c478bd9Sstevel@tonic-gate 	if (s == NULL)
1382*7c478bd9Sstevel@tonic-gate 		prt_dec(pri, 0, val);
1383*7c478bd9Sstevel@tonic-gate 	else
1384*7c478bd9Sstevel@tonic-gate 		outstring(pri, s);
1385*7c478bd9Sstevel@tonic-gate }
1386*7c478bd9Sstevel@tonic-gate 
1387*7c478bd9Sstevel@tonic-gate void
1388*7c478bd9Sstevel@tonic-gate prt_clf(private_t *pri, int raw, long val)
1389*7c478bd9Sstevel@tonic-gate {
1390*7c478bd9Sstevel@tonic-gate 	const char *s = NULL;
1391*7c478bd9Sstevel@tonic-gate 
1392*7c478bd9Sstevel@tonic-gate 	if (!raw) {
1393*7c478bd9Sstevel@tonic-gate 		switch (pri->sys_args[0]) {
1394*7c478bd9Sstevel@tonic-gate 		case CL_CONFIG:
1395*7c478bd9Sstevel@tonic-gate 			switch (pri->sys_args[1]) {
1396*7c478bd9Sstevel@tonic-gate 			case CL_NODEID:
1397*7c478bd9Sstevel@tonic-gate 				s = "CL_NODEID";		break;
1398*7c478bd9Sstevel@tonic-gate 			case CL_HIGHEST_NODEID:
1399*7c478bd9Sstevel@tonic-gate 				s = "CL_HIGHEST_NODEID";	break;
1400*7c478bd9Sstevel@tonic-gate 			}
1401*7c478bd9Sstevel@tonic-gate 			break;
1402*7c478bd9Sstevel@tonic-gate 		case CL_INITIALIZE:
1403*7c478bd9Sstevel@tonic-gate 			switch (pri->sys_args[1]) {
1404*7c478bd9Sstevel@tonic-gate 			case CL_GET_BOOTFLAG:
1405*7c478bd9Sstevel@tonic-gate 				s = "CL_GET_BOOTFLAG";		break;
1406*7c478bd9Sstevel@tonic-gate 			}
1407*7c478bd9Sstevel@tonic-gate 			break;
1408*7c478bd9Sstevel@tonic-gate 		}
1409*7c478bd9Sstevel@tonic-gate 	}
1410*7c478bd9Sstevel@tonic-gate 
1411*7c478bd9Sstevel@tonic-gate 	if (s == NULL)
1412*7c478bd9Sstevel@tonic-gate 		prt_dec(pri, 0, val);
1413*7c478bd9Sstevel@tonic-gate 	else
1414*7c478bd9Sstevel@tonic-gate 		outstring(pri, s);
1415*7c478bd9Sstevel@tonic-gate }
1416*7c478bd9Sstevel@tonic-gate 
1417*7c478bd9Sstevel@tonic-gate void
1418*7c478bd9Sstevel@tonic-gate prt_sqc(private_t *pri, int raw, long val)	/* print sigqueue() si_code */
1419*7c478bd9Sstevel@tonic-gate {
1420*7c478bd9Sstevel@tonic-gate 	const char *s = NULL;
1421*7c478bd9Sstevel@tonic-gate 
1422*7c478bd9Sstevel@tonic-gate 	if (!raw) {
1423*7c478bd9Sstevel@tonic-gate 		switch ((int)val) {
1424*7c478bd9Sstevel@tonic-gate 		case SI_QUEUE:		s = "SI_QUEUE";		break;
1425*7c478bd9Sstevel@tonic-gate 		case SI_TIMER:		s = "SI_TIMER";		break;
1426*7c478bd9Sstevel@tonic-gate 		case SI_ASYNCIO:	s = "SI_ASYNCIO";	break;
1427*7c478bd9Sstevel@tonic-gate 		case SI_MESGQ:		s = "SI_MESGQ";		break;
1428*7c478bd9Sstevel@tonic-gate 		}
1429*7c478bd9Sstevel@tonic-gate 	}
1430*7c478bd9Sstevel@tonic-gate 
1431*7c478bd9Sstevel@tonic-gate 	if (s == NULL)
1432*7c478bd9Sstevel@tonic-gate 		prt_dec(pri, 0, val);
1433*7c478bd9Sstevel@tonic-gate 	else
1434*7c478bd9Sstevel@tonic-gate 		outstring(pri, s);
1435*7c478bd9Sstevel@tonic-gate }
1436*7c478bd9Sstevel@tonic-gate 
1437*7c478bd9Sstevel@tonic-gate /*
1438*7c478bd9Sstevel@tonic-gate  * print priocntlsys() (key, value) pair key.
1439*7c478bd9Sstevel@tonic-gate  */
1440*7c478bd9Sstevel@tonic-gate void
1441*7c478bd9Sstevel@tonic-gate print_pck(private_t *pri, int raw, long val)
1442*7c478bd9Sstevel@tonic-gate {
1443*7c478bd9Sstevel@tonic-gate 	const char	*s = NULL;
1444*7c478bd9Sstevel@tonic-gate 	char		clname[PC_CLNMSZ];
1445*7c478bd9Sstevel@tonic-gate 
1446*7c478bd9Sstevel@tonic-gate 	if ((pri->sys_args[2] != PC_GETXPARMS &&
1447*7c478bd9Sstevel@tonic-gate 	    pri->sys_args[2] != PC_SETXPARMS) || val == 0 || raw) {
1448*7c478bd9Sstevel@tonic-gate 		prt_dec(pri, 0, val);
1449*7c478bd9Sstevel@tonic-gate 		return;
1450*7c478bd9Sstevel@tonic-gate 	}
1451*7c478bd9Sstevel@tonic-gate 
1452*7c478bd9Sstevel@tonic-gate 	if (pri->sys_args[3] == NULL) {
1453*7c478bd9Sstevel@tonic-gate 		if (val == PC_KY_CLNAME) {
1454*7c478bd9Sstevel@tonic-gate 			s = "PC_KY_CLNAME";
1455*7c478bd9Sstevel@tonic-gate 			outstring(pri, s);
1456*7c478bd9Sstevel@tonic-gate 		} else
1457*7c478bd9Sstevel@tonic-gate 			prt_dec(pri, 0, val);
1458*7c478bd9Sstevel@tonic-gate 		return;
1459*7c478bd9Sstevel@tonic-gate 	}
1460*7c478bd9Sstevel@tonic-gate 
1461*7c478bd9Sstevel@tonic-gate 	if (Pread(Proc, &clname, PC_CLNMSZ, pri->sys_args[3]) != PC_CLNMSZ) {
1462*7c478bd9Sstevel@tonic-gate 		prt_dec(pri, 0, val);
1463*7c478bd9Sstevel@tonic-gate 		return;
1464*7c478bd9Sstevel@tonic-gate 	}
1465*7c478bd9Sstevel@tonic-gate 
1466*7c478bd9Sstevel@tonic-gate 	if (strcmp(clname, "TS") == 0) {
1467*7c478bd9Sstevel@tonic-gate 		switch (val) {
1468*7c478bd9Sstevel@tonic-gate 		case TS_KY_UPRILIM: 	s = "TS_KY_UPRILIM";	break;
1469*7c478bd9Sstevel@tonic-gate 		case TS_KY_UPRI:	s = "TS_KY_UPRI";	break;
1470*7c478bd9Sstevel@tonic-gate 		default:					break;
1471*7c478bd9Sstevel@tonic-gate 		}
1472*7c478bd9Sstevel@tonic-gate 	} else if (strcmp(clname, "IA") == 0) {
1473*7c478bd9Sstevel@tonic-gate 		switch (val) {
1474*7c478bd9Sstevel@tonic-gate 		case IA_KY_UPRILIM: 	s = "IA_KY_UPRILIM";	break;
1475*7c478bd9Sstevel@tonic-gate 		case IA_KY_UPRI:	s = "IA_KY_UPRI";	break;
1476*7c478bd9Sstevel@tonic-gate 		case IA_KY_MODE:	s = "IA_KY_MODE";	break;
1477*7c478bd9Sstevel@tonic-gate 		default:					break;
1478*7c478bd9Sstevel@tonic-gate 		}
1479*7c478bd9Sstevel@tonic-gate 	} else if (strcmp(clname, "RT") == 0) {
1480*7c478bd9Sstevel@tonic-gate 		switch (val) {
1481*7c478bd9Sstevel@tonic-gate 		case RT_KY_PRI: 	s = "RT_KY_PRI";	break;
1482*7c478bd9Sstevel@tonic-gate 		case RT_KY_TQSECS:	s = "RT_KY_TQSECS";	break;
1483*7c478bd9Sstevel@tonic-gate 		case RT_KY_TQNSECS:	s = "RT_KY_TQNSECS";	break;
1484*7c478bd9Sstevel@tonic-gate 		case RT_KY_TQSIG:	s = "RT_KY_TQSIG";	break;
1485*7c478bd9Sstevel@tonic-gate 		default:					break;
1486*7c478bd9Sstevel@tonic-gate 		}
1487*7c478bd9Sstevel@tonic-gate 	} else if (strcmp(clname, "FSS") == 0) {
1488*7c478bd9Sstevel@tonic-gate 		switch (val) {
1489*7c478bd9Sstevel@tonic-gate 		case FSS_KY_UPRILIM: 	s = "FSS_KY_UPRILIM";	break;
1490*7c478bd9Sstevel@tonic-gate 		case FSS_KY_UPRI:	s = "FSS_KY_UPRI";	break;
1491*7c478bd9Sstevel@tonic-gate 		default:					break;
1492*7c478bd9Sstevel@tonic-gate 		}
1493*7c478bd9Sstevel@tonic-gate 	} else if (strcmp(clname, "FX") == 0) {
1494*7c478bd9Sstevel@tonic-gate 		switch (val) {
1495*7c478bd9Sstevel@tonic-gate 		case FX_KY_UPRILIM: 	s = "FX_KY_UPRILIM";	break;
1496*7c478bd9Sstevel@tonic-gate 		case FX_KY_UPRI:	s = "FX_KY_UPRI";	break;
1497*7c478bd9Sstevel@tonic-gate 		case FX_KY_TQSECS:	s = "FX_KY_TQSECS";	break;
1498*7c478bd9Sstevel@tonic-gate 		case FX_KY_TQNSECS:	s = "FX_KY_TQNSECS";	break;
1499*7c478bd9Sstevel@tonic-gate 		default:					break;
1500*7c478bd9Sstevel@tonic-gate 		}
1501*7c478bd9Sstevel@tonic-gate 	}
1502*7c478bd9Sstevel@tonic-gate 
1503*7c478bd9Sstevel@tonic-gate 	if (s == NULL)
1504*7c478bd9Sstevel@tonic-gate 		prt_dec(pri, 0, val);
1505*7c478bd9Sstevel@tonic-gate 	else
1506*7c478bd9Sstevel@tonic-gate 		outstring(pri, s);
1507*7c478bd9Sstevel@tonic-gate }
1508*7c478bd9Sstevel@tonic-gate 
1509*7c478bd9Sstevel@tonic-gate /*
1510*7c478bd9Sstevel@tonic-gate  * print priocntlsys() fourth argument.
1511*7c478bd9Sstevel@tonic-gate  */
1512*7c478bd9Sstevel@tonic-gate /*ARGSUSED*/
1513*7c478bd9Sstevel@tonic-gate void
1514*7c478bd9Sstevel@tonic-gate prt_pc4(private_t *pri, int raw, long val)
1515*7c478bd9Sstevel@tonic-gate {
1516*7c478bd9Sstevel@tonic-gate 	/* look at pricntlsys function */
1517*7c478bd9Sstevel@tonic-gate 	if ((pri->sys_args[2] != PC_GETXPARMS &&
1518*7c478bd9Sstevel@tonic-gate 	    pri->sys_args[2] != PC_SETXPARMS))
1519*7c478bd9Sstevel@tonic-gate 		prt_hex(pri, 0, val);
1520*7c478bd9Sstevel@tonic-gate 	else if (val)
1521*7c478bd9Sstevel@tonic-gate 		prt_stg(pri, 0, val);
1522*7c478bd9Sstevel@tonic-gate 	else
1523*7c478bd9Sstevel@tonic-gate 		prt_dec(pri, 0, val);
1524*7c478bd9Sstevel@tonic-gate }
1525*7c478bd9Sstevel@tonic-gate 
1526*7c478bd9Sstevel@tonic-gate /*
1527*7c478bd9Sstevel@tonic-gate  * print priocntlsys() (key, value) pairs (5th argument).
1528*7c478bd9Sstevel@tonic-gate  */
1529*7c478bd9Sstevel@tonic-gate /*ARGSUSED*/
1530*7c478bd9Sstevel@tonic-gate void
1531*7c478bd9Sstevel@tonic-gate prt_pc5(private_t *pri, int raw, long val)
1532*7c478bd9Sstevel@tonic-gate {
1533*7c478bd9Sstevel@tonic-gate 	pc_vaparms_t	prms;
1534*7c478bd9Sstevel@tonic-gate 	pc_vaparm_t	*vpp = &prms.pc_parms[0];
1535*7c478bd9Sstevel@tonic-gate 	uint_t		cnt;
1536*7c478bd9Sstevel@tonic-gate 
1537*7c478bd9Sstevel@tonic-gate 
1538*7c478bd9Sstevel@tonic-gate 	/* look at pricntlsys function */
1539*7c478bd9Sstevel@tonic-gate 	if ((pri->sys_args[2] != PC_GETXPARMS &&
1540*7c478bd9Sstevel@tonic-gate 	    pri->sys_args[2] != PC_SETXPARMS) || val == 0) {
1541*7c478bd9Sstevel@tonic-gate 		prt_dec(pri, 0, 0);
1542*7c478bd9Sstevel@tonic-gate 		return;
1543*7c478bd9Sstevel@tonic-gate 	}
1544*7c478bd9Sstevel@tonic-gate 
1545*7c478bd9Sstevel@tonic-gate 	if (Pread(Proc, &prms, sizeof (prms), val) != sizeof (prms)) {
1546*7c478bd9Sstevel@tonic-gate 		prt_hex(pri, 0, val);
1547*7c478bd9Sstevel@tonic-gate 		return;
1548*7c478bd9Sstevel@tonic-gate 	}
1549*7c478bd9Sstevel@tonic-gate 
1550*7c478bd9Sstevel@tonic-gate 	if ((cnt = prms.pc_vaparmscnt) > PC_VAPARMCNT)
1551*7c478bd9Sstevel@tonic-gate 		return;
1552*7c478bd9Sstevel@tonic-gate 
1553*7c478bd9Sstevel@tonic-gate 	for (; cnt--; vpp++) {
1554*7c478bd9Sstevel@tonic-gate 		print_pck(pri, 0, vpp->pc_key);
1555*7c478bd9Sstevel@tonic-gate 		outstring(pri, ", ");
1556*7c478bd9Sstevel@tonic-gate 		prt_hex(pri, 0, (long)vpp->pc_parm);
1557*7c478bd9Sstevel@tonic-gate 		outstring(pri, ", ");
1558*7c478bd9Sstevel@tonic-gate 	}
1559*7c478bd9Sstevel@tonic-gate 
1560*7c478bd9Sstevel@tonic-gate 	prt_dec(pri, 0, PC_KY_NULL);
1561*7c478bd9Sstevel@tonic-gate }
1562*7c478bd9Sstevel@tonic-gate 
1563*7c478bd9Sstevel@tonic-gate /*
1564*7c478bd9Sstevel@tonic-gate  * Print processor set id, including logical expansion of "special" ids.
1565*7c478bd9Sstevel@tonic-gate  */
1566*7c478bd9Sstevel@tonic-gate void
1567*7c478bd9Sstevel@tonic-gate prt_pst(private_t *pri, int raw, long val)
1568*7c478bd9Sstevel@tonic-gate {
1569*7c478bd9Sstevel@tonic-gate 	const char *s = NULL;
1570*7c478bd9Sstevel@tonic-gate 
1571*7c478bd9Sstevel@tonic-gate 	if (!raw) {
1572*7c478bd9Sstevel@tonic-gate 		switch ((psetid_t)val) {
1573*7c478bd9Sstevel@tonic-gate 		case PS_NONE:		s = "PS_NONE";		break;
1574*7c478bd9Sstevel@tonic-gate 		case PS_QUERY:		s = "PS_QUERY";		break;
1575*7c478bd9Sstevel@tonic-gate 		case PS_MYID:		s = "PS_MYID";		break;
1576*7c478bd9Sstevel@tonic-gate 		}
1577*7c478bd9Sstevel@tonic-gate 	}
1578*7c478bd9Sstevel@tonic-gate 
1579*7c478bd9Sstevel@tonic-gate 	if (s == NULL)
1580*7c478bd9Sstevel@tonic-gate 		prt_dec(pri, 0, val);
1581*7c478bd9Sstevel@tonic-gate 	else
1582*7c478bd9Sstevel@tonic-gate 		outstring(pri, s);
1583*7c478bd9Sstevel@tonic-gate }
1584*7c478bd9Sstevel@tonic-gate 
1585*7c478bd9Sstevel@tonic-gate /*
1586*7c478bd9Sstevel@tonic-gate  * Print meminfo() argument.
1587*7c478bd9Sstevel@tonic-gate  */
1588*7c478bd9Sstevel@tonic-gate /*ARGSUSED*/
1589*7c478bd9Sstevel@tonic-gate void
1590*7c478bd9Sstevel@tonic-gate prt_mif(private_t *pri, int raw, long val)
1591*7c478bd9Sstevel@tonic-gate {
1592*7c478bd9Sstevel@tonic-gate 	struct meminfo	minfo;
1593*7c478bd9Sstevel@tonic-gate 
1594*7c478bd9Sstevel@tonic-gate #ifdef _LP64
1595*7c478bd9Sstevel@tonic-gate 	if (data_model == PR_MODEL_ILP32) {
1596*7c478bd9Sstevel@tonic-gate 		struct meminfo32 minfo32;
1597*7c478bd9Sstevel@tonic-gate 
1598*7c478bd9Sstevel@tonic-gate 		if (Pread(Proc, &minfo32, sizeof (struct meminfo32), val) !=
1599*7c478bd9Sstevel@tonic-gate 			sizeof (struct meminfo32)) {
1600*7c478bd9Sstevel@tonic-gate 			prt_dec(pri, 0, pri->sys_args[1]);	/* addr_count */
1601*7c478bd9Sstevel@tonic-gate 			outstring(pri, ", ");
1602*7c478bd9Sstevel@tonic-gate 			prt_hex(pri, 0, val);
1603*7c478bd9Sstevel@tonic-gate 			return;
1604*7c478bd9Sstevel@tonic-gate 		}
1605*7c478bd9Sstevel@tonic-gate 		/*
1606*7c478bd9Sstevel@tonic-gate 		 * arrange the arguments in the order that user calls with
1607*7c478bd9Sstevel@tonic-gate 		 */
1608*7c478bd9Sstevel@tonic-gate 		prt_hex(pri, 0, minfo32.mi_inaddr);
1609*7c478bd9Sstevel@tonic-gate 		outstring(pri, ", ");
1610*7c478bd9Sstevel@tonic-gate 		prt_dec(pri, 0, pri->sys_args[1]);	/* addr_count */
1611*7c478bd9Sstevel@tonic-gate 		outstring(pri, ", ");
1612*7c478bd9Sstevel@tonic-gate 		prt_hex(pri, 0, minfo32.mi_info_req);
1613*7c478bd9Sstevel@tonic-gate 		outstring(pri, ", ");
1614*7c478bd9Sstevel@tonic-gate 		prt_dec(pri, 0, minfo32.mi_info_count);
1615*7c478bd9Sstevel@tonic-gate 		outstring(pri, ", ");
1616*7c478bd9Sstevel@tonic-gate 		prt_hex(pri, 0, minfo32.mi_outdata);
1617*7c478bd9Sstevel@tonic-gate 		outstring(pri, ", ");
1618*7c478bd9Sstevel@tonic-gate 		prt_hex(pri, 0, minfo32.mi_validity);
1619*7c478bd9Sstevel@tonic-gate 		return;
1620*7c478bd9Sstevel@tonic-gate 	}
1621*7c478bd9Sstevel@tonic-gate #endif
1622*7c478bd9Sstevel@tonic-gate 	if (Pread(Proc, &minfo, sizeof (struct meminfo), val) !=
1623*7c478bd9Sstevel@tonic-gate 		sizeof (struct meminfo)) {
1624*7c478bd9Sstevel@tonic-gate 		prt_dec(pri, 0, pri->sys_args[1]);	/* addr_count */
1625*7c478bd9Sstevel@tonic-gate 		outstring(pri, ", ");
1626*7c478bd9Sstevel@tonic-gate 		prt_hex(pri, 0, val);
1627*7c478bd9Sstevel@tonic-gate 		return;
1628*7c478bd9Sstevel@tonic-gate 	}
1629*7c478bd9Sstevel@tonic-gate 	/*
1630*7c478bd9Sstevel@tonic-gate 	 * arrange the arguments in the order that user calls with
1631*7c478bd9Sstevel@tonic-gate 	 */
1632*7c478bd9Sstevel@tonic-gate 	prt_hex(pri, 0, (long)minfo.mi_inaddr);
1633*7c478bd9Sstevel@tonic-gate 	outstring(pri, ", ");
1634*7c478bd9Sstevel@tonic-gate 	prt_dec(pri, 0, pri->sys_args[1]);	/* addr_count */
1635*7c478bd9Sstevel@tonic-gate 	outstring(pri, ", ");
1636*7c478bd9Sstevel@tonic-gate 	prt_hex(pri, 0, (long)minfo.mi_info_req);
1637*7c478bd9Sstevel@tonic-gate 	outstring(pri, ", ");
1638*7c478bd9Sstevel@tonic-gate 	prt_dec(pri, 0, minfo.mi_info_count);
1639*7c478bd9Sstevel@tonic-gate 	outstring(pri, ", ");
1640*7c478bd9Sstevel@tonic-gate 	prt_hex(pri, 0, (long)minfo.mi_outdata);
1641*7c478bd9Sstevel@tonic-gate 	outstring(pri, ", ");
1642*7c478bd9Sstevel@tonic-gate 	prt_hex(pri, 0, (long)minfo.mi_validity);
1643*7c478bd9Sstevel@tonic-gate }
1644*7c478bd9Sstevel@tonic-gate 
1645*7c478bd9Sstevel@tonic-gate 
1646*7c478bd9Sstevel@tonic-gate /*
1647*7c478bd9Sstevel@tonic-gate  * Print so_socket() 1st argument.
1648*7c478bd9Sstevel@tonic-gate  */
1649*7c478bd9Sstevel@tonic-gate /*ARGSUSED*/
1650*7c478bd9Sstevel@tonic-gate void
1651*7c478bd9Sstevel@tonic-gate prt_pfm(private_t *pri, int raw, long val)
1652*7c478bd9Sstevel@tonic-gate {
1653*7c478bd9Sstevel@tonic-gate 	/* Protocol Families have same names as Address Families */
1654*7c478bd9Sstevel@tonic-gate 	if ((ulong_t)val < MAX_AFCODES) {
1655*7c478bd9Sstevel@tonic-gate 		outstring(pri, "PF_");
1656*7c478bd9Sstevel@tonic-gate 		outstring(pri, afcodes[val]);
1657*7c478bd9Sstevel@tonic-gate 	} else {
1658*7c478bd9Sstevel@tonic-gate 		prt_dec(pri, 0, val);
1659*7c478bd9Sstevel@tonic-gate 	}
1660*7c478bd9Sstevel@tonic-gate }
1661*7c478bd9Sstevel@tonic-gate 
1662*7c478bd9Sstevel@tonic-gate 
1663*7c478bd9Sstevel@tonic-gate /*
1664*7c478bd9Sstevel@tonic-gate  * Print so_socket() 2nd argument.
1665*7c478bd9Sstevel@tonic-gate  */
1666*7c478bd9Sstevel@tonic-gate /*ARGSUSED*/
1667*7c478bd9Sstevel@tonic-gate void
1668*7c478bd9Sstevel@tonic-gate prt_skt(private_t *pri, int raw, long val)
1669*7c478bd9Sstevel@tonic-gate {
1670*7c478bd9Sstevel@tonic-gate 	const char *s;
1671*7c478bd9Sstevel@tonic-gate 
1672*7c478bd9Sstevel@tonic-gate 	if ((ulong_t)val <= MAX_SOCKTYPES && (s = socktype_codes[val]) != NULL)
1673*7c478bd9Sstevel@tonic-gate 		outstring(pri, s);
1674*7c478bd9Sstevel@tonic-gate 	else
1675*7c478bd9Sstevel@tonic-gate 		prt_dec(pri, 0, val);
1676*7c478bd9Sstevel@tonic-gate }
1677*7c478bd9Sstevel@tonic-gate 
1678*7c478bd9Sstevel@tonic-gate 
1679*7c478bd9Sstevel@tonic-gate /*
1680*7c478bd9Sstevel@tonic-gate  * Print so_socket() 3rd argument.
1681*7c478bd9Sstevel@tonic-gate  */
1682*7c478bd9Sstevel@tonic-gate /*ARGSUSED*/
1683*7c478bd9Sstevel@tonic-gate void
1684*7c478bd9Sstevel@tonic-gate prt_skp(private_t *pri, int raw, long val)
1685*7c478bd9Sstevel@tonic-gate {
1686*7c478bd9Sstevel@tonic-gate 	const char *s;
1687*7c478bd9Sstevel@tonic-gate 
1688*7c478bd9Sstevel@tonic-gate 	/* cheating -- look at the protocol-family */
1689*7c478bd9Sstevel@tonic-gate 	switch (pri->sys_args[0]) {
1690*7c478bd9Sstevel@tonic-gate 	case PF_INET6:
1691*7c478bd9Sstevel@tonic-gate 	case PF_INET:
1692*7c478bd9Sstevel@tonic-gate 	case PF_NCA:	if ((s = ipprotos((int)val)) != NULL) {
1693*7c478bd9Sstevel@tonic-gate 				outstring(pri, s);
1694*7c478bd9Sstevel@tonic-gate 				break;
1695*7c478bd9Sstevel@tonic-gate 			}
1696*7c478bd9Sstevel@tonic-gate 			/* FALLTHROUGH */
1697*7c478bd9Sstevel@tonic-gate 	default:	prt_dec(pri, 0, val);
1698*7c478bd9Sstevel@tonic-gate 			break;
1699*7c478bd9Sstevel@tonic-gate 	}
1700*7c478bd9Sstevel@tonic-gate }
1701*7c478bd9Sstevel@tonic-gate 
1702*7c478bd9Sstevel@tonic-gate 
1703*7c478bd9Sstevel@tonic-gate /*
1704*7c478bd9Sstevel@tonic-gate  * Print so_socket() 5th argument.
1705*7c478bd9Sstevel@tonic-gate  */
1706*7c478bd9Sstevel@tonic-gate /*ARGSUSED*/
1707*7c478bd9Sstevel@tonic-gate void
1708*7c478bd9Sstevel@tonic-gate prt_skv(private_t *pri, int raw, long val)
1709*7c478bd9Sstevel@tonic-gate {
1710*7c478bd9Sstevel@tonic-gate 	switch (val) {
1711*7c478bd9Sstevel@tonic-gate 	case SOV_STREAM:	outstring(pri, "SOV_STREAM");	break;
1712*7c478bd9Sstevel@tonic-gate 	case SOV_DEFAULT:	outstring(pri, "SOV_DEFAULT");	break;
1713*7c478bd9Sstevel@tonic-gate 	case SOV_SOCKSTREAM:	outstring(pri, "SOV_SOCKSTREAM");	break;
1714*7c478bd9Sstevel@tonic-gate 	case SOV_SOCKBSD:	outstring(pri, "SOV_SOCKBSD");	break;
1715*7c478bd9Sstevel@tonic-gate 	case SOV_XPG4_2:	outstring(pri, "SOV_XPG4_2");	break;
1716*7c478bd9Sstevel@tonic-gate 	default:		prt_dec(pri, 0, val);		break;
1717*7c478bd9Sstevel@tonic-gate 	}
1718*7c478bd9Sstevel@tonic-gate }
1719*7c478bd9Sstevel@tonic-gate 
1720*7c478bd9Sstevel@tonic-gate 
1721*7c478bd9Sstevel@tonic-gate /*
1722*7c478bd9Sstevel@tonic-gate  * Print setsockopt()/getsockopt() 2nd argument.
1723*7c478bd9Sstevel@tonic-gate  */
1724*7c478bd9Sstevel@tonic-gate /*ARGSUSED*/
1725*7c478bd9Sstevel@tonic-gate void
1726*7c478bd9Sstevel@tonic-gate prt_sol(private_t *pri, int raw, long val)
1727*7c478bd9Sstevel@tonic-gate {
1728*7c478bd9Sstevel@tonic-gate 	if (val == SOL_SOCKET) {
1729*7c478bd9Sstevel@tonic-gate 		outstring(pri, "SOL_SOCKET");
1730*7c478bd9Sstevel@tonic-gate 	} else {
1731*7c478bd9Sstevel@tonic-gate 		const struct protoent *p;
1732*7c478bd9Sstevel@tonic-gate 		struct protoent res;
1733*7c478bd9Sstevel@tonic-gate 		char buf[NSS_BUFLEN_PROTOCOLS];
1734*7c478bd9Sstevel@tonic-gate 
1735*7c478bd9Sstevel@tonic-gate 		if ((p = getprotobynumber_r(val, &res,
1736*7c478bd9Sstevel@tonic-gate 		    (char *)buf, sizeof (buf))) != NULL)
1737*7c478bd9Sstevel@tonic-gate 			outstring(pri, p->p_name);
1738*7c478bd9Sstevel@tonic-gate 		else
1739*7c478bd9Sstevel@tonic-gate 			prt_dec(pri, 0, val);
1740*7c478bd9Sstevel@tonic-gate 	}
1741*7c478bd9Sstevel@tonic-gate }
1742*7c478bd9Sstevel@tonic-gate 
1743*7c478bd9Sstevel@tonic-gate 
1744*7c478bd9Sstevel@tonic-gate const char *
1745*7c478bd9Sstevel@tonic-gate sol_optname(private_t *pri, long val)
1746*7c478bd9Sstevel@tonic-gate {
1747*7c478bd9Sstevel@tonic-gate #define	CBSIZE	sizeof (pri->code_buf)
1748*7c478bd9Sstevel@tonic-gate 	if (val >= SO_SNDBUF) {
1749*7c478bd9Sstevel@tonic-gate 		switch (val) {
1750*7c478bd9Sstevel@tonic-gate 		case SO_SNDBUF:		return ("SO_SNDBUF");
1751*7c478bd9Sstevel@tonic-gate 		case SO_RCVBUF:		return ("SO_RCVBUF");
1752*7c478bd9Sstevel@tonic-gate 		case SO_SNDLOWAT:	return ("SO_SNDLOWAT");
1753*7c478bd9Sstevel@tonic-gate 		case SO_RCVLOWAT:	return ("SO_RCVLOWAT");
1754*7c478bd9Sstevel@tonic-gate 		case SO_SNDTIMEO:	return ("SO_SNDTIMEO");
1755*7c478bd9Sstevel@tonic-gate 		case SO_RCVTIMEO:	return ("SO_RCVTIMEO");
1756*7c478bd9Sstevel@tonic-gate 		case SO_ERROR:		return ("SO_ERROR");
1757*7c478bd9Sstevel@tonic-gate 		case SO_TYPE:		return ("SO_TYPE");
1758*7c478bd9Sstevel@tonic-gate 		case SO_PROTOTYPE:	return ("SO_PROTOTYPE");
1759*7c478bd9Sstevel@tonic-gate 
1760*7c478bd9Sstevel@tonic-gate 		default:		(void) snprintf(pri->code_buf, CBSIZE,
1761*7c478bd9Sstevel@tonic-gate 						    "0x%lx", val);
1762*7c478bd9Sstevel@tonic-gate 					return (pri->code_buf);
1763*7c478bd9Sstevel@tonic-gate 		}
1764*7c478bd9Sstevel@tonic-gate 	} else {
1765*7c478bd9Sstevel@tonic-gate 		char *s = pri->code_buf;
1766*7c478bd9Sstevel@tonic-gate 		size_t used = 1;
1767*7c478bd9Sstevel@tonic-gate 		long val2;
1768*7c478bd9Sstevel@tonic-gate 
1769*7c478bd9Sstevel@tonic-gate 		*s = '\0';
1770*7c478bd9Sstevel@tonic-gate 		val2 = val & ~(SO_DEBUG|SO_ACCEPTCONN|SO_REUSEADDR|SO_KEEPALIVE|
1771*7c478bd9Sstevel@tonic-gate 		    SO_DONTROUTE|SO_BROADCAST|SO_USELOOPBACK|SO_LINGER|
1772*7c478bd9Sstevel@tonic-gate 		    SO_OOBINLINE|SO_DGRAM_ERRIND|SO_RECVUCRED);
1773*7c478bd9Sstevel@tonic-gate 		if (val2)
1774*7c478bd9Sstevel@tonic-gate 			used = snprintf(s, CBSIZE, "|0x%lx", val2);
1775*7c478bd9Sstevel@tonic-gate 		if (val & SO_DEBUG)
1776*7c478bd9Sstevel@tonic-gate 			used = strlcat(s, "|SO_DEBUG", CBSIZE);
1777*7c478bd9Sstevel@tonic-gate 		if (val & SO_ACCEPTCONN)
1778*7c478bd9Sstevel@tonic-gate 			used = strlcat(s, "|SO_ACCEPTCONN", CBSIZE);
1779*7c478bd9Sstevel@tonic-gate 		if (val & SO_REUSEADDR)
1780*7c478bd9Sstevel@tonic-gate 			used = strlcat(s, "|SO_REUSEADDR", CBSIZE);
1781*7c478bd9Sstevel@tonic-gate 		if (val & SO_KEEPALIVE)
1782*7c478bd9Sstevel@tonic-gate 			used = strlcat(s, "|SO_KEEPALIVE", CBSIZE);
1783*7c478bd9Sstevel@tonic-gate 		if (val & SO_DONTROUTE)
1784*7c478bd9Sstevel@tonic-gate 			used = strlcat(s, "|SO_DONTROUTE", CBSIZE);
1785*7c478bd9Sstevel@tonic-gate 		if (val & SO_BROADCAST)
1786*7c478bd9Sstevel@tonic-gate 			used = strlcat(s, "|SO_BROADCAST", CBSIZE);
1787*7c478bd9Sstevel@tonic-gate 		if (val & SO_USELOOPBACK)
1788*7c478bd9Sstevel@tonic-gate 			used = strlcat(s, "|SO_USELOOPBACK", CBSIZE);
1789*7c478bd9Sstevel@tonic-gate 		if (val & SO_LINGER)
1790*7c478bd9Sstevel@tonic-gate 			used = strlcat(s, "|SO_LINGER", CBSIZE);
1791*7c478bd9Sstevel@tonic-gate 		if (val & SO_OOBINLINE)
1792*7c478bd9Sstevel@tonic-gate 			used = strlcat(s, "|SO_OOBINLINE", CBSIZE);
1793*7c478bd9Sstevel@tonic-gate 		if (val & SO_DGRAM_ERRIND)
1794*7c478bd9Sstevel@tonic-gate 			used = strlcat(s, "|SO_DGRAM_ERRIND", CBSIZE);
1795*7c478bd9Sstevel@tonic-gate 		if (val & SO_RECVUCRED)
1796*7c478bd9Sstevel@tonic-gate 			used = strlcat(s, "|SO_RECVUCRED", CBSIZE);
1797*7c478bd9Sstevel@tonic-gate 		if (used >= CBSIZE || val == 0)
1798*7c478bd9Sstevel@tonic-gate 			(void) snprintf(s + 1, CBSIZE-1, "0x%lx", val);
1799*7c478bd9Sstevel@tonic-gate 		return ((const char *)(s + 1));
1800*7c478bd9Sstevel@tonic-gate 	}
1801*7c478bd9Sstevel@tonic-gate #undef CBSIZE
1802*7c478bd9Sstevel@tonic-gate }
1803*7c478bd9Sstevel@tonic-gate 
1804*7c478bd9Sstevel@tonic-gate 
1805*7c478bd9Sstevel@tonic-gate const char *
1806*7c478bd9Sstevel@tonic-gate tcp_optname(private_t *pri, long val)
1807*7c478bd9Sstevel@tonic-gate {
1808*7c478bd9Sstevel@tonic-gate 	switch (val) {
1809*7c478bd9Sstevel@tonic-gate 	case TCP_NODELAY:		return ("TCP_NODELAY");
1810*7c478bd9Sstevel@tonic-gate 	case TCP_MAXSEG:		return ("TCP_MAXSEG");
1811*7c478bd9Sstevel@tonic-gate 	case TCP_KEEPALIVE:		return ("TCP_KEEPALIVE");
1812*7c478bd9Sstevel@tonic-gate 	case TCP_NOTIFY_THRESHOLD:	return ("TCP_NOTIFY_THRESHOLD");
1813*7c478bd9Sstevel@tonic-gate 	case TCP_ABORT_THRESHOLD:	return ("TCP_ABORT_THRESHOLD");
1814*7c478bd9Sstevel@tonic-gate 	case TCP_CONN_NOTIFY_THRESHOLD:	return ("TCP_CONN_NOTIFY_THRESHOLD");
1815*7c478bd9Sstevel@tonic-gate 	case TCP_CONN_ABORT_THRESHOLD:	return ("TCP_CONN_ABORT_THRESHOLD");
1816*7c478bd9Sstevel@tonic-gate 	case TCP_RECVDSTADDR:		return ("TCP_RECVDSTADDR");
1817*7c478bd9Sstevel@tonic-gate 	case TCP_ANONPRIVBIND:		return ("TCP_ANONPRIVBIND");
1818*7c478bd9Sstevel@tonic-gate 	case TCP_EXCLBIND:		return ("TCP_EXCLBIND");
1819*7c478bd9Sstevel@tonic-gate 
1820*7c478bd9Sstevel@tonic-gate 	default:			(void) snprintf(pri->code_buf,
1821*7c478bd9Sstevel@tonic-gate 					    sizeof (pri->code_buf),
1822*7c478bd9Sstevel@tonic-gate 					    "0x%lx", val);
1823*7c478bd9Sstevel@tonic-gate 					return (pri->code_buf);
1824*7c478bd9Sstevel@tonic-gate 	}
1825*7c478bd9Sstevel@tonic-gate }
1826*7c478bd9Sstevel@tonic-gate 
1827*7c478bd9Sstevel@tonic-gate 
1828*7c478bd9Sstevel@tonic-gate const char *
1829*7c478bd9Sstevel@tonic-gate sctp_optname(private_t *pri, long val)
1830*7c478bd9Sstevel@tonic-gate {
1831*7c478bd9Sstevel@tonic-gate 	switch (val) {
1832*7c478bd9Sstevel@tonic-gate 	case SCTP_RTOINFO:		return ("SCTP_RTOINFO");
1833*7c478bd9Sstevel@tonic-gate 	case SCTP_ASSOCINFO:		return ("SCTP_ASSOCINFO");
1834*7c478bd9Sstevel@tonic-gate 	case SCTP_INITMSG:		return ("SCTP_INITMSG");
1835*7c478bd9Sstevel@tonic-gate 	case SCTP_NODELAY:		return ("SCTP_NODELAY");
1836*7c478bd9Sstevel@tonic-gate 	case SCTP_AUTOCLOSE:		return ("SCTP_AUTOCLOSE");
1837*7c478bd9Sstevel@tonic-gate 	case SCTP_SET_PEER_PRIMARY_ADDR:
1838*7c478bd9Sstevel@tonic-gate 		return ("SCTP_SET_PEER_PRIMARY_ADDR");
1839*7c478bd9Sstevel@tonic-gate 	case SCTP_PRIMARY_ADDR:		return ("SCTP_PRIMARY_ADDR");
1840*7c478bd9Sstevel@tonic-gate 	case SCTP_ADAPTION_LAYER:	return ("SCTP_ADAPTION_LAYER");
1841*7c478bd9Sstevel@tonic-gate 	case SCTP_DISABLE_FRAGMENTS:	return ("SCTP_DISABLE_FRAGMENTS");
1842*7c478bd9Sstevel@tonic-gate 	case SCTP_PEER_ADDR_PARAMS:	return ("SCTP_PEER_ADDR_PARAMS");
1843*7c478bd9Sstevel@tonic-gate 	case SCTP_DEFAULT_SEND_PARAM:	return ("SCTP_DEFAULT_SEND_PARAM");
1844*7c478bd9Sstevel@tonic-gate 	case SCTP_EVENTS:		return ("SCTP_EVENTS");
1845*7c478bd9Sstevel@tonic-gate 	case SCTP_I_WANT_MAPPED_V4_ADDR:
1846*7c478bd9Sstevel@tonic-gate 		return ("SCTP_I_WANT_MAPPED_V4_ADDR");
1847*7c478bd9Sstevel@tonic-gate 	case SCTP_MAXSEG:		return ("SCTP_MAXSEG");
1848*7c478bd9Sstevel@tonic-gate 	case SCTP_STATUS:		return ("SCTP_STATUS");
1849*7c478bd9Sstevel@tonic-gate 	case SCTP_GET_PEER_ADDR_INFO:	return ("SCTP_GET_PEER_ADDR_INFO");
1850*7c478bd9Sstevel@tonic-gate 
1851*7c478bd9Sstevel@tonic-gate 	case SCTP_ADD_ADDR:		return ("SCTP_ADD_ADDR");
1852*7c478bd9Sstevel@tonic-gate 	case SCTP_REM_ADDR:		return ("SCTP_REM_ADDR");
1853*7c478bd9Sstevel@tonic-gate 
1854*7c478bd9Sstevel@tonic-gate 	default:			(void) snprintf(pri->code_buf,
1855*7c478bd9Sstevel@tonic-gate 					    sizeof (pri->code_buf),
1856*7c478bd9Sstevel@tonic-gate 					    "0x%lx", val);
1857*7c478bd9Sstevel@tonic-gate 					return (pri->code_buf);
1858*7c478bd9Sstevel@tonic-gate 	}
1859*7c478bd9Sstevel@tonic-gate }
1860*7c478bd9Sstevel@tonic-gate 
1861*7c478bd9Sstevel@tonic-gate 
1862*7c478bd9Sstevel@tonic-gate const char *
1863*7c478bd9Sstevel@tonic-gate udp_optname(private_t *pri, long val)
1864*7c478bd9Sstevel@tonic-gate {
1865*7c478bd9Sstevel@tonic-gate 	if (val == UDP_CHECKSUM)
1866*7c478bd9Sstevel@tonic-gate 		return ("UDP_CHECKSUM");
1867*7c478bd9Sstevel@tonic-gate 
1868*7c478bd9Sstevel@tonic-gate 	(void) snprintf(pri->code_buf, sizeof (pri->code_buf), "0x%lx", val);
1869*7c478bd9Sstevel@tonic-gate 	return (pri->code_buf);
1870*7c478bd9Sstevel@tonic-gate }
1871*7c478bd9Sstevel@tonic-gate 
1872*7c478bd9Sstevel@tonic-gate 
1873*7c478bd9Sstevel@tonic-gate /*
1874*7c478bd9Sstevel@tonic-gate  * Print setsockopt()/getsockopt() 3rd argument.
1875*7c478bd9Sstevel@tonic-gate  */
1876*7c478bd9Sstevel@tonic-gate /*ARGSUSED*/
1877*7c478bd9Sstevel@tonic-gate void
1878*7c478bd9Sstevel@tonic-gate prt_son(private_t *pri, int raw, long val)
1879*7c478bd9Sstevel@tonic-gate {
1880*7c478bd9Sstevel@tonic-gate 	/* cheating -- look at the level */
1881*7c478bd9Sstevel@tonic-gate 	switch (pri->sys_args[1]) {
1882*7c478bd9Sstevel@tonic-gate 	case SOL_SOCKET:	outstring(pri, sol_optname(pri, val));
1883*7c478bd9Sstevel@tonic-gate 				break;
1884*7c478bd9Sstevel@tonic-gate 	case IPPROTO_TCP:	outstring(pri, tcp_optname(pri, val));
1885*7c478bd9Sstevel@tonic-gate 				break;
1886*7c478bd9Sstevel@tonic-gate 	case IPPROTO_UDP:	outstring(pri, udp_optname(pri, val));
1887*7c478bd9Sstevel@tonic-gate 				break;
1888*7c478bd9Sstevel@tonic-gate 	case IPPROTO_SCTP:	outstring(pri, sctp_optname(pri, val));
1889*7c478bd9Sstevel@tonic-gate 				break;
1890*7c478bd9Sstevel@tonic-gate 	default:		prt_dec(pri, 0, val);
1891*7c478bd9Sstevel@tonic-gate 				break;
1892*7c478bd9Sstevel@tonic-gate 	}
1893*7c478bd9Sstevel@tonic-gate }
1894*7c478bd9Sstevel@tonic-gate 
1895*7c478bd9Sstevel@tonic-gate 
1896*7c478bd9Sstevel@tonic-gate /*
1897*7c478bd9Sstevel@tonic-gate  * Print utrap type
1898*7c478bd9Sstevel@tonic-gate  */
1899*7c478bd9Sstevel@tonic-gate /*ARGSUSED*/
1900*7c478bd9Sstevel@tonic-gate void
1901*7c478bd9Sstevel@tonic-gate prt_utt(private_t *pri, int raw, long val)
1902*7c478bd9Sstevel@tonic-gate {
1903*7c478bd9Sstevel@tonic-gate 	const char *s = NULL;
1904*7c478bd9Sstevel@tonic-gate 
1905*7c478bd9Sstevel@tonic-gate #ifdef __sparc
1906*7c478bd9Sstevel@tonic-gate 	if (!raw) {
1907*7c478bd9Sstevel@tonic-gate 		switch (val) {
1908*7c478bd9Sstevel@tonic-gate 		case UT_INSTRUCTION_DISABLED:
1909*7c478bd9Sstevel@tonic-gate 			s = "UT_INSTRUCTION_DISABLED"; break;
1910*7c478bd9Sstevel@tonic-gate 		case UT_INSTRUCTION_ERROR:
1911*7c478bd9Sstevel@tonic-gate 			s = "UT_INSTRUCTION_ERROR"; break;
1912*7c478bd9Sstevel@tonic-gate 		case UT_INSTRUCTION_PROTECTION:
1913*7c478bd9Sstevel@tonic-gate 			s = "UT_INSTRUCTION_PROTECTION"; break;
1914*7c478bd9Sstevel@tonic-gate 		case UT_ILLTRAP_INSTRUCTION:
1915*7c478bd9Sstevel@tonic-gate 			s = "UT_ILLTRAP_INSTRUCTION"; break;
1916*7c478bd9Sstevel@tonic-gate 		case UT_ILLEGAL_INSTRUCTION:
1917*7c478bd9Sstevel@tonic-gate 			s = "UT_ILLEGAL_INSTRUCTION"; break;
1918*7c478bd9Sstevel@tonic-gate 		case UT_PRIVILEGED_OPCODE:
1919*7c478bd9Sstevel@tonic-gate 			s = "UT_PRIVILEGED_OPCODE"; break;
1920*7c478bd9Sstevel@tonic-gate 		case UT_FP_DISABLED:
1921*7c478bd9Sstevel@tonic-gate 			s = "UT_FP_DISABLED"; break;
1922*7c478bd9Sstevel@tonic-gate 		case UT_FP_EXCEPTION_IEEE_754:
1923*7c478bd9Sstevel@tonic-gate 			s = "UT_FP_EXCEPTION_IEEE_754"; break;
1924*7c478bd9Sstevel@tonic-gate 		case UT_FP_EXCEPTION_OTHER:
1925*7c478bd9Sstevel@tonic-gate 			s = "UT_FP_EXCEPTION_OTHER"; break;
1926*7c478bd9Sstevel@tonic-gate 		case UT_TAG_OVERFLOW:
1927*7c478bd9Sstevel@tonic-gate 			s = "UT_TAG_OVERFLOW"; break;
1928*7c478bd9Sstevel@tonic-gate 		case UT_DIVISION_BY_ZERO:
1929*7c478bd9Sstevel@tonic-gate 			s = "UT_DIVISION_BY_ZERO"; break;
1930*7c478bd9Sstevel@tonic-gate 		case UT_DATA_EXCEPTION:
1931*7c478bd9Sstevel@tonic-gate 			s = "UT_DATA_EXCEPTION"; break;
1932*7c478bd9Sstevel@tonic-gate 		case UT_DATA_ERROR:
1933*7c478bd9Sstevel@tonic-gate 			s = "UT_DATA_ERROR"; break;
1934*7c478bd9Sstevel@tonic-gate 		case UT_DATA_PROTECTION:
1935*7c478bd9Sstevel@tonic-gate 			s = "UT_DATA_PROTECTION"; break;
1936*7c478bd9Sstevel@tonic-gate 		case UT_MEM_ADDRESS_NOT_ALIGNED:
1937*7c478bd9Sstevel@tonic-gate 			s = "UT_MEM_ADDRESS_NOT_ALIGNED"; break;
1938*7c478bd9Sstevel@tonic-gate 		case UT_PRIVILEGED_ACTION:
1939*7c478bd9Sstevel@tonic-gate 			s = "UT_PRIVILEGED_ACTION"; break;
1940*7c478bd9Sstevel@tonic-gate 		case UT_ASYNC_DATA_ERROR:
1941*7c478bd9Sstevel@tonic-gate 			s = "UT_ASYNC_DATA_ERROR"; break;
1942*7c478bd9Sstevel@tonic-gate 		case UT_TRAP_INSTRUCTION_16:
1943*7c478bd9Sstevel@tonic-gate 			s = "UT_TRAP_INSTRUCTION_16"; break;
1944*7c478bd9Sstevel@tonic-gate 		case UT_TRAP_INSTRUCTION_17:
1945*7c478bd9Sstevel@tonic-gate 			s = "UT_TRAP_INSTRUCTION_17"; break;
1946*7c478bd9Sstevel@tonic-gate 		case UT_TRAP_INSTRUCTION_18:
1947*7c478bd9Sstevel@tonic-gate 			s = "UT_TRAP_INSTRUCTION_18"; break;
1948*7c478bd9Sstevel@tonic-gate 		case UT_TRAP_INSTRUCTION_19:
1949*7c478bd9Sstevel@tonic-gate 			s = "UT_TRAP_INSTRUCTION_19"; break;
1950*7c478bd9Sstevel@tonic-gate 		case UT_TRAP_INSTRUCTION_20:
1951*7c478bd9Sstevel@tonic-gate 			s = "UT_TRAP_INSTRUCTION_20"; break;
1952*7c478bd9Sstevel@tonic-gate 		case UT_TRAP_INSTRUCTION_21:
1953*7c478bd9Sstevel@tonic-gate 			s = "UT_TRAP_INSTRUCTION_21"; break;
1954*7c478bd9Sstevel@tonic-gate 		case UT_TRAP_INSTRUCTION_22:
1955*7c478bd9Sstevel@tonic-gate 			s = "UT_TRAP_INSTRUCTION_22"; break;
1956*7c478bd9Sstevel@tonic-gate 		case UT_TRAP_INSTRUCTION_23:
1957*7c478bd9Sstevel@tonic-gate 			s = "UT_TRAP_INSTRUCTION_23"; break;
1958*7c478bd9Sstevel@tonic-gate 		case UT_TRAP_INSTRUCTION_24:
1959*7c478bd9Sstevel@tonic-gate 			s = "UT_TRAP_INSTRUCTION_24"; break;
1960*7c478bd9Sstevel@tonic-gate 		case UT_TRAP_INSTRUCTION_25:
1961*7c478bd9Sstevel@tonic-gate 			s = "UT_TRAP_INSTRUCTION_25"; break;
1962*7c478bd9Sstevel@tonic-gate 		case UT_TRAP_INSTRUCTION_26:
1963*7c478bd9Sstevel@tonic-gate 			s = "UT_TRAP_INSTRUCTION_26"; break;
1964*7c478bd9Sstevel@tonic-gate 		case UT_TRAP_INSTRUCTION_27:
1965*7c478bd9Sstevel@tonic-gate 			s = "UT_TRAP_INSTRUCTION_27"; break;
1966*7c478bd9Sstevel@tonic-gate 		case UT_TRAP_INSTRUCTION_28:
1967*7c478bd9Sstevel@tonic-gate 			s = "UT_TRAP_INSTRUCTION_28"; break;
1968*7c478bd9Sstevel@tonic-gate 		case UT_TRAP_INSTRUCTION_29:
1969*7c478bd9Sstevel@tonic-gate 			s = "UT_TRAP_INSTRUCTION_29"; break;
1970*7c478bd9Sstevel@tonic-gate 		case UT_TRAP_INSTRUCTION_30:
1971*7c478bd9Sstevel@tonic-gate 			s = "UT_TRAP_INSTRUCTION_30"; break;
1972*7c478bd9Sstevel@tonic-gate 		case UT_TRAP_INSTRUCTION_31:
1973*7c478bd9Sstevel@tonic-gate 			s = "UT_TRAP_INSTRUCTION_31"; break;
1974*7c478bd9Sstevel@tonic-gate 		}
1975*7c478bd9Sstevel@tonic-gate 	}
1976*7c478bd9Sstevel@tonic-gate #endif /* __sparc */
1977*7c478bd9Sstevel@tonic-gate 
1978*7c478bd9Sstevel@tonic-gate 	if (s == NULL)
1979*7c478bd9Sstevel@tonic-gate 		prt_dec(pri, 0, val);
1980*7c478bd9Sstevel@tonic-gate 	else
1981*7c478bd9Sstevel@tonic-gate 		outstring(pri, s);
1982*7c478bd9Sstevel@tonic-gate }
1983*7c478bd9Sstevel@tonic-gate 
1984*7c478bd9Sstevel@tonic-gate 
1985*7c478bd9Sstevel@tonic-gate /*
1986*7c478bd9Sstevel@tonic-gate  * Print utrap handler
1987*7c478bd9Sstevel@tonic-gate  */
1988*7c478bd9Sstevel@tonic-gate void
1989*7c478bd9Sstevel@tonic-gate prt_uth(private_t *pri, int raw, long val)
1990*7c478bd9Sstevel@tonic-gate {
1991*7c478bd9Sstevel@tonic-gate 	const char *s = NULL;
1992*7c478bd9Sstevel@tonic-gate 
1993*7c478bd9Sstevel@tonic-gate 	if (!raw) {
1994*7c478bd9Sstevel@tonic-gate 		switch (val) {
1995*7c478bd9Sstevel@tonic-gate 		case (long)UTH_NOCHANGE:	s = "UTH_NOCHANGE"; break;
1996*7c478bd9Sstevel@tonic-gate 		}
1997*7c478bd9Sstevel@tonic-gate 	}
1998*7c478bd9Sstevel@tonic-gate 
1999*7c478bd9Sstevel@tonic-gate 	if (s == NULL)
2000*7c478bd9Sstevel@tonic-gate 		prt_hex(pri, 0, val);
2001*7c478bd9Sstevel@tonic-gate 	else
2002*7c478bd9Sstevel@tonic-gate 		outstring(pri, s);
2003*7c478bd9Sstevel@tonic-gate }
2004*7c478bd9Sstevel@tonic-gate 
2005*7c478bd9Sstevel@tonic-gate const char *
2006*7c478bd9Sstevel@tonic-gate access_flags(private_t *pri, long arg)
2007*7c478bd9Sstevel@tonic-gate {
2008*7c478bd9Sstevel@tonic-gate #define	E_OK 010
2009*7c478bd9Sstevel@tonic-gate 	char *str = pri->code_buf;
2010*7c478bd9Sstevel@tonic-gate 
2011*7c478bd9Sstevel@tonic-gate 	if (arg & ~(R_OK|W_OK|X_OK|E_OK))
2012*7c478bd9Sstevel@tonic-gate 		return (NULL);
2013*7c478bd9Sstevel@tonic-gate 
2014*7c478bd9Sstevel@tonic-gate 	/* NB: F_OK == 0 */
2015*7c478bd9Sstevel@tonic-gate 	if (arg == F_OK)
2016*7c478bd9Sstevel@tonic-gate 		return ("F_OK");
2017*7c478bd9Sstevel@tonic-gate 	if (arg == E_OK)
2018*7c478bd9Sstevel@tonic-gate 		return ("F_OK|E_OK");
2019*7c478bd9Sstevel@tonic-gate 
2020*7c478bd9Sstevel@tonic-gate 	*str = '\0';
2021*7c478bd9Sstevel@tonic-gate 	if (arg & R_OK)
2022*7c478bd9Sstevel@tonic-gate 		(void) strlcat(str, "|R_OK", sizeof (pri->code_buf));
2023*7c478bd9Sstevel@tonic-gate 	if (arg & W_OK)
2024*7c478bd9Sstevel@tonic-gate 		(void) strlcat(str, "|W_OK", sizeof (pri->code_buf));
2025*7c478bd9Sstevel@tonic-gate 	if (arg & X_OK)
2026*7c478bd9Sstevel@tonic-gate 		(void) strlcat(str, "|X_OK", sizeof (pri->code_buf));
2027*7c478bd9Sstevel@tonic-gate 	if (arg & E_OK)
2028*7c478bd9Sstevel@tonic-gate 		(void) strlcat(str, "|E_OK", sizeof (pri->code_buf));
2029*7c478bd9Sstevel@tonic-gate 	return ((const char *)(str + 1));
2030*7c478bd9Sstevel@tonic-gate #undef E_OK
2031*7c478bd9Sstevel@tonic-gate }
2032*7c478bd9Sstevel@tonic-gate 
2033*7c478bd9Sstevel@tonic-gate /*
2034*7c478bd9Sstevel@tonic-gate  * Print access() flags.
2035*7c478bd9Sstevel@tonic-gate  */
2036*7c478bd9Sstevel@tonic-gate void
2037*7c478bd9Sstevel@tonic-gate prt_acc(private_t *pri, int raw, long val)
2038*7c478bd9Sstevel@tonic-gate {
2039*7c478bd9Sstevel@tonic-gate 	const char *s = raw? NULL : access_flags(pri, val);
2040*7c478bd9Sstevel@tonic-gate 
2041*7c478bd9Sstevel@tonic-gate 	if (s == NULL)
2042*7c478bd9Sstevel@tonic-gate 		prt_dex(pri, 0, val);
2043*7c478bd9Sstevel@tonic-gate 	else
2044*7c478bd9Sstevel@tonic-gate 		outstring(pri, s);
2045*7c478bd9Sstevel@tonic-gate }
2046*7c478bd9Sstevel@tonic-gate 
2047*7c478bd9Sstevel@tonic-gate /*
2048*7c478bd9Sstevel@tonic-gate  * Print shutdown() "how" (2nd) argument
2049*7c478bd9Sstevel@tonic-gate  */
2050*7c478bd9Sstevel@tonic-gate void
2051*7c478bd9Sstevel@tonic-gate prt_sht(private_t *pri, int raw, long val)
2052*7c478bd9Sstevel@tonic-gate {
2053*7c478bd9Sstevel@tonic-gate 	if (raw) {
2054*7c478bd9Sstevel@tonic-gate 		prt_dex(pri, 0, val);
2055*7c478bd9Sstevel@tonic-gate 		return;
2056*7c478bd9Sstevel@tonic-gate 	}
2057*7c478bd9Sstevel@tonic-gate 	switch (val) {
2058*7c478bd9Sstevel@tonic-gate 	case SHUT_RD:	outstring(pri, "SHUT_RD");	break;
2059*7c478bd9Sstevel@tonic-gate 	case SHUT_WR:	outstring(pri, "SHUT_WR");	break;
2060*7c478bd9Sstevel@tonic-gate 	case SHUT_RDWR:	outstring(pri, "SHUT_RDWR");	break;
2061*7c478bd9Sstevel@tonic-gate 	default:	prt_dec(pri, 0, val);		break;
2062*7c478bd9Sstevel@tonic-gate 	}
2063*7c478bd9Sstevel@tonic-gate }
2064*7c478bd9Sstevel@tonic-gate 
2065*7c478bd9Sstevel@tonic-gate /*
2066*7c478bd9Sstevel@tonic-gate  * Print fcntl() F_SETFL flags (3rd) argument or fdsync flag (2nd arg)
2067*7c478bd9Sstevel@tonic-gate  */
2068*7c478bd9Sstevel@tonic-gate static struct fcntl_flags {
2069*7c478bd9Sstevel@tonic-gate 	long		val;
2070*7c478bd9Sstevel@tonic-gate 	const char	*name;
2071*7c478bd9Sstevel@tonic-gate } fcntl_flags[] = {
2072*7c478bd9Sstevel@tonic-gate #define	FC_FL(flag)	{ (long)flag, "|" # flag }
2073*7c478bd9Sstevel@tonic-gate #ifdef C2_AUDIT
2074*7c478bd9Sstevel@tonic-gate 	FC_FL(FREVOKED),
2075*7c478bd9Sstevel@tonic-gate #endif
2076*7c478bd9Sstevel@tonic-gate 	FC_FL(FREAD),
2077*7c478bd9Sstevel@tonic-gate 	FC_FL(FWRITE),
2078*7c478bd9Sstevel@tonic-gate 	FC_FL(FNDELAY),
2079*7c478bd9Sstevel@tonic-gate 	FC_FL(FAPPEND),
2080*7c478bd9Sstevel@tonic-gate 	FC_FL(FSYNC),
2081*7c478bd9Sstevel@tonic-gate 	FC_FL(FDSYNC),
2082*7c478bd9Sstevel@tonic-gate 	FC_FL(FRSYNC),
2083*7c478bd9Sstevel@tonic-gate 	FC_FL(FOFFMAX),
2084*7c478bd9Sstevel@tonic-gate 	FC_FL(FNONBLOCK),
2085*7c478bd9Sstevel@tonic-gate 	FC_FL(FCREAT),
2086*7c478bd9Sstevel@tonic-gate 	FC_FL(FTRUNC),
2087*7c478bd9Sstevel@tonic-gate 	FC_FL(FEXCL),
2088*7c478bd9Sstevel@tonic-gate 	FC_FL(FNOCTTY),
2089*7c478bd9Sstevel@tonic-gate 	FC_FL(FXATTR),
2090*7c478bd9Sstevel@tonic-gate 	FC_FL(FASYNC),
2091*7c478bd9Sstevel@tonic-gate 	FC_FL(FNODSYNC)
2092*7c478bd9Sstevel@tonic-gate #undef FC_FL
2093*7c478bd9Sstevel@tonic-gate };
2094*7c478bd9Sstevel@tonic-gate 
2095*7c478bd9Sstevel@tonic-gate void
2096*7c478bd9Sstevel@tonic-gate prt_ffg(private_t *pri, int raw, long val)
2097*7c478bd9Sstevel@tonic-gate {
2098*7c478bd9Sstevel@tonic-gate #define	CBSIZE	sizeof (pri->code_buf)
2099*7c478bd9Sstevel@tonic-gate 	char *s = pri->code_buf;
2100*7c478bd9Sstevel@tonic-gate 	size_t used = 1;
2101*7c478bd9Sstevel@tonic-gate 	struct fcntl_flags *fp;
2102*7c478bd9Sstevel@tonic-gate 
2103*7c478bd9Sstevel@tonic-gate 	if (raw) {
2104*7c478bd9Sstevel@tonic-gate 		(void) snprintf(s, CBSIZE, "0x%lx", val);
2105*7c478bd9Sstevel@tonic-gate 		outstring(pri, s);
2106*7c478bd9Sstevel@tonic-gate 		return;
2107*7c478bd9Sstevel@tonic-gate 	}
2108*7c478bd9Sstevel@tonic-gate 	if (val == 0) {
2109*7c478bd9Sstevel@tonic-gate 		outstring(pri, "(no flags)");
2110*7c478bd9Sstevel@tonic-gate 		return;
2111*7c478bd9Sstevel@tonic-gate 	}
2112*7c478bd9Sstevel@tonic-gate 
2113*7c478bd9Sstevel@tonic-gate 	*s = '\0';
2114*7c478bd9Sstevel@tonic-gate 	for (fp = fcntl_flags;
2115*7c478bd9Sstevel@tonic-gate 	    fp < &fcntl_flags[sizeof (fcntl_flags) / sizeof (*fp)]; fp++) {
2116*7c478bd9Sstevel@tonic-gate 		if (val & fp->val) {
2117*7c478bd9Sstevel@tonic-gate 			used = strlcat(s, fp->name, CBSIZE);
2118*7c478bd9Sstevel@tonic-gate 			val &= ~fp->val;
2119*7c478bd9Sstevel@tonic-gate 		}
2120*7c478bd9Sstevel@tonic-gate 	}
2121*7c478bd9Sstevel@tonic-gate 
2122*7c478bd9Sstevel@tonic-gate 	if (val != 0 && used <= CBSIZE)
2123*7c478bd9Sstevel@tonic-gate 		used += snprintf(s + used, CBSIZE - used, "|0x%lx", val);
2124*7c478bd9Sstevel@tonic-gate 
2125*7c478bd9Sstevel@tonic-gate 	if (used >= CBSIZE)
2126*7c478bd9Sstevel@tonic-gate 		(void) snprintf(s + 1, CBSIZE-1, "0x%lx", val);
2127*7c478bd9Sstevel@tonic-gate 	outstring(pri, s + 1);
2128*7c478bd9Sstevel@tonic-gate #undef CBSIZE
2129*7c478bd9Sstevel@tonic-gate }
2130*7c478bd9Sstevel@tonic-gate 
2131*7c478bd9Sstevel@tonic-gate void
2132*7c478bd9Sstevel@tonic-gate prt_prs(private_t *pri, int raw, long val)
2133*7c478bd9Sstevel@tonic-gate {
2134*7c478bd9Sstevel@tonic-gate 	static size_t setsize;
2135*7c478bd9Sstevel@tonic-gate 	priv_set_t *set = priv_allocset();
2136*7c478bd9Sstevel@tonic-gate 
2137*7c478bd9Sstevel@tonic-gate 	if (setsize == 0) {
2138*7c478bd9Sstevel@tonic-gate 		const priv_impl_info_t *info = getprivimplinfo();
2139*7c478bd9Sstevel@tonic-gate 		if (info != NULL)
2140*7c478bd9Sstevel@tonic-gate 			setsize = info->priv_setsize * sizeof (priv_chunk_t);
2141*7c478bd9Sstevel@tonic-gate 	}
2142*7c478bd9Sstevel@tonic-gate 
2143*7c478bd9Sstevel@tonic-gate 	if (setsize != 0 && !raw && set != NULL &&
2144*7c478bd9Sstevel@tonic-gate 	    Pread(Proc, set, setsize, val) == setsize) {
2145*7c478bd9Sstevel@tonic-gate 		int i;
2146*7c478bd9Sstevel@tonic-gate 
2147*7c478bd9Sstevel@tonic-gate 		outstring(pri, "{");
2148*7c478bd9Sstevel@tonic-gate 		for (i = 0; i < setsize / sizeof (priv_chunk_t); i++) {
2149*7c478bd9Sstevel@tonic-gate 			char buf[9];	/* 8 hex digits + '\0' */
2150*7c478bd9Sstevel@tonic-gate 			(void) snprintf(buf, sizeof (buf), "%08x",
2151*7c478bd9Sstevel@tonic-gate 			    ((priv_chunk_t *)set)[i]);
2152*7c478bd9Sstevel@tonic-gate 			outstring(pri, buf);
2153*7c478bd9Sstevel@tonic-gate 		}
2154*7c478bd9Sstevel@tonic-gate 
2155*7c478bd9Sstevel@tonic-gate 		outstring(pri, "}");
2156*7c478bd9Sstevel@tonic-gate 	} else {
2157*7c478bd9Sstevel@tonic-gate 		prt_hex(pri, 0, val);
2158*7c478bd9Sstevel@tonic-gate 	}
2159*7c478bd9Sstevel@tonic-gate 
2160*7c478bd9Sstevel@tonic-gate 	if (set != NULL)
2161*7c478bd9Sstevel@tonic-gate 		priv_freeset(set);
2162*7c478bd9Sstevel@tonic-gate }
2163*7c478bd9Sstevel@tonic-gate 
2164*7c478bd9Sstevel@tonic-gate /*
2165*7c478bd9Sstevel@tonic-gate  * Print privilege set operation.
2166*7c478bd9Sstevel@tonic-gate  */
2167*7c478bd9Sstevel@tonic-gate void
2168*7c478bd9Sstevel@tonic-gate prt_pro(private_t *pri, int raw, long val)
2169*7c478bd9Sstevel@tonic-gate {
2170*7c478bd9Sstevel@tonic-gate 	const char *s = NULL;
2171*7c478bd9Sstevel@tonic-gate 
2172*7c478bd9Sstevel@tonic-gate 	if (!raw) {
2173*7c478bd9Sstevel@tonic-gate 		switch ((priv_op_t)val) {
2174*7c478bd9Sstevel@tonic-gate 		case PRIV_ON:		s = "PRIV_ON";		break;
2175*7c478bd9Sstevel@tonic-gate 		case PRIV_OFF:		s = "PRIV_OFF";		break;
2176*7c478bd9Sstevel@tonic-gate 		case PRIV_SET:		s = "PRIV_SET";		break;
2177*7c478bd9Sstevel@tonic-gate 		}
2178*7c478bd9Sstevel@tonic-gate 	}
2179*7c478bd9Sstevel@tonic-gate 
2180*7c478bd9Sstevel@tonic-gate 	if (s == NULL)
2181*7c478bd9Sstevel@tonic-gate 		prt_dec(pri, 0, val);
2182*7c478bd9Sstevel@tonic-gate 	else
2183*7c478bd9Sstevel@tonic-gate 		outstring(pri, s);
2184*7c478bd9Sstevel@tonic-gate }
2185*7c478bd9Sstevel@tonic-gate 
2186*7c478bd9Sstevel@tonic-gate /*
2187*7c478bd9Sstevel@tonic-gate  * Print privilege set name
2188*7c478bd9Sstevel@tonic-gate  */
2189*7c478bd9Sstevel@tonic-gate void
2190*7c478bd9Sstevel@tonic-gate prt_prn(private_t *pri, int raw, long val)
2191*7c478bd9Sstevel@tonic-gate {
2192*7c478bd9Sstevel@tonic-gate 	const char *s = NULL;
2193*7c478bd9Sstevel@tonic-gate 
2194*7c478bd9Sstevel@tonic-gate 	if (!raw)
2195*7c478bd9Sstevel@tonic-gate 		s = priv_getsetbynum((int)val);
2196*7c478bd9Sstevel@tonic-gate 
2197*7c478bd9Sstevel@tonic-gate 	if (s == NULL)
2198*7c478bd9Sstevel@tonic-gate 		prt_dec(pri, 0, val);
2199*7c478bd9Sstevel@tonic-gate 	else {
2200*7c478bd9Sstevel@tonic-gate 		char *dup = strdup(s);
2201*7c478bd9Sstevel@tonic-gate 		char *q;
2202*7c478bd9Sstevel@tonic-gate 
2203*7c478bd9Sstevel@tonic-gate 		/* Do the best we can in this case */
2204*7c478bd9Sstevel@tonic-gate 		if (dup == NULL) {
2205*7c478bd9Sstevel@tonic-gate 			outstring(pri, s);
2206*7c478bd9Sstevel@tonic-gate 			return;
2207*7c478bd9Sstevel@tonic-gate 		}
2208*7c478bd9Sstevel@tonic-gate 
2209*7c478bd9Sstevel@tonic-gate 		outstring(pri, "PRIV_");
2210*7c478bd9Sstevel@tonic-gate 
2211*7c478bd9Sstevel@tonic-gate 		q = dup;
2212*7c478bd9Sstevel@tonic-gate 
2213*7c478bd9Sstevel@tonic-gate 		while (*q != '\0') {
2214*7c478bd9Sstevel@tonic-gate 			*q = toupper(*q);
2215*7c478bd9Sstevel@tonic-gate 			q++;
2216*7c478bd9Sstevel@tonic-gate 		}
2217*7c478bd9Sstevel@tonic-gate 		outstring(pri, dup);
2218*7c478bd9Sstevel@tonic-gate 		free(dup);
2219*7c478bd9Sstevel@tonic-gate 	}
2220*7c478bd9Sstevel@tonic-gate }
2221*7c478bd9Sstevel@tonic-gate 
2222*7c478bd9Sstevel@tonic-gate /*
2223*7c478bd9Sstevel@tonic-gate  * Print process flag names.
2224*7c478bd9Sstevel@tonic-gate  */
2225*7c478bd9Sstevel@tonic-gate void
2226*7c478bd9Sstevel@tonic-gate prt_pfl(private_t *pri, int raw, long val)
2227*7c478bd9Sstevel@tonic-gate {
2228*7c478bd9Sstevel@tonic-gate 	const char *s = NULL;
2229*7c478bd9Sstevel@tonic-gate 
2230*7c478bd9Sstevel@tonic-gate 	if (!raw) {
2231*7c478bd9Sstevel@tonic-gate 		switch ((int)val) {
2232*7c478bd9Sstevel@tonic-gate 		case PRIV_DEBUG:	s = "PRIV_DEBUG";	break;
2233*7c478bd9Sstevel@tonic-gate 		case PRIV_AWARE:	s = "PRIV_AWARE";	break;
2234*7c478bd9Sstevel@tonic-gate 		}
2235*7c478bd9Sstevel@tonic-gate 	}
2236*7c478bd9Sstevel@tonic-gate 
2237*7c478bd9Sstevel@tonic-gate 	if (s == NULL)
2238*7c478bd9Sstevel@tonic-gate 		prt_dec(pri, 0, val);
2239*7c478bd9Sstevel@tonic-gate 	else
2240*7c478bd9Sstevel@tonic-gate 		outstring(pri, s);
2241*7c478bd9Sstevel@tonic-gate }
2242*7c478bd9Sstevel@tonic-gate 
2243*7c478bd9Sstevel@tonic-gate /*
2244*7c478bd9Sstevel@tonic-gate  * Print lgrp_affinity_{get,set}() arguments.
2245*7c478bd9Sstevel@tonic-gate  */
2246*7c478bd9Sstevel@tonic-gate /*ARGSUSED*/
2247*7c478bd9Sstevel@tonic-gate void
2248*7c478bd9Sstevel@tonic-gate prt_laf(private_t *pri, int raw, long val)
2249*7c478bd9Sstevel@tonic-gate {
2250*7c478bd9Sstevel@tonic-gate 	lgrp_affinity_args_t	laff;
2251*7c478bd9Sstevel@tonic-gate 
2252*7c478bd9Sstevel@tonic-gate 	if (Pread(Proc, &laff, sizeof (lgrp_affinity_args_t), val) !=
2253*7c478bd9Sstevel@tonic-gate 		sizeof (lgrp_affinity_args_t)) {
2254*7c478bd9Sstevel@tonic-gate 		prt_hex(pri, 0, val);
2255*7c478bd9Sstevel@tonic-gate 		return;
2256*7c478bd9Sstevel@tonic-gate 	}
2257*7c478bd9Sstevel@tonic-gate 	/*
2258*7c478bd9Sstevel@tonic-gate 	 * arrange the arguments in the order that user calls with
2259*7c478bd9Sstevel@tonic-gate 	 */
2260*7c478bd9Sstevel@tonic-gate 	prt_dec(pri, 0, laff.idtype);
2261*7c478bd9Sstevel@tonic-gate 	outstring(pri, ", ");
2262*7c478bd9Sstevel@tonic-gate 	prt_dec(pri, 0, laff.id);
2263*7c478bd9Sstevel@tonic-gate 	outstring(pri, ", ");
2264*7c478bd9Sstevel@tonic-gate 	prt_dec(pri, 0, laff.lgrp);
2265*7c478bd9Sstevel@tonic-gate 	outstring(pri, ", ");
2266*7c478bd9Sstevel@tonic-gate 	if (pri->sys_args[0] == LGRP_SYS_AFFINITY_SET)
2267*7c478bd9Sstevel@tonic-gate 		prt_dec(pri, 0, laff.aff);
2268*7c478bd9Sstevel@tonic-gate }
2269*7c478bd9Sstevel@tonic-gate 
2270*7c478bd9Sstevel@tonic-gate /*
2271*7c478bd9Sstevel@tonic-gate  * Print a key_t as IPC_PRIVATE if it is 0.
2272*7c478bd9Sstevel@tonic-gate  */
2273*7c478bd9Sstevel@tonic-gate void
2274*7c478bd9Sstevel@tonic-gate prt_key(private_t *pri, int raw, long val)
2275*7c478bd9Sstevel@tonic-gate {
2276*7c478bd9Sstevel@tonic-gate 	if (!raw && val == 0)
2277*7c478bd9Sstevel@tonic-gate 		outstring(pri, "IPC_PRIVATE");
2278*7c478bd9Sstevel@tonic-gate 	else
2279*7c478bd9Sstevel@tonic-gate 		prt_dec(pri, 0, val);
2280*7c478bd9Sstevel@tonic-gate }
2281*7c478bd9Sstevel@tonic-gate 
2282*7c478bd9Sstevel@tonic-gate 
2283*7c478bd9Sstevel@tonic-gate /*
2284*7c478bd9Sstevel@tonic-gate  * Print zone_getattr() attribute types.
2285*7c478bd9Sstevel@tonic-gate  */
2286*7c478bd9Sstevel@tonic-gate void
2287*7c478bd9Sstevel@tonic-gate prt_zga(private_t *pri, int raw, long val)
2288*7c478bd9Sstevel@tonic-gate {
2289*7c478bd9Sstevel@tonic-gate 	const char *s = NULL;
2290*7c478bd9Sstevel@tonic-gate 
2291*7c478bd9Sstevel@tonic-gate 	if (!raw) {
2292*7c478bd9Sstevel@tonic-gate 		switch ((int)val) {
2293*7c478bd9Sstevel@tonic-gate 		case ZONE_ATTR_NAME:	s = "ZONE_ATTR_NAME";	break;
2294*7c478bd9Sstevel@tonic-gate 		case ZONE_ATTR_ROOT:	s = "ZONE_ATTR_ROOT";	break;
2295*7c478bd9Sstevel@tonic-gate 		case ZONE_ATTR_STATUS:	s = "ZONE_ATTR_STATUS";	break;
2296*7c478bd9Sstevel@tonic-gate 		case ZONE_ATTR_PRIVSET:	s = "ZONE_ATTR_PRIVSET"; break;
2297*7c478bd9Sstevel@tonic-gate 		case ZONE_ATTR_UNIQID:	s = "ZONE_ATTR_UNIQID"; break;
2298*7c478bd9Sstevel@tonic-gate 		case ZONE_ATTR_POOLID:	s = "ZONE_ATTR_POOLID"; break;
2299*7c478bd9Sstevel@tonic-gate 		case ZONE_ATTR_INITPID:	s = "ZONE_ATTR_INITPID"; break;
2300*7c478bd9Sstevel@tonic-gate 		}
2301*7c478bd9Sstevel@tonic-gate 	}
2302*7c478bd9Sstevel@tonic-gate 
2303*7c478bd9Sstevel@tonic-gate 	if (s == NULL)
2304*7c478bd9Sstevel@tonic-gate 		prt_dec(pri, 0, val);
2305*7c478bd9Sstevel@tonic-gate 	else
2306*7c478bd9Sstevel@tonic-gate 		outstring(pri, s);
2307*7c478bd9Sstevel@tonic-gate }
2308*7c478bd9Sstevel@tonic-gate 
2309*7c478bd9Sstevel@tonic-gate /*
2310*7c478bd9Sstevel@tonic-gate  * Print a file descriptor as AT_FDCWD if necessary
2311*7c478bd9Sstevel@tonic-gate  */
2312*7c478bd9Sstevel@tonic-gate void
2313*7c478bd9Sstevel@tonic-gate prt_atc(private_t *pri, int raw, long val)
2314*7c478bd9Sstevel@tonic-gate {
2315*7c478bd9Sstevel@tonic-gate 	if (!raw && val == AT_FDCWD)
2316*7c478bd9Sstevel@tonic-gate 		outstring(pri, "AT_FDCWD");
2317*7c478bd9Sstevel@tonic-gate 	else
2318*7c478bd9Sstevel@tonic-gate 		prt_dec(pri, 0, val);
2319*7c478bd9Sstevel@tonic-gate }
2320*7c478bd9Sstevel@tonic-gate 
2321*7c478bd9Sstevel@tonic-gate /*
2322*7c478bd9Sstevel@tonic-gate  * Print LIO_XX flags
2323*7c478bd9Sstevel@tonic-gate  */
2324*7c478bd9Sstevel@tonic-gate void
2325*7c478bd9Sstevel@tonic-gate prt_lio(private_t *pri, int raw, long val)
2326*7c478bd9Sstevel@tonic-gate {
2327*7c478bd9Sstevel@tonic-gate 	if (raw)
2328*7c478bd9Sstevel@tonic-gate 		prt_dec(pri, 0, val);
2329*7c478bd9Sstevel@tonic-gate 	else if (val == LIO_WAIT)
2330*7c478bd9Sstevel@tonic-gate 		outstring(pri, "LIO_WAIT");
2331*7c478bd9Sstevel@tonic-gate 	else if (val == LIO_NOWAIT)
2332*7c478bd9Sstevel@tonic-gate 		outstring(pri, "LIO_NOWAIT");
2333*7c478bd9Sstevel@tonic-gate 	else
2334*7c478bd9Sstevel@tonic-gate 		prt_dec(pri, 0, val);
2335*7c478bd9Sstevel@tonic-gate }
2336*7c478bd9Sstevel@tonic-gate 
2337*7c478bd9Sstevel@tonic-gate const char *
2338*7c478bd9Sstevel@tonic-gate door_flags(private_t *pri, long val)
2339*7c478bd9Sstevel@tonic-gate {
2340*7c478bd9Sstevel@tonic-gate 	door_attr_t attr = (door_attr_t)val;
2341*7c478bd9Sstevel@tonic-gate 	char *str = pri->code_buf;
2342*7c478bd9Sstevel@tonic-gate 
2343*7c478bd9Sstevel@tonic-gate 	*str = '\0';
2344*7c478bd9Sstevel@tonic-gate #define	PROCESS_FLAG(flg)						\
2345*7c478bd9Sstevel@tonic-gate 	if (attr & flg) {						\
2346*7c478bd9Sstevel@tonic-gate 		(void) strlcat(str, "|" #flg, sizeof (pri->code_buf));	\
2347*7c478bd9Sstevel@tonic-gate 		attr &= ~flg;						\
2348*7c478bd9Sstevel@tonic-gate 	}
2349*7c478bd9Sstevel@tonic-gate 
2350*7c478bd9Sstevel@tonic-gate 	PROCESS_FLAG(DOOR_UNREF);
2351*7c478bd9Sstevel@tonic-gate 	PROCESS_FLAG(DOOR_UNREF_MULTI);
2352*7c478bd9Sstevel@tonic-gate 	PROCESS_FLAG(DOOR_PRIVATE);
2353*7c478bd9Sstevel@tonic-gate 	PROCESS_FLAG(DOOR_REFUSE_DESC);
2354*7c478bd9Sstevel@tonic-gate 	PROCESS_FLAG(DOOR_NO_CANCEL);
2355*7c478bd9Sstevel@tonic-gate 	PROCESS_FLAG(DOOR_LOCAL);
2356*7c478bd9Sstevel@tonic-gate 	PROCESS_FLAG(DOOR_REVOKED);
2357*7c478bd9Sstevel@tonic-gate 	PROCESS_FLAG(DOOR_IS_UNREF);
2358*7c478bd9Sstevel@tonic-gate #undef PROCESS_FLAG
2359*7c478bd9Sstevel@tonic-gate 
2360*7c478bd9Sstevel@tonic-gate 	if (attr != 0 || *str == '\0') {
2361*7c478bd9Sstevel@tonic-gate 		size_t len = strlen(str);
2362*7c478bd9Sstevel@tonic-gate 		(void) snprintf(str + len, sizeof (pri->code_buf) - len,
2363*7c478bd9Sstevel@tonic-gate 		    "|0x%X", attr);
2364*7c478bd9Sstevel@tonic-gate 	}
2365*7c478bd9Sstevel@tonic-gate 
2366*7c478bd9Sstevel@tonic-gate 	return (str + 1);
2367*7c478bd9Sstevel@tonic-gate }
2368*7c478bd9Sstevel@tonic-gate 
2369*7c478bd9Sstevel@tonic-gate /*
2370*7c478bd9Sstevel@tonic-gate  * Print door_create() flags
2371*7c478bd9Sstevel@tonic-gate  */
2372*7c478bd9Sstevel@tonic-gate void
2373*7c478bd9Sstevel@tonic-gate prt_dfl(private_t *pri, int raw, long val)
2374*7c478bd9Sstevel@tonic-gate {
2375*7c478bd9Sstevel@tonic-gate 	if (raw)
2376*7c478bd9Sstevel@tonic-gate 		prt_hex(pri, 0, val);
2377*7c478bd9Sstevel@tonic-gate 	else
2378*7c478bd9Sstevel@tonic-gate 		outstring(pri, door_flags(pri, val));
2379*7c478bd9Sstevel@tonic-gate }
2380*7c478bd9Sstevel@tonic-gate 
2381*7c478bd9Sstevel@tonic-gate /*
2382*7c478bd9Sstevel@tonic-gate  * Print door_*param() param argument
2383*7c478bd9Sstevel@tonic-gate  */
2384*7c478bd9Sstevel@tonic-gate void
2385*7c478bd9Sstevel@tonic-gate prt_dpm(private_t *pri, int raw, long val)
2386*7c478bd9Sstevel@tonic-gate {
2387*7c478bd9Sstevel@tonic-gate 	if (raw)
2388*7c478bd9Sstevel@tonic-gate 		prt_hex(pri, 0, val);
2389*7c478bd9Sstevel@tonic-gate 	else if (val == DOOR_PARAM_DESC_MAX)
2390*7c478bd9Sstevel@tonic-gate 		outstring(pri, "DOOR_PARAM_DESC_MAX");
2391*7c478bd9Sstevel@tonic-gate 	else if (val == DOOR_PARAM_DATA_MIN)
2392*7c478bd9Sstevel@tonic-gate 		outstring(pri, "DOOR_PARAM_DATA_MIN");
2393*7c478bd9Sstevel@tonic-gate 	else if (val == DOOR_PARAM_DATA_MAX)
2394*7c478bd9Sstevel@tonic-gate 		outstring(pri, "DOOR_PARAM_DATA_MAX");
2395*7c478bd9Sstevel@tonic-gate 	else
2396*7c478bd9Sstevel@tonic-gate 		prt_hex(pri, 0, val);
2397*7c478bd9Sstevel@tonic-gate }
2398*7c478bd9Sstevel@tonic-gate 
2399*7c478bd9Sstevel@tonic-gate /*
2400*7c478bd9Sstevel@tonic-gate  * Array of pointers to print functions, one for each format.
2401*7c478bd9Sstevel@tonic-gate  */
2402*7c478bd9Sstevel@tonic-gate void (* const Print[])() = {
2403*7c478bd9Sstevel@tonic-gate 	prt_nov,	/* NOV -- no value */
2404*7c478bd9Sstevel@tonic-gate 	prt_dec,	/* DEC -- print value in decimal */
2405*7c478bd9Sstevel@tonic-gate 	prt_oct,	/* OCT -- print value in octal */
2406*7c478bd9Sstevel@tonic-gate 	prt_hex,	/* HEX -- print value in hexadecimal */
2407*7c478bd9Sstevel@tonic-gate 	prt_dex,	/* DEX -- print value in hexadecimal if big enough */
2408*7c478bd9Sstevel@tonic-gate 	prt_stg,	/* STG -- print value as string */
2409*7c478bd9Sstevel@tonic-gate 	prt_ioc,	/* IOC -- print ioctl code */
2410*7c478bd9Sstevel@tonic-gate 	prt_fcn,	/* FCN -- print fcntl code */
2411*7c478bd9Sstevel@tonic-gate 	prt_s86,	/* S86 -- print sysi86 code */
2412*7c478bd9Sstevel@tonic-gate 	prt_uts,	/* UTS -- print utssys code */
2413*7c478bd9Sstevel@tonic-gate 	prt_opn,	/* OPN -- print open code */
2414*7c478bd9Sstevel@tonic-gate 	prt_sig,	/* SIG -- print signal name plus flags */
2415*7c478bd9Sstevel@tonic-gate 	prt_act,	/* ACT -- print signal action value */
2416*7c478bd9Sstevel@tonic-gate 	prt_msc,	/* MSC -- print msgsys command */
2417*7c478bd9Sstevel@tonic-gate 	prt_msf,	/* MSF -- print msgsys flags */
2418*7c478bd9Sstevel@tonic-gate 	prt_smc,	/* SMC -- print semsys command */
2419*7c478bd9Sstevel@tonic-gate 	prt_sef,	/* SEF -- print semsys flags */
2420*7c478bd9Sstevel@tonic-gate 	prt_shc,	/* SHC -- print shmsys command */
2421*7c478bd9Sstevel@tonic-gate 	prt_shf,	/* SHF -- print shmsys flags */
2422*7c478bd9Sstevel@tonic-gate 	prt_plk,	/* PLK -- print plock code */
2423*7c478bd9Sstevel@tonic-gate 	prt_sfs,	/* SFS -- print sysfs code */
2424*7c478bd9Sstevel@tonic-gate 	prt_rst,	/* RST -- print string returned by syscall */
2425*7c478bd9Sstevel@tonic-gate 	prt_smf,	/* SMF -- print streams message flags */
2426*7c478bd9Sstevel@tonic-gate 	prt_ioa,	/* IOA -- print ioctl argument */
2427*7c478bd9Sstevel@tonic-gate 	prt_six,	/* SIX -- print signal, masked with SIGNO_MASK */
2428*7c478bd9Sstevel@tonic-gate 	prt_mtf,	/* MTF -- print mount flags */
2429*7c478bd9Sstevel@tonic-gate 	prt_mft,	/* MFT -- print mount file system type */
2430*7c478bd9Sstevel@tonic-gate 	prt_iob,	/* IOB -- print contents of I/O buffer */
2431*7c478bd9Sstevel@tonic-gate 	prt_hhx,	/* HHX -- print value in hexadecimal (half size) */
2432*7c478bd9Sstevel@tonic-gate 	prt_wop,	/* WOP -- print waitsys() options */
2433*7c478bd9Sstevel@tonic-gate 	prt_spm,	/* SPM -- print sigprocmask argument */
2434*7c478bd9Sstevel@tonic-gate 	prt_rlk,	/* RLK -- print readlink buffer */
2435*7c478bd9Sstevel@tonic-gate 	prt_mpr,	/* MPR -- print mmap()/mprotect() flags */
2436*7c478bd9Sstevel@tonic-gate 	prt_mty,	/* MTY -- print mmap() mapping type flags */
2437*7c478bd9Sstevel@tonic-gate 	prt_mcf,	/* MCF -- print memcntl() function */
2438*7c478bd9Sstevel@tonic-gate 	prt_mc4,	/* MC4 -- print memcntl() (fourth) argument */
2439*7c478bd9Sstevel@tonic-gate 	prt_mc5,	/* MC5 -- print memcntl() (fifth) argument */
2440*7c478bd9Sstevel@tonic-gate 	prt_mad,	/* MAD -- print madvise() argument */
2441*7c478bd9Sstevel@tonic-gate 	prt_ulm,	/* ULM -- print ulimit() argument */
2442*7c478bd9Sstevel@tonic-gate 	prt_rlm,	/* RLM -- print get/setrlimit() argument */
2443*7c478bd9Sstevel@tonic-gate 	prt_cnf,	/* CNF -- print sysconfig() argument */
2444*7c478bd9Sstevel@tonic-gate 	prt_inf,	/* INF -- print sysinfo() argument */
2445*7c478bd9Sstevel@tonic-gate 	prt_ptc,	/* PTC -- print pathconf/fpathconf() argument */
2446*7c478bd9Sstevel@tonic-gate 	prt_fui,	/* FUI -- print fusers() input argument */
2447*7c478bd9Sstevel@tonic-gate 	prt_idt,	/* IDT -- print idtype_t, waitid() argument */
2448*7c478bd9Sstevel@tonic-gate 	prt_lwf,	/* LWF -- print lwp_create() flags */
2449*7c478bd9Sstevel@tonic-gate 	prt_itm,	/* ITM -- print [get|set]itimer() arg */
2450*7c478bd9Sstevel@tonic-gate 	prt_llo,	/* LLO -- print long long offset arg */
2451*7c478bd9Sstevel@tonic-gate 	prt_mod,	/* MOD -- print modctl() subcode */
2452*7c478bd9Sstevel@tonic-gate 	prt_whn,	/* WHN -- print lseek() whence arguiment */
2453*7c478bd9Sstevel@tonic-gate 	prt_acl,	/* ACL -- print acl() code */
2454*7c478bd9Sstevel@tonic-gate 	prt_aio,	/* AIO -- print kaio() code */
2455*7c478bd9Sstevel@tonic-gate 	prt_aud,	/* AUD -- print auditsys() code */
2456*7c478bd9Sstevel@tonic-gate 	prt_uns,	/* DEC -- print value in unsigned decimal */
2457*7c478bd9Sstevel@tonic-gate 	prt_clc,	/* CLC -- print cladm command argument */
2458*7c478bd9Sstevel@tonic-gate 	prt_clf,	/* CLF -- print cladm flag argument */
2459*7c478bd9Sstevel@tonic-gate 	prt_cor,	/* COR -- print corectl() subcode */
2460*7c478bd9Sstevel@tonic-gate 	prt_cco,	/* CCO -- print corectl() options */
2461*7c478bd9Sstevel@tonic-gate 	prt_ccc,	/* CCC -- print corectl() content */
2462*7c478bd9Sstevel@tonic-gate 	prt_rcc,	/* RCC -- print corectl() returned content */
2463*7c478bd9Sstevel@tonic-gate 	prt_cpc,	/* CPC -- print cpc() subcode */
2464*7c478bd9Sstevel@tonic-gate 	prt_sqc,	/* SQC -- print sigqueue() si_code argument */
2465*7c478bd9Sstevel@tonic-gate 	prt_pc4,	/* PC4 -- print priocntlsys() (fourth) argument */
2466*7c478bd9Sstevel@tonic-gate 	prt_pc5,	/* PC5 -- print priocntlsys() (key, value) pairs */
2467*7c478bd9Sstevel@tonic-gate 	prt_pst,	/* PST -- print processor set id */
2468*7c478bd9Sstevel@tonic-gate 	prt_mif,	/* MIF -- print meminfo() arguments */
2469*7c478bd9Sstevel@tonic-gate 	prt_pfm,	/* PFM -- print so_socket() proto-family (1st) arg */
2470*7c478bd9Sstevel@tonic-gate 	prt_skt,	/* SKT -- print so_socket() socket-type (2nd) arg */
2471*7c478bd9Sstevel@tonic-gate 	prt_skp,	/* SKP -- print so_socket() protocol (3rd) arg */
2472*7c478bd9Sstevel@tonic-gate 	prt_skv,	/* SKV -- print socket version arg */
2473*7c478bd9Sstevel@tonic-gate 	prt_sol,	/* SOL -- print [sg]etsockopt() level (2nd) arg */
2474*7c478bd9Sstevel@tonic-gate 	prt_son,	/* SON -- print [sg]etsockopt() opt-name (3rd) arg */
2475*7c478bd9Sstevel@tonic-gate 	prt_utt,	/* UTT -- print utrap type */
2476*7c478bd9Sstevel@tonic-gate 	prt_uth,	/* UTH -- print utrap handler */
2477*7c478bd9Sstevel@tonic-gate 	prt_acc,	/* ACC -- print access() flags */
2478*7c478bd9Sstevel@tonic-gate 	prt_sht,	/* SHT -- print shutdown() how (2nd) argument */
2479*7c478bd9Sstevel@tonic-gate 	prt_ffg,	/* FFG -- print fcntl() flags (3rd) argument */
2480*7c478bd9Sstevel@tonic-gate 	prt_prs,	/* PRS -- print privilege set */
2481*7c478bd9Sstevel@tonic-gate 	prt_pro,	/* PRO -- print privilege set operation */
2482*7c478bd9Sstevel@tonic-gate 	prt_prn,	/* PRN -- print privilege set name */
2483*7c478bd9Sstevel@tonic-gate 	prt_pfl,	/* PFL -- print privilege/process flag name */
2484*7c478bd9Sstevel@tonic-gate 	prt_laf,	/* LAF -- print lgrp_affinity arguments */
2485*7c478bd9Sstevel@tonic-gate 	prt_key,	/* KEY -- print key_t 0 as IPC_PRIVATE */
2486*7c478bd9Sstevel@tonic-gate 	prt_zga,	/* ZGA -- print zone_getattr attribute types */
2487*7c478bd9Sstevel@tonic-gate 	prt_atc,	/* ATC -- print AT_FDCWD or file descriptor */
2488*7c478bd9Sstevel@tonic-gate 	prt_lio,	/* LIO -- print LIO_XX flags */
2489*7c478bd9Sstevel@tonic-gate 	prt_dfl,	/* DFL -- print door_create() flags */
2490*7c478bd9Sstevel@tonic-gate 	prt_dpm,	/* DPM -- print DOOR_PARAM_XX flags */
2491*7c478bd9Sstevel@tonic-gate 	prt_dec,	/* HID -- hidden argument, make this the last one */
2492*7c478bd9Sstevel@tonic-gate };
2493