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