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