xref: /titanic_41/usr/src/cmd/truss/print.c (revision 75e21072b15921edb21066ef5eaa2e412b163266)
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_AUDIT:		s = "BSM_AUDIT";	break;
1217 		case BSM_AUDITON:	s = "BSM_AUDITON";	break;
1218 		case BSM_AUDITCTL:	s = "BSM_AUDITCTL";	break;
1219 		case BSM_GETAUDIT_ADDR:	s = "BSM_GETAUDIT_ADDR"; break;
1220 		case BSM_SETAUDIT_ADDR:	s = "BSM_SETAUDIT_ADDR"; break;
1221 		}
1222 	}
1223 
1224 	if (s == NULL)
1225 		prt_dec(pri, 0, val);
1226 	else
1227 		outstring(pri, s);
1228 }
1229 
1230 void
1231 prt_cor(private_t *pri, int raw, long val)	/* print corectl() subcode */
1232 {
1233 	const char *s = NULL;
1234 
1235 	if (!raw) {
1236 		switch (val) {
1237 		case CC_SET_OPTIONS:
1238 			s = "CC_SET_OPTIONS";		break;
1239 		case CC_GET_OPTIONS:
1240 			s = "CC_GET_OPTIONS";		break;
1241 		case CC_SET_GLOBAL_PATH:
1242 			s = "CC_SET_GLOBAL_PATH";	break;
1243 		case CC_GET_GLOBAL_PATH:
1244 			s = "CC_GET_GLOBAL_PATH";	break;
1245 		case CC_SET_PROCESS_PATH:
1246 			s = "CC_SET_PROCESS_PATH";	break;
1247 		case CC_GET_PROCESS_PATH:
1248 			s = "CC_GET_PROCESS_PATH";	break;
1249 		case CC_SET_GLOBAL_CONTENT:
1250 			s = "CC_SET_GLOBAL_CONTENT";	break;
1251 		case CC_GET_GLOBAL_CONTENT:
1252 			s = "CC_GET_GLOBAL_CONTENT";	break;
1253 		case CC_SET_PROCESS_CONTENT:
1254 			s = "CC_SET_PROCESS_CONTENT";	break;
1255 		case CC_GET_PROCESS_CONTENT:
1256 			s = "CC_GET_PROCESS_CONTENT";	break;
1257 		case CC_SET_DEFAULT_PATH:
1258 			s = "CC_SET_DEFAULT_PATH";	break;
1259 		case CC_GET_DEFAULT_PATH:
1260 			s = "CC_GET_DEFAULT_PATH";	break;
1261 		case CC_SET_DEFAULT_CONTENT:
1262 			s = "CC_SET_DEFAULT_CONTENT";	break;
1263 		case CC_GET_DEFAULT_CONTENT:
1264 			s = "CC_GET_DEFAULT_CONTENT";	break;
1265 		}
1266 	}
1267 
1268 	if (s == NULL)
1269 		prt_dec(pri, 0, val);
1270 	else
1271 		outstring(pri, s);
1272 }
1273 
1274 void
1275 prt_cco(private_t *pri, int raw, long val)	/* print corectl() options */
1276 {
1277 	char *s;
1278 
1279 	if (val == 0)
1280 		prt_dec(pri, 0, val);
1281 	else if (raw || (val & ~CC_OPTIONS))
1282 		prt_hhx(pri, 0, val);
1283 	else {
1284 #define	CBSIZE	sizeof (pri->code_buf)
1285 		s = pri->code_buf;
1286 		*s = '\0';
1287 		if (val & CC_GLOBAL_PATH)
1288 			(void) strlcat(s, "|CC_GLOBAL_PATH", CBSIZE);
1289 		if (val & CC_PROCESS_PATH)
1290 			(void) strlcat(s, "|CC_PROCESS_PATH", CBSIZE);
1291 		if (val & CC_GLOBAL_SETID)
1292 			(void) strlcat(s, "|CC_GLOBAL_SETID", CBSIZE);
1293 		if (val & CC_PROCESS_SETID)
1294 			(void) strlcat(s, "|CC_PROCESS_SETID", CBSIZE);
1295 		if (val & CC_GLOBAL_LOG)
1296 			(void) strlcat(s, "|CC_GLOBAL_LOG", CBSIZE);
1297 		if (*s == '\0')
1298 			prt_hhx(pri, 0, val);
1299 		else
1300 			outstring(pri, ++s);
1301 #undef CBSIZE
1302 	}
1303 }
1304 
1305 void
1306 prt_ccc(private_t *pri, int raw, long val)	/* print corectl() content */
1307 {
1308 	core_content_t ccc;
1309 
1310 	if (Pread(Proc, &ccc, sizeof (ccc), val) != sizeof (ccc))
1311 		prt_hex(pri, 0, val);
1312 	else if (!raw && proc_content2str(ccc, pri->code_buf,
1313 	    sizeof (pri->code_buf)) >= 0)
1314 		outstring(pri, pri->code_buf);
1315 	else
1316 		prt_hhx(pri, 0, (long)ccc);
1317 }
1318 
1319 void
1320 prt_rcc(private_t *pri, int raw, long val)	/* print corectl() ret. cont. */
1321 {
1322 	core_content_t ccc;
1323 
1324 	if (pri->Errno || Pread(Proc, &ccc, sizeof (ccc), val) != sizeof (ccc))
1325 		prt_hex(pri, 0, val);
1326 	else if (!raw && proc_content2str(ccc, pri->code_buf,
1327 	    sizeof (pri->code_buf)) >= 0)
1328 		outstring(pri, pri->code_buf);
1329 	else
1330 		prt_hhx(pri, 0, (long)ccc);
1331 }
1332 
1333 void
1334 prt_cpc(private_t *pri, int raw, long val)	/* print cpc() subcode */
1335 {
1336 	const char *s = NULL;
1337 
1338 	if (!raw) {
1339 		switch (val) {
1340 		case CPC_BIND:		s = "CPC_BIND";		break;
1341 		case CPC_SAMPLE:	s = "CPC_SAMPLE";	break;
1342 		case CPC_INVALIDATE:	s = "CPC_INVALIDATE";	break;
1343 		case CPC_RELE:		s = "CPC_RELE";		break;
1344 		case CPC_EVLIST_SIZE:	s = "CPC_EVLIST_SIZE";	break;
1345 		case CPC_LIST_EVENTS:	s = "CPC_LIST_EVENTS";	break;
1346 		case CPC_ATTRLIST_SIZE:	s = "CPC_ATTRLIST_SIZE"; break;
1347 		case CPC_LIST_ATTRS:	s = "CPC_LIST_ATTRS";	break;
1348 		case CPC_IMPL_NAME:	s = "CPC_IMPL_NAME";	break;
1349 		case CPC_CPUREF:	s = "CPC_CPUREF";	break;
1350 		case CPC_USR_EVENTS:	s = "CPC_USR_EVENTS";	break;
1351 		case CPC_SYS_EVENTS:	s = "CPC_SYS_EVENTS";	break;
1352 		case CPC_NPIC:		s = "CPC_NPIC";		break;
1353 		case CPC_CAPS:		s = "CPC_CAPS";		break;
1354 		case CPC_ENABLE:	s = "CPC_ENABLE";	break;
1355 		case CPC_DISABLE:	s = "CPC_DISABLE";	break;
1356 		}
1357 	}
1358 
1359 	if (s == NULL)
1360 		prt_dec(pri, 0, val);
1361 	else
1362 		outstring(pri, s);
1363 }
1364 
1365 void
1366 outstring(private_t *pri, const char *s)
1367 {
1368 	int len = strlen(s);
1369 
1370 	GROW(len);
1371 	(void) strcpy(pri->sys_string + pri->sys_leng, s);
1372 	pri->sys_leng += len;
1373 }
1374 
1375 void
1376 grow(private_t *pri, int nbyte)	/* reallocate format buffer if necessary */
1377 {
1378 	while (pri->sys_leng + nbyte >= pri->sys_ssize)
1379 		pri->sys_string = my_realloc(pri->sys_string,
1380 		    pri->sys_ssize *= 2, "format buffer");
1381 }
1382 
1383 void
1384 prt_clc(private_t *pri, int raw, long val)
1385 {
1386 	const char *s = NULL;
1387 
1388 	if (!raw) {
1389 		switch (val) {
1390 		case CL_INITIALIZE:	s = "CL_INITIALIZE";	break;
1391 		case CL_CONFIG:		s = "CL_CONFIG";	break;
1392 		}
1393 	}
1394 
1395 	if (s == NULL)
1396 		prt_dec(pri, 0, val);
1397 	else
1398 		outstring(pri, s);
1399 }
1400 
1401 void
1402 prt_clf(private_t *pri, int raw, long val)
1403 {
1404 	const char *s = NULL;
1405 
1406 	if (!raw) {
1407 		switch (pri->sys_args[0]) {
1408 		case CL_CONFIG:
1409 			switch (pri->sys_args[1]) {
1410 			case CL_NODEID:
1411 				s = "CL_NODEID";		break;
1412 			case CL_HIGHEST_NODEID:
1413 				s = "CL_HIGHEST_NODEID";	break;
1414 			}
1415 			break;
1416 		case CL_INITIALIZE:
1417 			switch (pri->sys_args[1]) {
1418 			case CL_GET_BOOTFLAG:
1419 				s = "CL_GET_BOOTFLAG";		break;
1420 			}
1421 			break;
1422 		}
1423 	}
1424 
1425 	if (s == NULL)
1426 		prt_dec(pri, 0, val);
1427 	else
1428 		outstring(pri, s);
1429 }
1430 
1431 void
1432 prt_sqc(private_t *pri, int raw, long val)	/* print sigqueue() si_code */
1433 {
1434 	const char *s = NULL;
1435 
1436 	if (!raw) {
1437 		switch ((int)val) {
1438 		case SI_QUEUE:		s = "SI_QUEUE";		break;
1439 		case SI_TIMER:		s = "SI_TIMER";		break;
1440 		case SI_ASYNCIO:	s = "SI_ASYNCIO";	break;
1441 		case SI_MESGQ:		s = "SI_MESGQ";		break;
1442 		}
1443 	}
1444 
1445 	if (s == NULL)
1446 		prt_dec(pri, 0, val);
1447 	else
1448 		outstring(pri, s);
1449 }
1450 
1451 /*
1452  * print priocntlsys() (key, value) pair key.
1453  */
1454 void
1455 print_pck(private_t *pri, int raw, long val)
1456 {
1457 	const char	*s = NULL;
1458 	char		clname[PC_CLNMSZ];
1459 
1460 	if ((pri->sys_args[2] != PC_GETXPARMS &&
1461 	    pri->sys_args[2] != PC_SETXPARMS) || val == 0 || raw) {
1462 		prt_dec(pri, 0, val);
1463 		return;
1464 	}
1465 
1466 	if (pri->sys_args[3] == NULL) {
1467 		if (val == PC_KY_CLNAME) {
1468 			s = "PC_KY_CLNAME";
1469 			outstring(pri, s);
1470 		} else
1471 			prt_dec(pri, 0, val);
1472 		return;
1473 	}
1474 
1475 	if (Pread(Proc, &clname, PC_CLNMSZ, pri->sys_args[3]) != PC_CLNMSZ) {
1476 		prt_dec(pri, 0, val);
1477 		return;
1478 	}
1479 
1480 	if (strcmp(clname, "TS") == 0) {
1481 		switch (val) {
1482 		case TS_KY_UPRILIM: 	s = "TS_KY_UPRILIM";	break;
1483 		case TS_KY_UPRI:	s = "TS_KY_UPRI";	break;
1484 		default:					break;
1485 		}
1486 	} else if (strcmp(clname, "IA") == 0) {
1487 		switch (val) {
1488 		case IA_KY_UPRILIM: 	s = "IA_KY_UPRILIM";	break;
1489 		case IA_KY_UPRI:	s = "IA_KY_UPRI";	break;
1490 		case IA_KY_MODE:	s = "IA_KY_MODE";	break;
1491 		default:					break;
1492 		}
1493 	} else if (strcmp(clname, "RT") == 0) {
1494 		switch (val) {
1495 		case RT_KY_PRI: 	s = "RT_KY_PRI";	break;
1496 		case RT_KY_TQSECS:	s = "RT_KY_TQSECS";	break;
1497 		case RT_KY_TQNSECS:	s = "RT_KY_TQNSECS";	break;
1498 		case RT_KY_TQSIG:	s = "RT_KY_TQSIG";	break;
1499 		default:					break;
1500 		}
1501 	} else if (strcmp(clname, "FSS") == 0) {
1502 		switch (val) {
1503 		case FSS_KY_UPRILIM: 	s = "FSS_KY_UPRILIM";	break;
1504 		case FSS_KY_UPRI:	s = "FSS_KY_UPRI";	break;
1505 		default:					break;
1506 		}
1507 	} else if (strcmp(clname, "FX") == 0) {
1508 		switch (val) {
1509 		case FX_KY_UPRILIM: 	s = "FX_KY_UPRILIM";	break;
1510 		case FX_KY_UPRI:	s = "FX_KY_UPRI";	break;
1511 		case FX_KY_TQSECS:	s = "FX_KY_TQSECS";	break;
1512 		case FX_KY_TQNSECS:	s = "FX_KY_TQNSECS";	break;
1513 		default:					break;
1514 		}
1515 	}
1516 
1517 	if (s == NULL)
1518 		prt_dec(pri, 0, val);
1519 	else
1520 		outstring(pri, s);
1521 }
1522 
1523 /*
1524  * print priocntlsys() fourth argument.
1525  */
1526 /*ARGSUSED*/
1527 void
1528 prt_pc4(private_t *pri, int raw, long val)
1529 {
1530 	/* look at pricntlsys function */
1531 	if ((pri->sys_args[2] != PC_GETXPARMS &&
1532 	    pri->sys_args[2] != PC_SETXPARMS))
1533 		prt_hex(pri, 0, val);
1534 	else if (val)
1535 		prt_stg(pri, 0, val);
1536 	else
1537 		prt_dec(pri, 0, val);
1538 }
1539 
1540 /*
1541  * print priocntlsys() (key, value) pairs (5th argument).
1542  */
1543 /*ARGSUSED*/
1544 void
1545 prt_pc5(private_t *pri, int raw, long val)
1546 {
1547 	pc_vaparms_t	prms;
1548 	pc_vaparm_t	*vpp = &prms.pc_parms[0];
1549 	uint_t		cnt;
1550 
1551 
1552 	/* look at pricntlsys function */
1553 	if ((pri->sys_args[2] != PC_GETXPARMS &&
1554 	    pri->sys_args[2] != PC_SETXPARMS) || val == 0) {
1555 		prt_dec(pri, 0, 0);
1556 		return;
1557 	}
1558 
1559 	if (Pread(Proc, &prms, sizeof (prms), val) != sizeof (prms)) {
1560 		prt_hex(pri, 0, val);
1561 		return;
1562 	}
1563 
1564 	if ((cnt = prms.pc_vaparmscnt) > PC_VAPARMCNT)
1565 		return;
1566 
1567 	for (; cnt--; vpp++) {
1568 		print_pck(pri, 0, vpp->pc_key);
1569 		outstring(pri, ", ");
1570 		prt_hex(pri, 0, (long)vpp->pc_parm);
1571 		outstring(pri, ", ");
1572 	}
1573 
1574 	prt_dec(pri, 0, PC_KY_NULL);
1575 }
1576 
1577 /*
1578  * Print processor set id, including logical expansion of "special" ids.
1579  */
1580 void
1581 prt_pst(private_t *pri, int raw, long val)
1582 {
1583 	const char *s = NULL;
1584 
1585 	if (!raw) {
1586 		switch ((psetid_t)val) {
1587 		case PS_NONE:		s = "PS_NONE";		break;
1588 		case PS_QUERY:		s = "PS_QUERY";		break;
1589 		case PS_MYID:		s = "PS_MYID";		break;
1590 		}
1591 	}
1592 
1593 	if (s == NULL)
1594 		prt_dec(pri, 0, val);
1595 	else
1596 		outstring(pri, s);
1597 }
1598 
1599 /*
1600  * Print meminfo() argument.
1601  */
1602 /*ARGSUSED*/
1603 void
1604 prt_mif(private_t *pri, int raw, long val)
1605 {
1606 	struct meminfo	minfo;
1607 
1608 #ifdef _LP64
1609 	if (data_model == PR_MODEL_ILP32) {
1610 		struct meminfo32 minfo32;
1611 
1612 		if (Pread(Proc, &minfo32, sizeof (struct meminfo32), val) !=
1613 			sizeof (struct meminfo32)) {
1614 			prt_dec(pri, 0, pri->sys_args[1]);	/* addr_count */
1615 			outstring(pri, ", ");
1616 			prt_hex(pri, 0, val);
1617 			return;
1618 		}
1619 		/*
1620 		 * arrange the arguments in the order that user calls with
1621 		 */
1622 		prt_hex(pri, 0, minfo32.mi_inaddr);
1623 		outstring(pri, ", ");
1624 		prt_dec(pri, 0, pri->sys_args[1]);	/* addr_count */
1625 		outstring(pri, ", ");
1626 		prt_hex(pri, 0, minfo32.mi_info_req);
1627 		outstring(pri, ", ");
1628 		prt_dec(pri, 0, minfo32.mi_info_count);
1629 		outstring(pri, ", ");
1630 		prt_hex(pri, 0, minfo32.mi_outdata);
1631 		outstring(pri, ", ");
1632 		prt_hex(pri, 0, minfo32.mi_validity);
1633 		return;
1634 	}
1635 #endif
1636 	if (Pread(Proc, &minfo, sizeof (struct meminfo), val) !=
1637 		sizeof (struct meminfo)) {
1638 		prt_dec(pri, 0, pri->sys_args[1]);	/* addr_count */
1639 		outstring(pri, ", ");
1640 		prt_hex(pri, 0, val);
1641 		return;
1642 	}
1643 	/*
1644 	 * arrange the arguments in the order that user calls with
1645 	 */
1646 	prt_hex(pri, 0, (long)minfo.mi_inaddr);
1647 	outstring(pri, ", ");
1648 	prt_dec(pri, 0, pri->sys_args[1]);	/* addr_count */
1649 	outstring(pri, ", ");
1650 	prt_hex(pri, 0, (long)minfo.mi_info_req);
1651 	outstring(pri, ", ");
1652 	prt_dec(pri, 0, minfo.mi_info_count);
1653 	outstring(pri, ", ");
1654 	prt_hex(pri, 0, (long)minfo.mi_outdata);
1655 	outstring(pri, ", ");
1656 	prt_hex(pri, 0, (long)minfo.mi_validity);
1657 }
1658 
1659 
1660 /*
1661  * Print so_socket() 1st argument.
1662  */
1663 /*ARGSUSED*/
1664 void
1665 prt_pfm(private_t *pri, int raw, long val)
1666 {
1667 	/* Protocol Families have same names as Address Families */
1668 	if ((ulong_t)val < MAX_AFCODES) {
1669 		outstring(pri, "PF_");
1670 		outstring(pri, afcodes[val]);
1671 	} else {
1672 		prt_dec(pri, 0, val);
1673 	}
1674 }
1675 
1676 
1677 /*
1678  * Print so_socket() 2nd argument.
1679  */
1680 /*ARGSUSED*/
1681 void
1682 prt_skt(private_t *pri, int raw, long val)
1683 {
1684 	const char *s;
1685 
1686 	if ((ulong_t)val <= MAX_SOCKTYPES && (s = socktype_codes[val]) != NULL)
1687 		outstring(pri, s);
1688 	else
1689 		prt_dec(pri, 0, val);
1690 }
1691 
1692 
1693 /*
1694  * Print so_socket() 3rd argument.
1695  */
1696 /*ARGSUSED*/
1697 void
1698 prt_skp(private_t *pri, int raw, long val)
1699 {
1700 	const char *s;
1701 
1702 	/* cheating -- look at the protocol-family */
1703 	switch (pri->sys_args[0]) {
1704 	case PF_INET6:
1705 	case PF_INET:
1706 	case PF_NCA:	if ((s = ipprotos((int)val)) != NULL) {
1707 				outstring(pri, s);
1708 				break;
1709 			}
1710 			/* FALLTHROUGH */
1711 	default:	prt_dec(pri, 0, val);
1712 			break;
1713 	}
1714 }
1715 
1716 
1717 /*
1718  * Print so_socket() 5th argument.
1719  */
1720 /*ARGSUSED*/
1721 void
1722 prt_skv(private_t *pri, int raw, long val)
1723 {
1724 	switch (val) {
1725 	case SOV_STREAM:	outstring(pri, "SOV_STREAM");	break;
1726 	case SOV_DEFAULT:	outstring(pri, "SOV_DEFAULT");	break;
1727 	case SOV_SOCKSTREAM:	outstring(pri, "SOV_SOCKSTREAM");	break;
1728 	case SOV_SOCKBSD:	outstring(pri, "SOV_SOCKBSD");	break;
1729 	case SOV_XPG4_2:	outstring(pri, "SOV_XPG4_2");	break;
1730 	default:		prt_dec(pri, 0, val);		break;
1731 	}
1732 }
1733 
1734 
1735 /*
1736  * Print setsockopt()/getsockopt() 2nd argument.
1737  */
1738 /*ARGSUSED*/
1739 void
1740 prt_sol(private_t *pri, int raw, long val)
1741 {
1742 	if (val == SOL_SOCKET) {
1743 		outstring(pri, "SOL_SOCKET");
1744 	} else if (val == SOL_ROUTE) {
1745 		outstring(pri, "SOL_ROUTE");
1746 	} else {
1747 		const struct protoent *p;
1748 		struct protoent res;
1749 		char buf[NSS_BUFLEN_PROTOCOLS];
1750 
1751 		if ((p = getprotobynumber_r(val, &res,
1752 		    (char *)buf, sizeof (buf))) != NULL)
1753 			outstring(pri, p->p_name);
1754 		else
1755 			prt_dec(pri, 0, val);
1756 	}
1757 }
1758 
1759 
1760 const char *
1761 sol_optname(private_t *pri, long val)
1762 {
1763 #define	CBSIZE	sizeof (pri->code_buf)
1764 	if (val >= SO_SNDBUF) {
1765 		switch (val) {
1766 		case SO_SNDBUF:		return ("SO_SNDBUF");
1767 		case SO_RCVBUF:		return ("SO_RCVBUF");
1768 		case SO_SNDLOWAT:	return ("SO_SNDLOWAT");
1769 		case SO_RCVLOWAT:	return ("SO_RCVLOWAT");
1770 		case SO_SNDTIMEO:	return ("SO_SNDTIMEO");
1771 		case SO_RCVTIMEO:	return ("SO_RCVTIMEO");
1772 		case SO_ERROR:		return ("SO_ERROR");
1773 		case SO_TYPE:		return ("SO_TYPE");
1774 		case SO_PROTOTYPE:	return ("SO_PROTOTYPE");
1775 		case SO_ALLZONES:	return ("SO_ALLZONES");
1776 		case SO_EXCLBIND:	return ("SO_EXCLBIND");
1777 		case SO_DOMAIN:		return ("SO_DOMAIN");
1778 
1779 		default:		(void) snprintf(pri->code_buf, CBSIZE,
1780 					    "0x%lx", val);
1781 					return (pri->code_buf);
1782 		}
1783 	} else {
1784 		char *s = pri->code_buf;
1785 		size_t used = 1;
1786 		long val2;
1787 
1788 		*s = '\0';
1789 		val2 = val & ~(SO_DEBUG|SO_ACCEPTCONN|SO_REUSEADDR|SO_KEEPALIVE|
1790 		    SO_DONTROUTE|SO_BROADCAST|SO_USELOOPBACK|SO_LINGER|
1791 		    SO_OOBINLINE|SO_DGRAM_ERRIND|SO_RECVUCRED);
1792 		if (val2)
1793 			used = snprintf(s, CBSIZE, "|0x%lx", val2);
1794 		if (val & SO_DEBUG)
1795 			used = strlcat(s, "|SO_DEBUG", CBSIZE);
1796 		if (val & SO_ACCEPTCONN)
1797 			used = strlcat(s, "|SO_ACCEPTCONN", CBSIZE);
1798 		if (val & SO_REUSEADDR)
1799 			used = strlcat(s, "|SO_REUSEADDR", CBSIZE);
1800 		if (val & SO_KEEPALIVE)
1801 			used = strlcat(s, "|SO_KEEPALIVE", CBSIZE);
1802 		if (val & SO_DONTROUTE)
1803 			used = strlcat(s, "|SO_DONTROUTE", CBSIZE);
1804 		if (val & SO_BROADCAST)
1805 			used = strlcat(s, "|SO_BROADCAST", CBSIZE);
1806 		if (val & SO_USELOOPBACK)
1807 			used = strlcat(s, "|SO_USELOOPBACK", CBSIZE);
1808 		if (val & SO_LINGER)
1809 			used = strlcat(s, "|SO_LINGER", CBSIZE);
1810 		if (val & SO_OOBINLINE)
1811 			used = strlcat(s, "|SO_OOBINLINE", CBSIZE);
1812 		if (val & SO_DGRAM_ERRIND)
1813 			used = strlcat(s, "|SO_DGRAM_ERRIND", CBSIZE);
1814 		if (val & SO_RECVUCRED)
1815 			used = strlcat(s, "|SO_RECVUCRED", CBSIZE);
1816 		if (used >= CBSIZE || val == 0)
1817 			(void) snprintf(s + 1, CBSIZE-1, "0x%lx", val);
1818 		return ((const char *)(s + 1));
1819 	}
1820 #undef CBSIZE
1821 }
1822 
1823 const char *
1824 route_optname(private_t *pri, long val)
1825 {
1826 	switch (val) {
1827 	case RT_AWARE:
1828 		return ("RT_AWARE");
1829 	default:
1830 		(void) snprintf(pri->code_buf, sizeof (pri->code_buf),
1831 		    "0x%lx", val);
1832 		return (pri->code_buf);
1833 	}
1834 }
1835 
1836 const char *
1837 tcp_optname(private_t *pri, long val)
1838 {
1839 	switch (val) {
1840 	case TCP_NODELAY:		return ("TCP_NODELAY");
1841 	case TCP_MAXSEG:		return ("TCP_MAXSEG");
1842 	case TCP_KEEPALIVE:		return ("TCP_KEEPALIVE");
1843 	case TCP_NOTIFY_THRESHOLD:	return ("TCP_NOTIFY_THRESHOLD");
1844 	case TCP_ABORT_THRESHOLD:	return ("TCP_ABORT_THRESHOLD");
1845 	case TCP_CONN_NOTIFY_THRESHOLD:	return ("TCP_CONN_NOTIFY_THRESHOLD");
1846 	case TCP_CONN_ABORT_THRESHOLD:	return ("TCP_CONN_ABORT_THRESHOLD");
1847 	case TCP_RECVDSTADDR:		return ("TCP_RECVDSTADDR");
1848 	case TCP_ANONPRIVBIND:		return ("TCP_ANONPRIVBIND");
1849 	case TCP_EXCLBIND:		return ("TCP_EXCLBIND");
1850 	case TCP_INIT_CWND:		return ("TCP_INIT_CWND");
1851 	case TCP_KEEPALIVE_THRESHOLD:	return ("TCP_KEEPALIVE_THRESHOLD");
1852 	case TCP_KEEPALIVE_ABORT_THRESHOLD:
1853 		return ("TCP_KEEPALIVE_ABORT_THRESHOLD");
1854 	case TCP_CORK:			return ("TCP_CORK");
1855 
1856 	default:			(void) snprintf(pri->code_buf,
1857 					    sizeof (pri->code_buf),
1858 					    "0x%lx", val);
1859 					return (pri->code_buf);
1860 	}
1861 }
1862 
1863 
1864 const char *
1865 sctp_optname(private_t *pri, long val)
1866 {
1867 	switch (val) {
1868 	case SCTP_RTOINFO:		return ("SCTP_RTOINFO");
1869 	case SCTP_ASSOCINFO:		return ("SCTP_ASSOCINFO");
1870 	case SCTP_INITMSG:		return ("SCTP_INITMSG");
1871 	case SCTP_NODELAY:		return ("SCTP_NODELAY");
1872 	case SCTP_AUTOCLOSE:		return ("SCTP_AUTOCLOSE");
1873 	case SCTP_SET_PEER_PRIMARY_ADDR:
1874 		return ("SCTP_SET_PEER_PRIMARY_ADDR");
1875 	case SCTP_PRIMARY_ADDR:		return ("SCTP_PRIMARY_ADDR");
1876 	case SCTP_ADAPTATION_LAYER:	return ("SCTP_ADAPTATION_LAYER");
1877 	case SCTP_DISABLE_FRAGMENTS:	return ("SCTP_DISABLE_FRAGMENTS");
1878 	case SCTP_PEER_ADDR_PARAMS:	return ("SCTP_PEER_ADDR_PARAMS");
1879 	case SCTP_DEFAULT_SEND_PARAM:	return ("SCTP_DEFAULT_SEND_PARAM");
1880 	case SCTP_EVENTS:		return ("SCTP_EVENTS");
1881 	case SCTP_I_WANT_MAPPED_V4_ADDR:
1882 		return ("SCTP_I_WANT_MAPPED_V4_ADDR");
1883 	case SCTP_MAXSEG:		return ("SCTP_MAXSEG");
1884 	case SCTP_STATUS:		return ("SCTP_STATUS");
1885 	case SCTP_GET_PEER_ADDR_INFO:	return ("SCTP_GET_PEER_ADDR_INFO");
1886 
1887 	case SCTP_ADD_ADDR:		return ("SCTP_ADD_ADDR");
1888 	case SCTP_REM_ADDR:		return ("SCTP_REM_ADDR");
1889 
1890 	default:			(void) snprintf(pri->code_buf,
1891 					    sizeof (pri->code_buf),
1892 					    "0x%lx", val);
1893 					return (pri->code_buf);
1894 	}
1895 }
1896 
1897 
1898 const char *
1899 udp_optname(private_t *pri, long val)
1900 {
1901 	switch (val) {
1902 	case UDP_CHECKSUM:		return ("UDP_CHECKSUM");
1903 	case UDP_ANONPRIVBIND:		return ("UDP_ANONPRIVBIND");
1904 	case UDP_EXCLBIND:		return ("UDP_EXCLBIND");
1905 	case UDP_RCVHDR:		return ("UDP_RCVHDR");
1906 	case UDP_NAT_T_ENDPOINT:	return ("UDP_NAT_T_ENDPOINT");
1907 
1908 	default:			(void) snprintf(pri->code_buf,
1909 					    sizeof (pri->code_buf), "0x%lx",
1910 					    val);
1911 					return (pri->code_buf);
1912 	}
1913 }
1914 
1915 
1916 /*
1917  * Print setsockopt()/getsockopt() 3rd argument.
1918  */
1919 /*ARGSUSED*/
1920 void
1921 prt_son(private_t *pri, int raw, long val)
1922 {
1923 	/* cheating -- look at the level */
1924 	switch (pri->sys_args[1]) {
1925 	case SOL_SOCKET:	outstring(pri, sol_optname(pri, val));
1926 				break;
1927 	case SOL_ROUTE:		outstring(pri, route_optname(pri, val));
1928 				break;
1929 	case IPPROTO_TCP:	outstring(pri, tcp_optname(pri, val));
1930 				break;
1931 	case IPPROTO_UDP:	outstring(pri, udp_optname(pri, val));
1932 				break;
1933 	case IPPROTO_SCTP:	outstring(pri, sctp_optname(pri, val));
1934 				break;
1935 	default:		prt_dec(pri, 0, val);
1936 				break;
1937 	}
1938 }
1939 
1940 
1941 /*
1942  * Print utrap type
1943  */
1944 /*ARGSUSED*/
1945 void
1946 prt_utt(private_t *pri, int raw, long val)
1947 {
1948 	const char *s = NULL;
1949 
1950 #ifdef __sparc
1951 	if (!raw) {
1952 		switch (val) {
1953 		case UT_INSTRUCTION_DISABLED:
1954 			s = "UT_INSTRUCTION_DISABLED"; break;
1955 		case UT_INSTRUCTION_ERROR:
1956 			s = "UT_INSTRUCTION_ERROR"; break;
1957 		case UT_INSTRUCTION_PROTECTION:
1958 			s = "UT_INSTRUCTION_PROTECTION"; break;
1959 		case UT_ILLTRAP_INSTRUCTION:
1960 			s = "UT_ILLTRAP_INSTRUCTION"; break;
1961 		case UT_ILLEGAL_INSTRUCTION:
1962 			s = "UT_ILLEGAL_INSTRUCTION"; break;
1963 		case UT_PRIVILEGED_OPCODE:
1964 			s = "UT_PRIVILEGED_OPCODE"; break;
1965 		case UT_FP_DISABLED:
1966 			s = "UT_FP_DISABLED"; break;
1967 		case UT_FP_EXCEPTION_IEEE_754:
1968 			s = "UT_FP_EXCEPTION_IEEE_754"; break;
1969 		case UT_FP_EXCEPTION_OTHER:
1970 			s = "UT_FP_EXCEPTION_OTHER"; break;
1971 		case UT_TAG_OVERFLOW:
1972 			s = "UT_TAG_OVERFLOW"; break;
1973 		case UT_DIVISION_BY_ZERO:
1974 			s = "UT_DIVISION_BY_ZERO"; break;
1975 		case UT_DATA_EXCEPTION:
1976 			s = "UT_DATA_EXCEPTION"; break;
1977 		case UT_DATA_ERROR:
1978 			s = "UT_DATA_ERROR"; break;
1979 		case UT_DATA_PROTECTION:
1980 			s = "UT_DATA_PROTECTION"; break;
1981 		case UT_MEM_ADDRESS_NOT_ALIGNED:
1982 			s = "UT_MEM_ADDRESS_NOT_ALIGNED"; break;
1983 		case UT_PRIVILEGED_ACTION:
1984 			s = "UT_PRIVILEGED_ACTION"; break;
1985 		case UT_ASYNC_DATA_ERROR:
1986 			s = "UT_ASYNC_DATA_ERROR"; break;
1987 		case UT_TRAP_INSTRUCTION_16:
1988 			s = "UT_TRAP_INSTRUCTION_16"; break;
1989 		case UT_TRAP_INSTRUCTION_17:
1990 			s = "UT_TRAP_INSTRUCTION_17"; break;
1991 		case UT_TRAP_INSTRUCTION_18:
1992 			s = "UT_TRAP_INSTRUCTION_18"; break;
1993 		case UT_TRAP_INSTRUCTION_19:
1994 			s = "UT_TRAP_INSTRUCTION_19"; break;
1995 		case UT_TRAP_INSTRUCTION_20:
1996 			s = "UT_TRAP_INSTRUCTION_20"; break;
1997 		case UT_TRAP_INSTRUCTION_21:
1998 			s = "UT_TRAP_INSTRUCTION_21"; break;
1999 		case UT_TRAP_INSTRUCTION_22:
2000 			s = "UT_TRAP_INSTRUCTION_22"; break;
2001 		case UT_TRAP_INSTRUCTION_23:
2002 			s = "UT_TRAP_INSTRUCTION_23"; break;
2003 		case UT_TRAP_INSTRUCTION_24:
2004 			s = "UT_TRAP_INSTRUCTION_24"; break;
2005 		case UT_TRAP_INSTRUCTION_25:
2006 			s = "UT_TRAP_INSTRUCTION_25"; break;
2007 		case UT_TRAP_INSTRUCTION_26:
2008 			s = "UT_TRAP_INSTRUCTION_26"; break;
2009 		case UT_TRAP_INSTRUCTION_27:
2010 			s = "UT_TRAP_INSTRUCTION_27"; break;
2011 		case UT_TRAP_INSTRUCTION_28:
2012 			s = "UT_TRAP_INSTRUCTION_28"; break;
2013 		case UT_TRAP_INSTRUCTION_29:
2014 			s = "UT_TRAP_INSTRUCTION_29"; break;
2015 		case UT_TRAP_INSTRUCTION_30:
2016 			s = "UT_TRAP_INSTRUCTION_30"; break;
2017 		case UT_TRAP_INSTRUCTION_31:
2018 			s = "UT_TRAP_INSTRUCTION_31"; break;
2019 		}
2020 	}
2021 #endif /* __sparc */
2022 
2023 	if (s == NULL)
2024 		prt_dec(pri, 0, val);
2025 	else
2026 		outstring(pri, s);
2027 }
2028 
2029 
2030 /*
2031  * Print utrap handler
2032  */
2033 void
2034 prt_uth(private_t *pri, int raw, long val)
2035 {
2036 	const char *s = NULL;
2037 
2038 	if (!raw) {
2039 		switch (val) {
2040 		case (long)UTH_NOCHANGE:	s = "UTH_NOCHANGE"; break;
2041 		}
2042 	}
2043 
2044 	if (s == NULL)
2045 		prt_hex(pri, 0, val);
2046 	else
2047 		outstring(pri, s);
2048 }
2049 
2050 const char *
2051 access_flags(private_t *pri, long arg)
2052 {
2053 #define	E_OK 010
2054 	char *str = pri->code_buf;
2055 
2056 	if (arg & ~(R_OK|W_OK|X_OK|E_OK))
2057 		return (NULL);
2058 
2059 	/* NB: F_OK == 0 */
2060 	if (arg == F_OK)
2061 		return ("F_OK");
2062 	if (arg == E_OK)
2063 		return ("F_OK|E_OK");
2064 
2065 	*str = '\0';
2066 	if (arg & R_OK)
2067 		(void) strlcat(str, "|R_OK", sizeof (pri->code_buf));
2068 	if (arg & W_OK)
2069 		(void) strlcat(str, "|W_OK", sizeof (pri->code_buf));
2070 	if (arg & X_OK)
2071 		(void) strlcat(str, "|X_OK", sizeof (pri->code_buf));
2072 	if (arg & E_OK)
2073 		(void) strlcat(str, "|E_OK", sizeof (pri->code_buf));
2074 	return ((const char *)(str + 1));
2075 #undef E_OK
2076 }
2077 
2078 /*
2079  * Print access() flags.
2080  */
2081 void
2082 prt_acc(private_t *pri, int raw, long val)
2083 {
2084 	const char *s = raw? NULL : access_flags(pri, val);
2085 
2086 	if (s == NULL)
2087 		prt_dex(pri, 0, val);
2088 	else
2089 		outstring(pri, s);
2090 }
2091 
2092 /*
2093  * Print shutdown() "how" (2nd) argument
2094  */
2095 void
2096 prt_sht(private_t *pri, int raw, long val)
2097 {
2098 	if (raw) {
2099 		prt_dex(pri, 0, val);
2100 		return;
2101 	}
2102 	switch (val) {
2103 	case SHUT_RD:	outstring(pri, "SHUT_RD");	break;
2104 	case SHUT_WR:	outstring(pri, "SHUT_WR");	break;
2105 	case SHUT_RDWR:	outstring(pri, "SHUT_RDWR");	break;
2106 	default:	prt_dec(pri, 0, val);		break;
2107 	}
2108 }
2109 
2110 /*
2111  * Print fcntl() F_SETFL flags (3rd) argument or fdsync flag (2nd arg)
2112  */
2113 static struct fcntl_flags {
2114 	long		val;
2115 	const char	*name;
2116 } fcntl_flags[] = {
2117 #define	FC_FL(flag)	{ (long)flag, "|" # flag }
2118 	FC_FL(FREVOKED),
2119 	FC_FL(FREAD),
2120 	FC_FL(FWRITE),
2121 	FC_FL(FNDELAY),
2122 	FC_FL(FAPPEND),
2123 	FC_FL(FSYNC),
2124 	FC_FL(FDSYNC),
2125 	FC_FL(FRSYNC),
2126 	FC_FL(FOFFMAX),
2127 	FC_FL(FNONBLOCK),
2128 	FC_FL(FCREAT),
2129 	FC_FL(FTRUNC),
2130 	FC_FL(FEXCL),
2131 	FC_FL(FNOCTTY),
2132 	FC_FL(FXATTR),
2133 	FC_FL(FASYNC),
2134 	FC_FL(FNODSYNC)
2135 #undef FC_FL
2136 };
2137 
2138 void
2139 prt_ffg(private_t *pri, int raw, long val)
2140 {
2141 #define	CBSIZE	sizeof (pri->code_buf)
2142 	char *s = pri->code_buf;
2143 	size_t used = 1;
2144 	struct fcntl_flags *fp;
2145 
2146 	if (raw) {
2147 		(void) snprintf(s, CBSIZE, "0x%lx", val);
2148 		outstring(pri, s);
2149 		return;
2150 	}
2151 	if (val == 0) {
2152 		outstring(pri, "(no flags)");
2153 		return;
2154 	}
2155 
2156 	*s = '\0';
2157 	for (fp = fcntl_flags;
2158 	    fp < &fcntl_flags[sizeof (fcntl_flags) / sizeof (*fp)]; fp++) {
2159 		if (val & fp->val) {
2160 			used = strlcat(s, fp->name, CBSIZE);
2161 			val &= ~fp->val;
2162 		}
2163 	}
2164 
2165 	if (val != 0 && used <= CBSIZE)
2166 		used += snprintf(s + used, CBSIZE - used, "|0x%lx", val);
2167 
2168 	if (used >= CBSIZE)
2169 		(void) snprintf(s + 1, CBSIZE-1, "0x%lx", val);
2170 	outstring(pri, s + 1);
2171 #undef CBSIZE
2172 }
2173 
2174 void
2175 prt_prs(private_t *pri, int raw, long val)
2176 {
2177 	static size_t setsize;
2178 	priv_set_t *set = priv_allocset();
2179 
2180 	if (setsize == 0) {
2181 		const priv_impl_info_t *info = getprivimplinfo();
2182 		if (info != NULL)
2183 			setsize = info->priv_setsize * sizeof (priv_chunk_t);
2184 	}
2185 
2186 	if (setsize != 0 && !raw && set != NULL &&
2187 	    Pread(Proc, set, setsize, val) == setsize) {
2188 		int i;
2189 
2190 		outstring(pri, "{");
2191 		for (i = 0; i < setsize / sizeof (priv_chunk_t); i++) {
2192 			char buf[9];	/* 8 hex digits + '\0' */
2193 			(void) snprintf(buf, sizeof (buf), "%08x",
2194 			    ((priv_chunk_t *)set)[i]);
2195 			outstring(pri, buf);
2196 		}
2197 
2198 		outstring(pri, "}");
2199 	} else {
2200 		prt_hex(pri, 0, val);
2201 	}
2202 
2203 	if (set != NULL)
2204 		priv_freeset(set);
2205 }
2206 
2207 /*
2208  * Print privilege set operation.
2209  */
2210 void
2211 prt_pro(private_t *pri, int raw, long val)
2212 {
2213 	const char *s = NULL;
2214 
2215 	if (!raw) {
2216 		switch ((priv_op_t)val) {
2217 		case PRIV_ON:		s = "PRIV_ON";		break;
2218 		case PRIV_OFF:		s = "PRIV_OFF";		break;
2219 		case PRIV_SET:		s = "PRIV_SET";		break;
2220 		}
2221 	}
2222 
2223 	if (s == NULL)
2224 		prt_dec(pri, 0, val);
2225 	else
2226 		outstring(pri, s);
2227 }
2228 
2229 /*
2230  * Print privilege set name
2231  */
2232 void
2233 prt_prn(private_t *pri, int raw, long val)
2234 {
2235 	const char *s = NULL;
2236 
2237 	if (!raw)
2238 		s = priv_getsetbynum((int)val);
2239 
2240 	if (s == NULL)
2241 		prt_dec(pri, 0, val);
2242 	else {
2243 		char *dup = strdup(s);
2244 		char *q;
2245 
2246 		/* Do the best we can in this case */
2247 		if (dup == NULL) {
2248 			outstring(pri, s);
2249 			return;
2250 		}
2251 
2252 		outstring(pri, "PRIV_");
2253 
2254 		q = dup;
2255 
2256 		while (*q != '\0') {
2257 			*q = toupper(*q);
2258 			q++;
2259 		}
2260 		outstring(pri, dup);
2261 		free(dup);
2262 	}
2263 }
2264 
2265 /*
2266  * Print process flag names.
2267  */
2268 void
2269 prt_pfl(private_t *pri, int raw, long val)
2270 {
2271 	const char *s = NULL;
2272 
2273 	if (!raw) {
2274 		switch ((int)val) {
2275 		case PRIV_DEBUG:	s = "PRIV_DEBUG";	break;
2276 		case PRIV_AWARE:	s = "PRIV_AWARE";	break;
2277 		case PRIV_XPOLICY:	s = "PRIV_XPOLICY";	break;
2278 		case PRIV_AWARE_RESET:  s = "PRIV_AWARE_RESET"; break;
2279 		case NET_MAC_AWARE:	s =  "NET_MAC_AWARE";	break;
2280 		case NET_MAC_AWARE_INHERIT:
2281 			s = "NET_MAC_AWARE_INHERIT";
2282 			break;
2283 		}
2284 	}
2285 
2286 	if (s == NULL)
2287 		prt_dec(pri, 0, val);
2288 	else
2289 		outstring(pri, s);
2290 }
2291 
2292 /*
2293  * Print lgrp_affinity_{get,set}() arguments.
2294  */
2295 /*ARGSUSED*/
2296 void
2297 prt_laf(private_t *pri, int raw, long val)
2298 {
2299 	lgrp_affinity_args_t	laff;
2300 
2301 	if (Pread(Proc, &laff, sizeof (lgrp_affinity_args_t), val) !=
2302 	    sizeof (lgrp_affinity_args_t)) {
2303 		prt_hex(pri, 0, val);
2304 		return;
2305 	}
2306 	/*
2307 	 * arrange the arguments in the order that user calls with
2308 	 */
2309 	prt_dec(pri, 0, laff.idtype);
2310 	outstring(pri, ", ");
2311 	prt_dec(pri, 0, laff.id);
2312 	outstring(pri, ", ");
2313 	prt_dec(pri, 0, laff.lgrp);
2314 	outstring(pri, ", ");
2315 	if (pri->sys_args[0] == LGRP_SYS_AFFINITY_SET)
2316 		prt_dec(pri, 0, laff.aff);
2317 }
2318 
2319 /*
2320  * Print a key_t as IPC_PRIVATE if it is 0.
2321  */
2322 void
2323 prt_key(private_t *pri, int raw, long val)
2324 {
2325 	if (!raw && val == 0)
2326 		outstring(pri, "IPC_PRIVATE");
2327 	else
2328 		prt_dec(pri, 0, val);
2329 }
2330 
2331 
2332 /*
2333  * Print zone_getattr() attribute types.
2334  */
2335 void
2336 prt_zga(private_t *pri, int raw, long val)
2337 {
2338 	const char *s = NULL;
2339 
2340 	if (!raw) {
2341 		switch ((int)val) {
2342 		case ZONE_ATTR_NAME:	s = "ZONE_ATTR_NAME";	break;
2343 		case ZONE_ATTR_ROOT:	s = "ZONE_ATTR_ROOT";	break;
2344 		case ZONE_ATTR_STATUS:	s = "ZONE_ATTR_STATUS";	break;
2345 		case ZONE_ATTR_PRIVSET:	s = "ZONE_ATTR_PRIVSET"; break;
2346 		case ZONE_ATTR_UNIQID:	s = "ZONE_ATTR_UNIQID"; break;
2347 		case ZONE_ATTR_POOLID:	s = "ZONE_ATTR_POOLID"; break;
2348 		case ZONE_ATTR_INITPID:	s = "ZONE_ATTR_INITPID"; break;
2349 		case ZONE_ATTR_SLBL:	s = "ZONE_ATTR_SLBL"; break;
2350 		case ZONE_ATTR_INITNAME:	s = "ZONE_ATTR_INITNAME"; break;
2351 		case ZONE_ATTR_BOOTARGS:	s = "ZONE_ATTR_BOOTARGS"; break;
2352 		case ZONE_ATTR_BRAND:	s = "ZONE_ATTR_BRAND"; break;
2353 		case ZONE_ATTR_FLAGS:	s = "ZONE_ATTR_FLAGS"; break;
2354 		case ZONE_ATTR_PHYS_MCAP: s = "ZONE_ATTR_PHYS_MCAP"; break;
2355 		}
2356 	}
2357 
2358 	if (s == NULL)
2359 		prt_dec(pri, 0, val);
2360 	else
2361 		outstring(pri, s);
2362 }
2363 
2364 /*
2365  * Print a file descriptor as AT_FDCWD if necessary
2366  */
2367 void
2368 prt_atc(private_t *pri, int raw, long val)
2369 {
2370 	if (!raw && val == AT_FDCWD)
2371 		outstring(pri, "AT_FDCWD");
2372 	else
2373 		prt_dec(pri, 0, val);
2374 }
2375 
2376 /*
2377  * Print Trusted Networking database operation codes (labelsys; tn*)
2378  */
2379 static void
2380 prt_tnd(private_t *pri, int raw, long val)
2381 {
2382 	const char *s = NULL;
2383 
2384 	if (!raw) {
2385 		switch ((tsol_dbops_t)val) {
2386 		case TNDB_NOOP:		s = "TNDB_NOOP";	break;
2387 		case TNDB_LOAD:		s = "TNDB_LOAD";	break;
2388 		case TNDB_DELETE:	s = "TNDB_DELETE";	break;
2389 		case TNDB_FLUSH:	s = "TNDB_FLUSH";	break;
2390 		case TNDB_GET:		s = "TNDB_GET";		break;
2391 		}
2392 	}
2393 
2394 	if (s == NULL)
2395 		prt_dec(pri, 0, val);
2396 	else
2397 		outstring(pri, s);
2398 }
2399 
2400 /*
2401  * Print LIO_XX flags
2402  */
2403 void
2404 prt_lio(private_t *pri, int raw, long val)
2405 {
2406 	if (raw)
2407 		prt_dec(pri, 0, val);
2408 	else if (val == LIO_WAIT)
2409 		outstring(pri, "LIO_WAIT");
2410 	else if (val == LIO_NOWAIT)
2411 		outstring(pri, "LIO_NOWAIT");
2412 	else
2413 		prt_dec(pri, 0, val);
2414 }
2415 
2416 const char *
2417 door_flags(private_t *pri, long val)
2418 {
2419 	door_attr_t attr = (door_attr_t)val;
2420 	char *str = pri->code_buf;
2421 
2422 	*str = '\0';
2423 #define	PROCESS_FLAG(flg)						\
2424 	if (attr & flg) {						\
2425 		(void) strlcat(str, "|" #flg, sizeof (pri->code_buf));	\
2426 		attr &= ~flg;						\
2427 	}
2428 
2429 	PROCESS_FLAG(DOOR_UNREF);
2430 	PROCESS_FLAG(DOOR_UNREF_MULTI);
2431 	PROCESS_FLAG(DOOR_PRIVATE);
2432 	PROCESS_FLAG(DOOR_REFUSE_DESC);
2433 	PROCESS_FLAG(DOOR_NO_CANCEL);
2434 	PROCESS_FLAG(DOOR_LOCAL);
2435 	PROCESS_FLAG(DOOR_REVOKED);
2436 	PROCESS_FLAG(DOOR_IS_UNREF);
2437 #undef PROCESS_FLAG
2438 
2439 	if (attr != 0 || *str == '\0') {
2440 		size_t len = strlen(str);
2441 		(void) snprintf(str + len, sizeof (pri->code_buf) - len,
2442 		    "|0x%X", attr);
2443 	}
2444 
2445 	return (str + 1);
2446 }
2447 
2448 /*
2449  * Print door_create() flags
2450  */
2451 void
2452 prt_dfl(private_t *pri, int raw, long val)
2453 {
2454 	if (raw)
2455 		prt_hex(pri, 0, val);
2456 	else
2457 		outstring(pri, door_flags(pri, val));
2458 }
2459 
2460 /*
2461  * Print door_*param() param argument
2462  */
2463 void
2464 prt_dpm(private_t *pri, int raw, long val)
2465 {
2466 	if (raw)
2467 		prt_hex(pri, 0, val);
2468 	else if (val == DOOR_PARAM_DESC_MAX)
2469 		outstring(pri, "DOOR_PARAM_DESC_MAX");
2470 	else if (val == DOOR_PARAM_DATA_MIN)
2471 		outstring(pri, "DOOR_PARAM_DATA_MIN");
2472 	else if (val == DOOR_PARAM_DATA_MAX)
2473 		outstring(pri, "DOOR_PARAM_DATA_MAX");
2474 	else
2475 		prt_hex(pri, 0, val);
2476 }
2477 
2478 /*
2479  * Print rctlsys subcodes
2480  */
2481 void
2482 prt_rsc(private_t *pri, int raw, long val)	/* print utssys code */
2483 {
2484 	const char *s = raw? NULL : rctlsyscode(val);
2485 
2486 	if (s == NULL)
2487 		prt_dec(pri, 0, val);
2488 	else
2489 		outstring(pri, s);
2490 }
2491 
2492 /*
2493  * Print getrctl flags
2494  */
2495 void
2496 prt_rgf(private_t *pri, int raw, long val)
2497 {
2498 	long action = val & (~RCTLSYS_ACTION_MASK);
2499 
2500 	if (raw)
2501 		prt_hex(pri, 0, val);
2502 	else if (action == RCTL_FIRST)
2503 		outstring(pri, "RCTL_FIRST");
2504 	else if (action == RCTL_NEXT)
2505 		outstring(pri, "RCTL_NEXT");
2506 	else if (action == RCTL_USAGE)
2507 		outstring(pri, "RCTL_USAGE");
2508 	else
2509 		prt_hex(pri, 0, val);
2510 }
2511 
2512 /*
2513  * Print setrctl flags
2514  */
2515 void
2516 prt_rsf(private_t *pri, int raw, long val)
2517 {
2518 	long action = val & (~RCTLSYS_ACTION_MASK);
2519 	long pval = val & RCTL_LOCAL_ACTION_MASK;
2520 	char *s = pri->code_buf;
2521 
2522 	if (raw) {
2523 		prt_hex(pri, 0, val);
2524 		return;
2525 	} else if (action == RCTL_INSERT)
2526 		(void) strcpy(s, "RCTL_INSERT");
2527 	else if (action == RCTL_DELETE)
2528 		(void) strcpy(s, "RCTL_DELETE");
2529 	else if (action == RCTL_REPLACE)
2530 		(void) strcpy(s, "RCTL_REPLACE");
2531 	else {
2532 		prt_hex(pri, 0, val);
2533 		return;
2534 	}
2535 
2536 	if (pval & RCTL_USE_RECIPIENT_PID) {
2537 		pval ^= RCTL_USE_RECIPIENT_PID;
2538 		(void) strlcat(s, "|RCTL_USE_RECIPIENT_PID",
2539 		    sizeof (pri->code_buf));
2540 	}
2541 
2542 	if ((pval & RCTLSYS_ACTION_MASK) != 0)
2543 		prt_hex(pri, 0, val);
2544 	else if (*s != '\0')
2545 		outstring(pri, s);
2546 	else
2547 		prt_hex(pri, 0, val);
2548 }
2549 
2550 /*
2551  * Print rctlctl flags
2552  */
2553 void
2554 prt_rcf(private_t *pri, int raw, long val)
2555 {
2556 	long action = val & (~RCTLSYS_ACTION_MASK);
2557 
2558 	if (raw)
2559 		prt_hex(pri, 0, val);
2560 	else if (action == RCTLCTL_GET)
2561 		outstring(pri, "RCTLCTL_GET");
2562 	else if (action == RCTLCTL_SET)
2563 		outstring(pri, "RCTLCTL_SET");
2564 	else
2565 		prt_hex(pri, 0, val);
2566 }
2567 
2568 /*
2569  * Print setprojrctl flags
2570  */
2571 void
2572 prt_spf(private_t *pri, int raw, long val)
2573 {
2574 	long action = val & TASK_PROJ_MASK;
2575 
2576 	if (!raw && (action == TASK_PROJ_PURGE))
2577 		outstring(pri, "TASK_PROJ_PURGE");
2578 	else
2579 		prt_hex(pri, 0, val);
2580 }
2581 
2582 /*
2583  * Print forkx() flags
2584  */
2585 void
2586 prt_fxf(private_t *pri, int raw, long val)
2587 {
2588 	char *str;
2589 
2590 	if (val == 0)
2591 		outstring(pri, "0");
2592 	else if (raw || (val & ~(FORK_NOSIGCHLD | FORK_WAITPID)))
2593 		prt_hhx(pri, 0, val);
2594 	else {
2595 		str = pri->code_buf;
2596 		*str = '\0';
2597 		if (val & FORK_NOSIGCHLD)
2598 			(void) strlcat(str, "|FORK_NOSIGCHLD",
2599 			    sizeof (pri->code_buf));
2600 		if (val & FORK_WAITPID)
2601 			(void) strlcat(str, "|FORK_WAITPID",
2602 			    sizeof (pri->code_buf));
2603 		outstring(pri, str + 1);
2604 	}
2605 }
2606 
2607 /*
2608  * Array of pointers to print functions, one for each format.
2609  */
2610 void (* const Print[])() = {
2611 	prt_nov,	/* NOV -- no value */
2612 	prt_dec,	/* DEC -- print value in decimal */
2613 	prt_oct,	/* OCT -- print value in octal */
2614 	prt_hex,	/* HEX -- print value in hexadecimal */
2615 	prt_dex,	/* DEX -- print value in hexadecimal if big enough */
2616 	prt_stg,	/* STG -- print value as string */
2617 	prt_ioc,	/* IOC -- print ioctl code */
2618 	prt_fcn,	/* FCN -- print fcntl code */
2619 	prt_s86,	/* S86 -- print sysi86 code */
2620 	prt_uts,	/* UTS -- print utssys code */
2621 	prt_opn,	/* OPN -- print open code */
2622 	prt_sig,	/* SIG -- print signal name plus flags */
2623 	prt_act,	/* ACT -- print signal action value */
2624 	prt_msc,	/* MSC -- print msgsys command */
2625 	prt_msf,	/* MSF -- print msgsys flags */
2626 	prt_smc,	/* SMC -- print semsys command */
2627 	prt_sef,	/* SEF -- print semsys flags */
2628 	prt_shc,	/* SHC -- print shmsys command */
2629 	prt_shf,	/* SHF -- print shmsys flags */
2630 	prt_plk,	/* PLK -- print plock code */
2631 	prt_sfs,	/* SFS -- print sysfs code */
2632 	prt_rst,	/* RST -- print string returned by syscall */
2633 	prt_smf,	/* SMF -- print streams message flags */
2634 	prt_ioa,	/* IOA -- print ioctl argument */
2635 	prt_six,	/* SIX -- print signal, masked with SIGNO_MASK */
2636 	prt_mtf,	/* MTF -- print mount flags */
2637 	prt_mft,	/* MFT -- print mount file system type */
2638 	prt_iob,	/* IOB -- print contents of I/O buffer */
2639 	prt_hhx,	/* HHX -- print value in hexadecimal (half size) */
2640 	prt_wop,	/* WOP -- print waitsys() options */
2641 	prt_spm,	/* SPM -- print sigprocmask argument */
2642 	prt_rlk,	/* RLK -- print readlink buffer */
2643 	prt_mpr,	/* MPR -- print mmap()/mprotect() flags */
2644 	prt_mty,	/* MTY -- print mmap() mapping type flags */
2645 	prt_mcf,	/* MCF -- print memcntl() function */
2646 	prt_mc4,	/* MC4 -- print memcntl() (fourth) argument */
2647 	prt_mc5,	/* MC5 -- print memcntl() (fifth) argument */
2648 	prt_mad,	/* MAD -- print madvise() argument */
2649 	prt_ulm,	/* ULM -- print ulimit() argument */
2650 	prt_rlm,	/* RLM -- print get/setrlimit() argument */
2651 	prt_cnf,	/* CNF -- print sysconfig() argument */
2652 	prt_inf,	/* INF -- print sysinfo() argument */
2653 	prt_ptc,	/* PTC -- print pathconf/fpathconf() argument */
2654 	prt_fui,	/* FUI -- print fusers() input argument */
2655 	prt_idt,	/* IDT -- print idtype_t, waitid() argument */
2656 	prt_lwf,	/* LWF -- print lwp_create() flags */
2657 	prt_itm,	/* ITM -- print [get|set]itimer() arg */
2658 	prt_llo,	/* LLO -- print long long offset arg */
2659 	prt_mod,	/* MOD -- print modctl() subcode */
2660 	prt_whn,	/* WHN -- print lseek() whence arguiment */
2661 	prt_acl,	/* ACL -- print acl() code */
2662 	prt_aio,	/* AIO -- print kaio() code */
2663 	prt_aud,	/* AUD -- print auditsys() code */
2664 	prt_uns,	/* DEC -- print value in unsigned decimal */
2665 	prt_clc,	/* CLC -- print cladm command argument */
2666 	prt_clf,	/* CLF -- print cladm flag argument */
2667 	prt_cor,	/* COR -- print corectl() subcode */
2668 	prt_cco,	/* CCO -- print corectl() options */
2669 	prt_ccc,	/* CCC -- print corectl() content */
2670 	prt_rcc,	/* RCC -- print corectl() returned content */
2671 	prt_cpc,	/* CPC -- print cpc() subcode */
2672 	prt_sqc,	/* SQC -- print sigqueue() si_code argument */
2673 	prt_pc4,	/* PC4 -- print priocntlsys() (fourth) argument */
2674 	prt_pc5,	/* PC5 -- print priocntlsys() (key, value) pairs */
2675 	prt_pst,	/* PST -- print processor set id */
2676 	prt_mif,	/* MIF -- print meminfo() arguments */
2677 	prt_pfm,	/* PFM -- print so_socket() proto-family (1st) arg */
2678 	prt_skt,	/* SKT -- print so_socket() socket-type (2nd) arg */
2679 	prt_skp,	/* SKP -- print so_socket() protocol (3rd) arg */
2680 	prt_skv,	/* SKV -- print socket version arg */
2681 	prt_sol,	/* SOL -- print [sg]etsockopt() level (2nd) arg */
2682 	prt_son,	/* SON -- print [sg]etsockopt() opt-name (3rd) arg */
2683 	prt_utt,	/* UTT -- print utrap type */
2684 	prt_uth,	/* UTH -- print utrap handler */
2685 	prt_acc,	/* ACC -- print access() flags */
2686 	prt_sht,	/* SHT -- print shutdown() how (2nd) argument */
2687 	prt_ffg,	/* FFG -- print fcntl() flags (3rd) argument */
2688 	prt_prs,	/* PRS -- print privilege set */
2689 	prt_pro,	/* PRO -- print privilege set operation */
2690 	prt_prn,	/* PRN -- print privilege set name */
2691 	prt_pfl,	/* PFL -- print privilege/process flag name */
2692 	prt_laf,	/* LAF -- print lgrp_affinity arguments */
2693 	prt_key,	/* KEY -- print key_t 0 as IPC_PRIVATE */
2694 	prt_zga,	/* ZGA -- print zone_getattr attribute types */
2695 	prt_atc,	/* ATC -- print AT_FDCWD or file descriptor */
2696 	prt_lio,	/* LIO -- print LIO_XX flags */
2697 	prt_dfl,	/* DFL -- print door_create() flags */
2698 	prt_dpm,	/* DPM -- print DOOR_PARAM_XX flags */
2699 	prt_tnd,	/* TND -- print trusted network data base opcode */
2700 	prt_rsc,	/* RSC -- print rctlsys() subcodes */
2701 	prt_rgf,	/* RGF -- print getrctl() flags */
2702 	prt_rsf,	/* RSF -- print setrctl() flags */
2703 	prt_rcf,	/* RCF -- print rctlsys_ctl() flags */
2704 	prt_fxf,	/* FXF -- print forkx() flags */
2705 	prt_spf,	/* SPF -- print rctlsys_projset() flags */
2706 	prt_un1,	/* UN1 -- as prt_uns except for -1 */
2707 	prt_dec,	/* HID -- hidden argument, make this the last one */
2708 };
2709