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