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