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