xref: /titanic_50/usr/src/cmd/truss/print.c (revision f9edfba4e2ac2531f0e52d0c4007976054e1023d)
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 	case UDP_NAT_T_ENDPOINT:	return ("UDP_NAT_T_ENDPOINT");
1901 
1902 	default:			(void) snprintf(pri->code_buf,
1903 					    sizeof (pri->code_buf), "0x%lx",
1904 					    val);
1905 					return (pri->code_buf);
1906 	}
1907 }
1908 
1909 
1910 /*
1911  * Print setsockopt()/getsockopt() 3rd argument.
1912  */
1913 /*ARGSUSED*/
1914 void
1915 prt_son(private_t *pri, int raw, long val)
1916 {
1917 	/* cheating -- look at the level */
1918 	switch (pri->sys_args[1]) {
1919 	case SOL_SOCKET:	outstring(pri, sol_optname(pri, val));
1920 				break;
1921 	case IPPROTO_TCP:	outstring(pri, tcp_optname(pri, val));
1922 				break;
1923 	case IPPROTO_UDP:	outstring(pri, udp_optname(pri, val));
1924 				break;
1925 	case IPPROTO_SCTP:	outstring(pri, sctp_optname(pri, val));
1926 				break;
1927 	default:		prt_dec(pri, 0, val);
1928 				break;
1929 	}
1930 }
1931 
1932 
1933 /*
1934  * Print utrap type
1935  */
1936 /*ARGSUSED*/
1937 void
1938 prt_utt(private_t *pri, int raw, long val)
1939 {
1940 	const char *s = NULL;
1941 
1942 #ifdef __sparc
1943 	if (!raw) {
1944 		switch (val) {
1945 		case UT_INSTRUCTION_DISABLED:
1946 			s = "UT_INSTRUCTION_DISABLED"; break;
1947 		case UT_INSTRUCTION_ERROR:
1948 			s = "UT_INSTRUCTION_ERROR"; break;
1949 		case UT_INSTRUCTION_PROTECTION:
1950 			s = "UT_INSTRUCTION_PROTECTION"; break;
1951 		case UT_ILLTRAP_INSTRUCTION:
1952 			s = "UT_ILLTRAP_INSTRUCTION"; break;
1953 		case UT_ILLEGAL_INSTRUCTION:
1954 			s = "UT_ILLEGAL_INSTRUCTION"; break;
1955 		case UT_PRIVILEGED_OPCODE:
1956 			s = "UT_PRIVILEGED_OPCODE"; break;
1957 		case UT_FP_DISABLED:
1958 			s = "UT_FP_DISABLED"; break;
1959 		case UT_FP_EXCEPTION_IEEE_754:
1960 			s = "UT_FP_EXCEPTION_IEEE_754"; break;
1961 		case UT_FP_EXCEPTION_OTHER:
1962 			s = "UT_FP_EXCEPTION_OTHER"; break;
1963 		case UT_TAG_OVERFLOW:
1964 			s = "UT_TAG_OVERFLOW"; break;
1965 		case UT_DIVISION_BY_ZERO:
1966 			s = "UT_DIVISION_BY_ZERO"; break;
1967 		case UT_DATA_EXCEPTION:
1968 			s = "UT_DATA_EXCEPTION"; break;
1969 		case UT_DATA_ERROR:
1970 			s = "UT_DATA_ERROR"; break;
1971 		case UT_DATA_PROTECTION:
1972 			s = "UT_DATA_PROTECTION"; break;
1973 		case UT_MEM_ADDRESS_NOT_ALIGNED:
1974 			s = "UT_MEM_ADDRESS_NOT_ALIGNED"; break;
1975 		case UT_PRIVILEGED_ACTION:
1976 			s = "UT_PRIVILEGED_ACTION"; break;
1977 		case UT_ASYNC_DATA_ERROR:
1978 			s = "UT_ASYNC_DATA_ERROR"; break;
1979 		case UT_TRAP_INSTRUCTION_16:
1980 			s = "UT_TRAP_INSTRUCTION_16"; break;
1981 		case UT_TRAP_INSTRUCTION_17:
1982 			s = "UT_TRAP_INSTRUCTION_17"; break;
1983 		case UT_TRAP_INSTRUCTION_18:
1984 			s = "UT_TRAP_INSTRUCTION_18"; break;
1985 		case UT_TRAP_INSTRUCTION_19:
1986 			s = "UT_TRAP_INSTRUCTION_19"; break;
1987 		case UT_TRAP_INSTRUCTION_20:
1988 			s = "UT_TRAP_INSTRUCTION_20"; break;
1989 		case UT_TRAP_INSTRUCTION_21:
1990 			s = "UT_TRAP_INSTRUCTION_21"; break;
1991 		case UT_TRAP_INSTRUCTION_22:
1992 			s = "UT_TRAP_INSTRUCTION_22"; break;
1993 		case UT_TRAP_INSTRUCTION_23:
1994 			s = "UT_TRAP_INSTRUCTION_23"; break;
1995 		case UT_TRAP_INSTRUCTION_24:
1996 			s = "UT_TRAP_INSTRUCTION_24"; break;
1997 		case UT_TRAP_INSTRUCTION_25:
1998 			s = "UT_TRAP_INSTRUCTION_25"; break;
1999 		case UT_TRAP_INSTRUCTION_26:
2000 			s = "UT_TRAP_INSTRUCTION_26"; break;
2001 		case UT_TRAP_INSTRUCTION_27:
2002 			s = "UT_TRAP_INSTRUCTION_27"; break;
2003 		case UT_TRAP_INSTRUCTION_28:
2004 			s = "UT_TRAP_INSTRUCTION_28"; break;
2005 		case UT_TRAP_INSTRUCTION_29:
2006 			s = "UT_TRAP_INSTRUCTION_29"; break;
2007 		case UT_TRAP_INSTRUCTION_30:
2008 			s = "UT_TRAP_INSTRUCTION_30"; break;
2009 		case UT_TRAP_INSTRUCTION_31:
2010 			s = "UT_TRAP_INSTRUCTION_31"; break;
2011 		}
2012 	}
2013 #endif /* __sparc */
2014 
2015 	if (s == NULL)
2016 		prt_dec(pri, 0, val);
2017 	else
2018 		outstring(pri, s);
2019 }
2020 
2021 
2022 /*
2023  * Print utrap handler
2024  */
2025 void
2026 prt_uth(private_t *pri, int raw, long val)
2027 {
2028 	const char *s = NULL;
2029 
2030 	if (!raw) {
2031 		switch (val) {
2032 		case (long)UTH_NOCHANGE:	s = "UTH_NOCHANGE"; break;
2033 		}
2034 	}
2035 
2036 	if (s == NULL)
2037 		prt_hex(pri, 0, val);
2038 	else
2039 		outstring(pri, s);
2040 }
2041 
2042 const char *
2043 access_flags(private_t *pri, long arg)
2044 {
2045 #define	E_OK 010
2046 	char *str = pri->code_buf;
2047 
2048 	if (arg & ~(R_OK|W_OK|X_OK|E_OK))
2049 		return (NULL);
2050 
2051 	/* NB: F_OK == 0 */
2052 	if (arg == F_OK)
2053 		return ("F_OK");
2054 	if (arg == E_OK)
2055 		return ("F_OK|E_OK");
2056 
2057 	*str = '\0';
2058 	if (arg & R_OK)
2059 		(void) strlcat(str, "|R_OK", sizeof (pri->code_buf));
2060 	if (arg & W_OK)
2061 		(void) strlcat(str, "|W_OK", sizeof (pri->code_buf));
2062 	if (arg & X_OK)
2063 		(void) strlcat(str, "|X_OK", sizeof (pri->code_buf));
2064 	if (arg & E_OK)
2065 		(void) strlcat(str, "|E_OK", sizeof (pri->code_buf));
2066 	return ((const char *)(str + 1));
2067 #undef E_OK
2068 }
2069 
2070 /*
2071  * Print access() flags.
2072  */
2073 void
2074 prt_acc(private_t *pri, int raw, long val)
2075 {
2076 	const char *s = raw? NULL : access_flags(pri, val);
2077 
2078 	if (s == NULL)
2079 		prt_dex(pri, 0, val);
2080 	else
2081 		outstring(pri, s);
2082 }
2083 
2084 /*
2085  * Print shutdown() "how" (2nd) argument
2086  */
2087 void
2088 prt_sht(private_t *pri, int raw, long val)
2089 {
2090 	if (raw) {
2091 		prt_dex(pri, 0, val);
2092 		return;
2093 	}
2094 	switch (val) {
2095 	case SHUT_RD:	outstring(pri, "SHUT_RD");	break;
2096 	case SHUT_WR:	outstring(pri, "SHUT_WR");	break;
2097 	case SHUT_RDWR:	outstring(pri, "SHUT_RDWR");	break;
2098 	default:	prt_dec(pri, 0, val);		break;
2099 	}
2100 }
2101 
2102 /*
2103  * Print fcntl() F_SETFL flags (3rd) argument or fdsync flag (2nd arg)
2104  */
2105 static struct fcntl_flags {
2106 	long		val;
2107 	const char	*name;
2108 } fcntl_flags[] = {
2109 #define	FC_FL(flag)	{ (long)flag, "|" # flag }
2110 #ifdef C2_AUDIT
2111 	FC_FL(FREVOKED),
2112 #endif
2113 	FC_FL(FREAD),
2114 	FC_FL(FWRITE),
2115 	FC_FL(FNDELAY),
2116 	FC_FL(FAPPEND),
2117 	FC_FL(FSYNC),
2118 	FC_FL(FDSYNC),
2119 	FC_FL(FRSYNC),
2120 	FC_FL(FOFFMAX),
2121 	FC_FL(FNONBLOCK),
2122 	FC_FL(FCREAT),
2123 	FC_FL(FTRUNC),
2124 	FC_FL(FEXCL),
2125 	FC_FL(FNOCTTY),
2126 	FC_FL(FXATTR),
2127 	FC_FL(FASYNC),
2128 	FC_FL(FNODSYNC)
2129 #undef FC_FL
2130 };
2131 
2132 void
2133 prt_ffg(private_t *pri, int raw, long val)
2134 {
2135 #define	CBSIZE	sizeof (pri->code_buf)
2136 	char *s = pri->code_buf;
2137 	size_t used = 1;
2138 	struct fcntl_flags *fp;
2139 
2140 	if (raw) {
2141 		(void) snprintf(s, CBSIZE, "0x%lx", val);
2142 		outstring(pri, s);
2143 		return;
2144 	}
2145 	if (val == 0) {
2146 		outstring(pri, "(no flags)");
2147 		return;
2148 	}
2149 
2150 	*s = '\0';
2151 	for (fp = fcntl_flags;
2152 	    fp < &fcntl_flags[sizeof (fcntl_flags) / sizeof (*fp)]; fp++) {
2153 		if (val & fp->val) {
2154 			used = strlcat(s, fp->name, CBSIZE);
2155 			val &= ~fp->val;
2156 		}
2157 	}
2158 
2159 	if (val != 0 && used <= CBSIZE)
2160 		used += snprintf(s + used, CBSIZE - used, "|0x%lx", val);
2161 
2162 	if (used >= CBSIZE)
2163 		(void) snprintf(s + 1, CBSIZE-1, "0x%lx", val);
2164 	outstring(pri, s + 1);
2165 #undef CBSIZE
2166 }
2167 
2168 void
2169 prt_prs(private_t *pri, int raw, long val)
2170 {
2171 	static size_t setsize;
2172 	priv_set_t *set = priv_allocset();
2173 
2174 	if (setsize == 0) {
2175 		const priv_impl_info_t *info = getprivimplinfo();
2176 		if (info != NULL)
2177 			setsize = info->priv_setsize * sizeof (priv_chunk_t);
2178 	}
2179 
2180 	if (setsize != 0 && !raw && set != NULL &&
2181 	    Pread(Proc, set, setsize, val) == setsize) {
2182 		int i;
2183 
2184 		outstring(pri, "{");
2185 		for (i = 0; i < setsize / sizeof (priv_chunk_t); i++) {
2186 			char buf[9];	/* 8 hex digits + '\0' */
2187 			(void) snprintf(buf, sizeof (buf), "%08x",
2188 			    ((priv_chunk_t *)set)[i]);
2189 			outstring(pri, buf);
2190 		}
2191 
2192 		outstring(pri, "}");
2193 	} else {
2194 		prt_hex(pri, 0, val);
2195 	}
2196 
2197 	if (set != NULL)
2198 		priv_freeset(set);
2199 }
2200 
2201 /*
2202  * Print privilege set operation.
2203  */
2204 void
2205 prt_pro(private_t *pri, int raw, long val)
2206 {
2207 	const char *s = NULL;
2208 
2209 	if (!raw) {
2210 		switch ((priv_op_t)val) {
2211 		case PRIV_ON:		s = "PRIV_ON";		break;
2212 		case PRIV_OFF:		s = "PRIV_OFF";		break;
2213 		case PRIV_SET:		s = "PRIV_SET";		break;
2214 		}
2215 	}
2216 
2217 	if (s == NULL)
2218 		prt_dec(pri, 0, val);
2219 	else
2220 		outstring(pri, s);
2221 }
2222 
2223 /*
2224  * Print privilege set name
2225  */
2226 void
2227 prt_prn(private_t *pri, int raw, long val)
2228 {
2229 	const char *s = NULL;
2230 
2231 	if (!raw)
2232 		s = priv_getsetbynum((int)val);
2233 
2234 	if (s == NULL)
2235 		prt_dec(pri, 0, val);
2236 	else {
2237 		char *dup = strdup(s);
2238 		char *q;
2239 
2240 		/* Do the best we can in this case */
2241 		if (dup == NULL) {
2242 			outstring(pri, s);
2243 			return;
2244 		}
2245 
2246 		outstring(pri, "PRIV_");
2247 
2248 		q = dup;
2249 
2250 		while (*q != '\0') {
2251 			*q = toupper(*q);
2252 			q++;
2253 		}
2254 		outstring(pri, dup);
2255 		free(dup);
2256 	}
2257 }
2258 
2259 /*
2260  * Print process flag names.
2261  */
2262 void
2263 prt_pfl(private_t *pri, int raw, long val)
2264 {
2265 	const char *s = NULL;
2266 
2267 	if (!raw) {
2268 		switch ((int)val) {
2269 		case PRIV_DEBUG:	s = "PRIV_DEBUG";	break;
2270 		case PRIV_AWARE:	s = "PRIV_AWARE";	break;
2271 		}
2272 	}
2273 
2274 	if (s == NULL)
2275 		prt_dec(pri, 0, val);
2276 	else
2277 		outstring(pri, s);
2278 }
2279 
2280 /*
2281  * Print lgrp_affinity_{get,set}() arguments.
2282  */
2283 /*ARGSUSED*/
2284 void
2285 prt_laf(private_t *pri, int raw, long val)
2286 {
2287 	lgrp_affinity_args_t	laff;
2288 
2289 	if (Pread(Proc, &laff, sizeof (lgrp_affinity_args_t), val) !=
2290 	    sizeof (lgrp_affinity_args_t)) {
2291 		prt_hex(pri, 0, val);
2292 		return;
2293 	}
2294 	/*
2295 	 * arrange the arguments in the order that user calls with
2296 	 */
2297 	prt_dec(pri, 0, laff.idtype);
2298 	outstring(pri, ", ");
2299 	prt_dec(pri, 0, laff.id);
2300 	outstring(pri, ", ");
2301 	prt_dec(pri, 0, laff.lgrp);
2302 	outstring(pri, ", ");
2303 	if (pri->sys_args[0] == LGRP_SYS_AFFINITY_SET)
2304 		prt_dec(pri, 0, laff.aff);
2305 }
2306 
2307 /*
2308  * Print a key_t as IPC_PRIVATE if it is 0.
2309  */
2310 void
2311 prt_key(private_t *pri, int raw, long val)
2312 {
2313 	if (!raw && val == 0)
2314 		outstring(pri, "IPC_PRIVATE");
2315 	else
2316 		prt_dec(pri, 0, val);
2317 }
2318 
2319 
2320 /*
2321  * Print zone_getattr() attribute types.
2322  */
2323 void
2324 prt_zga(private_t *pri, int raw, long val)
2325 {
2326 	const char *s = NULL;
2327 
2328 	if (!raw) {
2329 		switch ((int)val) {
2330 		case ZONE_ATTR_NAME:	s = "ZONE_ATTR_NAME";	break;
2331 		case ZONE_ATTR_ROOT:	s = "ZONE_ATTR_ROOT";	break;
2332 		case ZONE_ATTR_STATUS:	s = "ZONE_ATTR_STATUS";	break;
2333 		case ZONE_ATTR_PRIVSET:	s = "ZONE_ATTR_PRIVSET"; break;
2334 		case ZONE_ATTR_UNIQID:	s = "ZONE_ATTR_UNIQID"; break;
2335 		case ZONE_ATTR_POOLID:	s = "ZONE_ATTR_POOLID"; break;
2336 		case ZONE_ATTR_INITPID:	s = "ZONE_ATTR_INITPID"; break;
2337 		case ZONE_ATTR_SLBL:	s = "ZONE_ATTR_SLBL"; break;
2338 		case ZONE_ATTR_INITNAME:	s = "ZONE_ATTR_INITNAME"; break;
2339 		case ZONE_ATTR_BOOTARGS:	s = "ZONE_ATTR_BOOTARGS"; break;
2340 		case ZONE_ATTR_BRAND:	s = "ZONE_ATTR_BRAND"; break;
2341 		case ZONE_ATTR_FLAGS:	s = "ZONE_ATTR_FLAGS"; break;
2342 		case ZONE_ATTR_PHYS_MCAP: s = "ZONE_ATTR_PHYS_MCAP"; break;
2343 		}
2344 	}
2345 
2346 	if (s == NULL)
2347 		prt_dec(pri, 0, val);
2348 	else
2349 		outstring(pri, s);
2350 }
2351 
2352 /*
2353  * Print a file descriptor as AT_FDCWD if necessary
2354  */
2355 void
2356 prt_atc(private_t *pri, int raw, long val)
2357 {
2358 	if (!raw && val == AT_FDCWD)
2359 		outstring(pri, "AT_FDCWD");
2360 	else
2361 		prt_dec(pri, 0, val);
2362 }
2363 
2364 /*
2365  * Print Trusted Networking database operation codes (labelsys; tn*)
2366  */
2367 static void
2368 prt_tnd(private_t *pri, int raw, long val)
2369 {
2370 	const char *s = NULL;
2371 
2372 	if (!raw) {
2373 		switch ((tsol_dbops_t)val) {
2374 		case TNDB_NOOP:		s = "TNDB_NOOP";	break;
2375 		case TNDB_LOAD:		s = "TNDB_LOAD";	break;
2376 		case TNDB_DELETE:	s = "TNDB_DELETE";	break;
2377 		case TNDB_FLUSH:	s = "TNDB_FLUSH";	break;
2378 		case TNDB_GET:		s = "TNDB_GET";		break;
2379 		}
2380 	}
2381 
2382 	if (s == NULL)
2383 		prt_dec(pri, 0, val);
2384 	else
2385 		outstring(pri, s);
2386 }
2387 
2388 /*
2389  * Print LIO_XX flags
2390  */
2391 void
2392 prt_lio(private_t *pri, int raw, long val)
2393 {
2394 	if (raw)
2395 		prt_dec(pri, 0, val);
2396 	else if (val == LIO_WAIT)
2397 		outstring(pri, "LIO_WAIT");
2398 	else if (val == LIO_NOWAIT)
2399 		outstring(pri, "LIO_NOWAIT");
2400 	else
2401 		prt_dec(pri, 0, val);
2402 }
2403 
2404 const char *
2405 door_flags(private_t *pri, long val)
2406 {
2407 	door_attr_t attr = (door_attr_t)val;
2408 	char *str = pri->code_buf;
2409 
2410 	*str = '\0';
2411 #define	PROCESS_FLAG(flg)						\
2412 	if (attr & flg) {						\
2413 		(void) strlcat(str, "|" #flg, sizeof (pri->code_buf));	\
2414 		attr &= ~flg;						\
2415 	}
2416 
2417 	PROCESS_FLAG(DOOR_UNREF);
2418 	PROCESS_FLAG(DOOR_UNREF_MULTI);
2419 	PROCESS_FLAG(DOOR_PRIVATE);
2420 	PROCESS_FLAG(DOOR_REFUSE_DESC);
2421 	PROCESS_FLAG(DOOR_NO_CANCEL);
2422 	PROCESS_FLAG(DOOR_LOCAL);
2423 	PROCESS_FLAG(DOOR_REVOKED);
2424 	PROCESS_FLAG(DOOR_IS_UNREF);
2425 #undef PROCESS_FLAG
2426 
2427 	if (attr != 0 || *str == '\0') {
2428 		size_t len = strlen(str);
2429 		(void) snprintf(str + len, sizeof (pri->code_buf) - len,
2430 		    "|0x%X", attr);
2431 	}
2432 
2433 	return (str + 1);
2434 }
2435 
2436 /*
2437  * Print door_create() flags
2438  */
2439 void
2440 prt_dfl(private_t *pri, int raw, long val)
2441 {
2442 	if (raw)
2443 		prt_hex(pri, 0, val);
2444 	else
2445 		outstring(pri, door_flags(pri, val));
2446 }
2447 
2448 /*
2449  * Print door_*param() param argument
2450  */
2451 void
2452 prt_dpm(private_t *pri, int raw, long val)
2453 {
2454 	if (raw)
2455 		prt_hex(pri, 0, val);
2456 	else if (val == DOOR_PARAM_DESC_MAX)
2457 		outstring(pri, "DOOR_PARAM_DESC_MAX");
2458 	else if (val == DOOR_PARAM_DATA_MIN)
2459 		outstring(pri, "DOOR_PARAM_DATA_MIN");
2460 	else if (val == DOOR_PARAM_DATA_MAX)
2461 		outstring(pri, "DOOR_PARAM_DATA_MAX");
2462 	else
2463 		prt_hex(pri, 0, val);
2464 }
2465 
2466 /*
2467  * Print rctlsys subcodes
2468  */
2469 void
2470 prt_rsc(private_t *pri, int raw, long val)	/* print utssys code */
2471 {
2472 	const char *s = raw? NULL : rctlsyscode(val);
2473 
2474 	if (s == NULL)
2475 		prt_dec(pri, 0, val);
2476 	else
2477 		outstring(pri, s);
2478 }
2479 
2480 /*
2481  * Print getrctl flags
2482  */
2483 void
2484 prt_rgf(private_t *pri, int raw, long val)
2485 {
2486 	long action = val & (~RCTLSYS_ACTION_MASK);
2487 
2488 	if (raw)
2489 		prt_hex(pri, 0, val);
2490 	else if (action == RCTL_FIRST)
2491 		outstring(pri, "RCTL_FIRST");
2492 	else if (action == RCTL_NEXT)
2493 		outstring(pri, "RCTL_NEXT");
2494 	else if (action == RCTL_USAGE)
2495 		outstring(pri, "RCTL_USAGE");
2496 	else
2497 		prt_hex(pri, 0, val);
2498 }
2499 
2500 /*
2501  * Print setrctl flags
2502  */
2503 void
2504 prt_rsf(private_t *pri, int raw, long val)
2505 {
2506 	long action = val & (~RCTLSYS_ACTION_MASK);
2507 	long pval = val & RCTL_LOCAL_ACTION_MASK;
2508 	char *s = pri->code_buf;
2509 
2510 	if (raw) {
2511 		prt_hex(pri, 0, val);
2512 		return;
2513 	} else if (action == RCTL_INSERT)
2514 		(void) strcpy(s, "RCTL_INSERT");
2515 	else if (action == RCTL_DELETE)
2516 		(void) strcpy(s, "RCTL_DELETE");
2517 	else if (action == RCTL_REPLACE)
2518 		(void) strcpy(s, "RCTL_REPLACE");
2519 	else {
2520 		prt_hex(pri, 0, val);
2521 		return;
2522 	}
2523 
2524 	if (pval & RCTL_USE_RECIPIENT_PID) {
2525 		pval ^= RCTL_USE_RECIPIENT_PID;
2526 		(void) strlcat(s, "|RCTL_USE_RECIPIENT_PID",
2527 		    sizeof (pri->code_buf));
2528 	}
2529 
2530 	if ((pval & RCTLSYS_ACTION_MASK) != 0)
2531 		prt_hex(pri, 0, val);
2532 	else if (*s != '\0')
2533 		outstring(pri, s);
2534 	else
2535 		prt_hex(pri, 0, val);
2536 }
2537 
2538 /*
2539  * Print rctlctl flags
2540  */
2541 void
2542 prt_rcf(private_t *pri, int raw, long val)
2543 {
2544 	long action = val & (~RCTLSYS_ACTION_MASK);
2545 
2546 	if (raw)
2547 		prt_hex(pri, 0, val);
2548 	else if (action == RCTLCTL_GET)
2549 		outstring(pri, "RCTLCTL_GET");
2550 	else if (action == RCTLCTL_SET)
2551 		outstring(pri, "RCTLCTL_SET");
2552 	else
2553 		prt_hex(pri, 0, val);
2554 }
2555 
2556 /*
2557  * Print setprojrctl flags
2558  */
2559 void
2560 prt_spf(private_t *pri, int raw, long val)
2561 {
2562 	long action = val & TASK_PROJ_MASK;
2563 
2564 	if (!raw && (action == TASK_PROJ_PURGE))
2565 		outstring(pri, "TASK_PROJ_PURGE");
2566 	else
2567 		prt_hex(pri, 0, val);
2568 }
2569 
2570 /*
2571  * Print forkx() flags
2572  */
2573 void
2574 prt_fxf(private_t *pri, int raw, long val)
2575 {
2576 	char *str;
2577 
2578 	if (val == 0)
2579 		outstring(pri, "0");
2580 	else if (raw || (val & ~(FORK_NOSIGCHLD | FORK_WAITPID)))
2581 		prt_hhx(pri, 0, val);
2582 	else {
2583 		str = pri->code_buf;
2584 		*str = '\0';
2585 		if (val & FORK_NOSIGCHLD)
2586 			(void) strlcat(str, "|FORK_NOSIGCHLD",
2587 			    sizeof (pri->code_buf));
2588 		if (val & FORK_WAITPID)
2589 			(void) strlcat(str, "|FORK_WAITPID",
2590 			    sizeof (pri->code_buf));
2591 		outstring(pri, str + 1);
2592 	}
2593 }
2594 
2595 /*
2596  * Array of pointers to print functions, one for each format.
2597  */
2598 void (* const Print[])() = {
2599 	prt_nov,	/* NOV -- no value */
2600 	prt_dec,	/* DEC -- print value in decimal */
2601 	prt_oct,	/* OCT -- print value in octal */
2602 	prt_hex,	/* HEX -- print value in hexadecimal */
2603 	prt_dex,	/* DEX -- print value in hexadecimal if big enough */
2604 	prt_stg,	/* STG -- print value as string */
2605 	prt_ioc,	/* IOC -- print ioctl code */
2606 	prt_fcn,	/* FCN -- print fcntl code */
2607 	prt_s86,	/* S86 -- print sysi86 code */
2608 	prt_uts,	/* UTS -- print utssys code */
2609 	prt_opn,	/* OPN -- print open code */
2610 	prt_sig,	/* SIG -- print signal name plus flags */
2611 	prt_act,	/* ACT -- print signal action value */
2612 	prt_msc,	/* MSC -- print msgsys command */
2613 	prt_msf,	/* MSF -- print msgsys flags */
2614 	prt_smc,	/* SMC -- print semsys command */
2615 	prt_sef,	/* SEF -- print semsys flags */
2616 	prt_shc,	/* SHC -- print shmsys command */
2617 	prt_shf,	/* SHF -- print shmsys flags */
2618 	prt_plk,	/* PLK -- print plock code */
2619 	prt_sfs,	/* SFS -- print sysfs code */
2620 	prt_rst,	/* RST -- print string returned by syscall */
2621 	prt_smf,	/* SMF -- print streams message flags */
2622 	prt_ioa,	/* IOA -- print ioctl argument */
2623 	prt_six,	/* SIX -- print signal, masked with SIGNO_MASK */
2624 	prt_mtf,	/* MTF -- print mount flags */
2625 	prt_mft,	/* MFT -- print mount file system type */
2626 	prt_iob,	/* IOB -- print contents of I/O buffer */
2627 	prt_hhx,	/* HHX -- print value in hexadecimal (half size) */
2628 	prt_wop,	/* WOP -- print waitsys() options */
2629 	prt_spm,	/* SPM -- print sigprocmask argument */
2630 	prt_rlk,	/* RLK -- print readlink buffer */
2631 	prt_mpr,	/* MPR -- print mmap()/mprotect() flags */
2632 	prt_mty,	/* MTY -- print mmap() mapping type flags */
2633 	prt_mcf,	/* MCF -- print memcntl() function */
2634 	prt_mc4,	/* MC4 -- print memcntl() (fourth) argument */
2635 	prt_mc5,	/* MC5 -- print memcntl() (fifth) argument */
2636 	prt_mad,	/* MAD -- print madvise() argument */
2637 	prt_ulm,	/* ULM -- print ulimit() argument */
2638 	prt_rlm,	/* RLM -- print get/setrlimit() argument */
2639 	prt_cnf,	/* CNF -- print sysconfig() argument */
2640 	prt_inf,	/* INF -- print sysinfo() argument */
2641 	prt_ptc,	/* PTC -- print pathconf/fpathconf() argument */
2642 	prt_fui,	/* FUI -- print fusers() input argument */
2643 	prt_idt,	/* IDT -- print idtype_t, waitid() argument */
2644 	prt_lwf,	/* LWF -- print lwp_create() flags */
2645 	prt_itm,	/* ITM -- print [get|set]itimer() arg */
2646 	prt_llo,	/* LLO -- print long long offset arg */
2647 	prt_mod,	/* MOD -- print modctl() subcode */
2648 	prt_whn,	/* WHN -- print lseek() whence arguiment */
2649 	prt_acl,	/* ACL -- print acl() code */
2650 	prt_aio,	/* AIO -- print kaio() code */
2651 	prt_aud,	/* AUD -- print auditsys() code */
2652 	prt_uns,	/* DEC -- print value in unsigned decimal */
2653 	prt_clc,	/* CLC -- print cladm command argument */
2654 	prt_clf,	/* CLF -- print cladm flag argument */
2655 	prt_cor,	/* COR -- print corectl() subcode */
2656 	prt_cco,	/* CCO -- print corectl() options */
2657 	prt_ccc,	/* CCC -- print corectl() content */
2658 	prt_rcc,	/* RCC -- print corectl() returned content */
2659 	prt_cpc,	/* CPC -- print cpc() subcode */
2660 	prt_sqc,	/* SQC -- print sigqueue() si_code argument */
2661 	prt_pc4,	/* PC4 -- print priocntlsys() (fourth) argument */
2662 	prt_pc5,	/* PC5 -- print priocntlsys() (key, value) pairs */
2663 	prt_pst,	/* PST -- print processor set id */
2664 	prt_mif,	/* MIF -- print meminfo() arguments */
2665 	prt_pfm,	/* PFM -- print so_socket() proto-family (1st) arg */
2666 	prt_skt,	/* SKT -- print so_socket() socket-type (2nd) arg */
2667 	prt_skp,	/* SKP -- print so_socket() protocol (3rd) arg */
2668 	prt_skv,	/* SKV -- print socket version arg */
2669 	prt_sol,	/* SOL -- print [sg]etsockopt() level (2nd) arg */
2670 	prt_son,	/* SON -- print [sg]etsockopt() opt-name (3rd) arg */
2671 	prt_utt,	/* UTT -- print utrap type */
2672 	prt_uth,	/* UTH -- print utrap handler */
2673 	prt_acc,	/* ACC -- print access() flags */
2674 	prt_sht,	/* SHT -- print shutdown() how (2nd) argument */
2675 	prt_ffg,	/* FFG -- print fcntl() flags (3rd) argument */
2676 	prt_prs,	/* PRS -- print privilege set */
2677 	prt_pro,	/* PRO -- print privilege set operation */
2678 	prt_prn,	/* PRN -- print privilege set name */
2679 	prt_pfl,	/* PFL -- print privilege/process flag name */
2680 	prt_laf,	/* LAF -- print lgrp_affinity arguments */
2681 	prt_key,	/* KEY -- print key_t 0 as IPC_PRIVATE */
2682 	prt_zga,	/* ZGA -- print zone_getattr attribute types */
2683 	prt_atc,	/* ATC -- print AT_FDCWD or file descriptor */
2684 	prt_lio,	/* LIO -- print LIO_XX flags */
2685 	prt_dfl,	/* DFL -- print door_create() flags */
2686 	prt_dpm,	/* DPM -- print DOOR_PARAM_XX flags */
2687 	prt_tnd,	/* TND -- print trusted network data base opcode */
2688 	prt_rsc,	/* RSC -- print rctlsys() subcodes */
2689 	prt_rgf,	/* RGF -- print getrctl() flags */
2690 	prt_rsf,	/* RSF -- print setrctl() flags */
2691 	prt_rcf,	/* RCF -- print rctlsys_ctl() flags */
2692 	prt_fxf,	/* FXF -- print forkx() flags */
2693 	prt_spf,	/* SPF -- print rctlsys_projset() flags */
2694 	prt_un1,	/* UN1 -- as prt_uns except for -1 */
2695 	prt_dec,	/* HID -- hidden argument, make this the last one */
2696 };
2697