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