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