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