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