xref: /onnv-gate/usr/src/cmd/truss/print.c (revision 10493)
10Sstevel@tonic-gate /*
20Sstevel@tonic-gate  * CDDL HEADER START
30Sstevel@tonic-gate  *
40Sstevel@tonic-gate  * The contents of this file are subject to the terms of the
51676Sjpk  * Common Development and Distribution License (the "License").
61676Sjpk  * You may not use this file except in compliance with the License.
70Sstevel@tonic-gate  *
80Sstevel@tonic-gate  * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
90Sstevel@tonic-gate  * or http://www.opensolaris.org/os/licensing.
100Sstevel@tonic-gate  * See the License for the specific language governing permissions
110Sstevel@tonic-gate  * and limitations under the License.
120Sstevel@tonic-gate  *
130Sstevel@tonic-gate  * When distributing Covered Code, include this CDDL HEADER in each
140Sstevel@tonic-gate  * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
150Sstevel@tonic-gate  * If applicable, add the following below this CDDL HEADER, with the
160Sstevel@tonic-gate  * fields enclosed by brackets "[]" replaced with your own identifying
170Sstevel@tonic-gate  * information: Portions Copyright [yyyy] [name of copyright owner]
180Sstevel@tonic-gate  *
190Sstevel@tonic-gate  * CDDL HEADER END
200Sstevel@tonic-gate  */
210Sstevel@tonic-gate /*
228485SPeter.Memishian@Sun.COM  * Copyright 2009 Sun Microsystems, Inc.  All rights reserved.
230Sstevel@tonic-gate  * Use is subject to license terms.
240Sstevel@tonic-gate  */
250Sstevel@tonic-gate 
260Sstevel@tonic-gate /*	Copyright (c) 1984, 1986, 1987, 1988, 1989 AT&T	*/
270Sstevel@tonic-gate /*	  All Rights Reserved  	*/
280Sstevel@tonic-gate 
290Sstevel@tonic-gate #define	_SYSCALL32	/* make 32-bit compat headers visible */
300Sstevel@tonic-gate 
310Sstevel@tonic-gate #include <stdio.h>
320Sstevel@tonic-gate #include <stdlib.h>
330Sstevel@tonic-gate #include <unistd.h>
340Sstevel@tonic-gate #include <string.h>
350Sstevel@tonic-gate #include <signal.h>
360Sstevel@tonic-gate #include <termio.h>
370Sstevel@tonic-gate #include <stddef.h>
380Sstevel@tonic-gate #include <limits.h>
3910440SRoger.Faulkner@Sun.COM #include <fcntl.h>
400Sstevel@tonic-gate #include <ctype.h>
410Sstevel@tonic-gate #include <sys/types.h>
420Sstevel@tonic-gate #include <sys/mman.h>
430Sstevel@tonic-gate #include <sys/resource.h>
440Sstevel@tonic-gate #include <sys/ulimit.h>
450Sstevel@tonic-gate #include <sys/utsname.h>
460Sstevel@tonic-gate #include <sys/kstat.h>
470Sstevel@tonic-gate #include <sys/modctl.h>
480Sstevel@tonic-gate #include <sys/acl.h>
490Sstevel@tonic-gate #include <stropts.h>
500Sstevel@tonic-gate #include <sys/isa_defs.h>
510Sstevel@tonic-gate #include <sys/systeminfo.h>
520Sstevel@tonic-gate #include <sys/cladm.h>
530Sstevel@tonic-gate #include <sys/lwp.h>
540Sstevel@tonic-gate #include <bsm/audit.h>
550Sstevel@tonic-gate #include <libproc.h>
560Sstevel@tonic-gate #include <priv.h>
570Sstevel@tonic-gate #include <sys/aio.h>
580Sstevel@tonic-gate #include <sys/aiocb.h>
590Sstevel@tonic-gate #include <sys/corectl.h>
600Sstevel@tonic-gate #include <sys/cpc_impl.h>
610Sstevel@tonic-gate #include <sys/priocntl.h>
620Sstevel@tonic-gate #include <sys/tspriocntl.h>
630Sstevel@tonic-gate #include <sys/iapriocntl.h>
640Sstevel@tonic-gate #include <sys/rtpriocntl.h>
650Sstevel@tonic-gate #include <sys/fsspriocntl.h>
660Sstevel@tonic-gate #include <sys/fxpriocntl.h>
670Sstevel@tonic-gate #include <netdb.h>
680Sstevel@tonic-gate #include <nss_dbdefs.h>
690Sstevel@tonic-gate #include <sys/socketvar.h>
700Sstevel@tonic-gate #include <netinet/in.h>
710Sstevel@tonic-gate #include <netinet/tcp.h>
720Sstevel@tonic-gate #include <netinet/udp.h>
730Sstevel@tonic-gate #include <netinet/sctp.h>
748485SPeter.Memishian@Sun.COM #include <net/route.h>
750Sstevel@tonic-gate #include <sys/utrap.h>
760Sstevel@tonic-gate #include <sys/lgrp_user.h>
770Sstevel@tonic-gate #include <sys/door.h>
781676Sjpk #include <sys/tsol/tndb.h>
792447Snf202958 #include <sys/rctl.h>
802447Snf202958 #include <sys/rctl_impl.h>
813235Sraf #include <sys/fork.h>
823684Srd117015 #include <sys/task.h>
830Sstevel@tonic-gate #include "ramdata.h"
840Sstevel@tonic-gate #include "print.h"
850Sstevel@tonic-gate #include "proto.h"
860Sstevel@tonic-gate #include "systable.h"
870Sstevel@tonic-gate 
880Sstevel@tonic-gate void grow(private_t *, int nbyte);
890Sstevel@tonic-gate 
900Sstevel@tonic-gate #define	GROW(nb) if (pri->sys_leng + (nb) >= pri->sys_ssize) grow(pri, (nb))
910Sstevel@tonic-gate 
920Sstevel@tonic-gate 
930Sstevel@tonic-gate /*ARGSUSED*/
940Sstevel@tonic-gate void
950Sstevel@tonic-gate prt_nov(private_t *pri, int raw, long val)	/* print nothing */
960Sstevel@tonic-gate {
970Sstevel@tonic-gate }
980Sstevel@tonic-gate 
990Sstevel@tonic-gate /*ARGSUSED*/
1000Sstevel@tonic-gate void
1010Sstevel@tonic-gate prt_dec(private_t *pri, int raw, long val)	/* print as decimal */
1020Sstevel@tonic-gate {
1030Sstevel@tonic-gate 	GROW(24);
1040Sstevel@tonic-gate 	if (data_model == PR_MODEL_ILP32)
1050Sstevel@tonic-gate 		pri->sys_leng += sprintf(pri->sys_string + pri->sys_leng,
1064217Seschrock 		    "%d", (int)val);
1070Sstevel@tonic-gate 	else
1080Sstevel@tonic-gate 		pri->sys_leng += sprintf(pri->sys_string + pri->sys_leng,
1094217Seschrock 		    "%ld", val);
1100Sstevel@tonic-gate }
1110Sstevel@tonic-gate 
1120Sstevel@tonic-gate /*ARGSUSED*/
1130Sstevel@tonic-gate void
1140Sstevel@tonic-gate prt_uns(private_t *pri, int raw, long val)	/* print as unsigned decimal */
1150Sstevel@tonic-gate {
1160Sstevel@tonic-gate 	GROW(24);
1170Sstevel@tonic-gate 	if (data_model == PR_MODEL_ILP32)
1180Sstevel@tonic-gate 		pri->sys_leng += sprintf(pri->sys_string + pri->sys_leng,
1194217Seschrock 		    "%u", (int)val);
1200Sstevel@tonic-gate 	else
1210Sstevel@tonic-gate 		pri->sys_leng += sprintf(pri->sys_string + pri->sys_leng,
1224217Seschrock 		    "%lu", val);
1230Sstevel@tonic-gate }
1240Sstevel@tonic-gate 
1254321Scasper /* print as unsigned decimal, except for -1 */
1264321Scasper void
1274321Scasper prt_un1(private_t *pri, int raw, long val)
1284321Scasper {
1294321Scasper 	if ((int)val == -1)
1304321Scasper 		prt_dec(pri, raw, val);
1314321Scasper 	else
1324321Scasper 		prt_uns(pri, raw, val);
1334321Scasper }
1344321Scasper 
1350Sstevel@tonic-gate /*ARGSUSED*/
1360Sstevel@tonic-gate void
1370Sstevel@tonic-gate prt_oct(private_t *pri, int raw, long val)	/* print as octal */
1380Sstevel@tonic-gate {
1390Sstevel@tonic-gate 	GROW(24);
1400Sstevel@tonic-gate 	if (data_model == PR_MODEL_ILP32)
1410Sstevel@tonic-gate 		pri->sys_leng += sprintf(pri->sys_string + pri->sys_leng,
1424217Seschrock 		    "%#o", (int)val);
1430Sstevel@tonic-gate 	else
1440Sstevel@tonic-gate 		pri->sys_leng += sprintf(pri->sys_string + pri->sys_leng,
1454217Seschrock 		    "%#lo", val);
1460Sstevel@tonic-gate }
1470Sstevel@tonic-gate 
1480Sstevel@tonic-gate /*ARGSUSED*/
1490Sstevel@tonic-gate void
1500Sstevel@tonic-gate prt_hex(private_t *pri, int raw, long val)	/* print as hexadecimal */
1510Sstevel@tonic-gate {
1520Sstevel@tonic-gate 	GROW(20);
1530Sstevel@tonic-gate 	if (data_model == PR_MODEL_ILP32)
1540Sstevel@tonic-gate 		pri->sys_leng += sprintf(pri->sys_string + pri->sys_leng,
1554217Seschrock 		    "0x%.8X", (int)val);
1560Sstevel@tonic-gate 	else
1570Sstevel@tonic-gate 		pri->sys_leng += sprintf(pri->sys_string + pri->sys_leng,
1584217Seschrock 		    "0x%.8lX", val);
1590Sstevel@tonic-gate }
1600Sstevel@tonic-gate 
1610Sstevel@tonic-gate /* print as hexadecimal (half size) */
1620Sstevel@tonic-gate /*ARGSUSED*/
1630Sstevel@tonic-gate void
1640Sstevel@tonic-gate prt_hhx(private_t *pri, int raw, long val)
1650Sstevel@tonic-gate {
1660Sstevel@tonic-gate 	GROW(20);
1670Sstevel@tonic-gate 	if (data_model == PR_MODEL_ILP32)
1680Sstevel@tonic-gate 		pri->sys_leng += sprintf(pri->sys_string + pri->sys_leng,
1694217Seschrock 		    "0x%.4X", (int)val);
1700Sstevel@tonic-gate 	else
1710Sstevel@tonic-gate 		pri->sys_leng += sprintf(pri->sys_string + pri->sys_leng,
1724217Seschrock 		    "0x%.4lX", val);
1730Sstevel@tonic-gate }
1740Sstevel@tonic-gate 
1750Sstevel@tonic-gate /* print as decimal if small, else hexadecimal */
1760Sstevel@tonic-gate /*ARGSUSED*/
1770Sstevel@tonic-gate void
1780Sstevel@tonic-gate prt_dex(private_t *pri, int raw, long val)
1790Sstevel@tonic-gate {
1800Sstevel@tonic-gate 	if (val & 0xff000000)
1810Sstevel@tonic-gate 		prt_hex(pri, 0, val);
1820Sstevel@tonic-gate 	else
1830Sstevel@tonic-gate 		prt_dec(pri, 0, val);
1840Sstevel@tonic-gate }
1850Sstevel@tonic-gate 
1860Sstevel@tonic-gate /* print long long offset */
1870Sstevel@tonic-gate /*ARGSUSED*/
1880Sstevel@tonic-gate void
1890Sstevel@tonic-gate prt_llo(private_t *pri, int raw, long val1, long val2)
1900Sstevel@tonic-gate {
1910Sstevel@tonic-gate 	int hival;
1920Sstevel@tonic-gate 	int loval;
1930Sstevel@tonic-gate 
1940Sstevel@tonic-gate #ifdef	_LONG_LONG_LTOH
1950Sstevel@tonic-gate 	hival = (int)val2;
1960Sstevel@tonic-gate 	loval = (int)val1;
1970Sstevel@tonic-gate #else
1980Sstevel@tonic-gate 	hival = (int)val1;
1990Sstevel@tonic-gate 	loval = (int)val2;
2000Sstevel@tonic-gate #endif
2010Sstevel@tonic-gate 
2024217Seschrock 	if (hival == 0) {
2030Sstevel@tonic-gate 		prt_dex(pri, 0, loval);
2044217Seschrock 	} else {
2050Sstevel@tonic-gate 		GROW(18);
2060Sstevel@tonic-gate 		pri->sys_leng +=
2074217Seschrock 		    sprintf(pri->sys_string + pri->sys_leng, "0x%.8X%.8X",
2084217Seschrock 		    hival, loval);
2090Sstevel@tonic-gate 	}
2100Sstevel@tonic-gate }
2110Sstevel@tonic-gate 
2120Sstevel@tonic-gate void
2130Sstevel@tonic-gate escape_string(private_t *pri, const char *s)
2140Sstevel@tonic-gate {
2150Sstevel@tonic-gate 	/*
2160Sstevel@tonic-gate 	 * We want to avoid outputting unprintable characters that may
2170Sstevel@tonic-gate 	 * destroy the user's terminal.  So we do one pass to find any
2180Sstevel@tonic-gate 	 * unprintable characters, size the array appropriately, and
2190Sstevel@tonic-gate 	 * then walk each character by hand.  Those that are unprintable
2200Sstevel@tonic-gate 	 * are replaced by a hex escape (\xNN).  We also escape quotes for
2210Sstevel@tonic-gate 	 * completeness.
2220Sstevel@tonic-gate 	 */
2230Sstevel@tonic-gate 	int i, unprintable, quotes;
2240Sstevel@tonic-gate 	size_t len = strlen(s);
2250Sstevel@tonic-gate 	for (i = 0, unprintable = 0, quotes = 0; i < len; i++) {
2260Sstevel@tonic-gate 		if (!isprint(s[i]))
2270Sstevel@tonic-gate 			unprintable++;
2280Sstevel@tonic-gate 		if (s[i] == '"')
2290Sstevel@tonic-gate 			quotes++;
2300Sstevel@tonic-gate 	}
2310Sstevel@tonic-gate 
2320Sstevel@tonic-gate 	GROW(len + 3 * unprintable + quotes + 2);
2330Sstevel@tonic-gate 
2340Sstevel@tonic-gate 	pri->sys_string[pri->sys_leng++] = '"';
2350Sstevel@tonic-gate 	for (i = 0; i < len; i++) {
2360Sstevel@tonic-gate 		if (s[i] == '"')
2370Sstevel@tonic-gate 			pri->sys_string[pri->sys_leng++] = '\\';
2380Sstevel@tonic-gate 
2390Sstevel@tonic-gate 		if (isprint(s[i])) {
2400Sstevel@tonic-gate 			pri->sys_string[pri->sys_leng++] = s[i];
2410Sstevel@tonic-gate 		} else {
2420Sstevel@tonic-gate 			pri->sys_leng += sprintf(pri->sys_string +
2434217Seschrock 			    pri->sys_leng, "\\x%02x", (uint8_t)s[i]);
2440Sstevel@tonic-gate 		}
2450Sstevel@tonic-gate 	}
2460Sstevel@tonic-gate 	pri->sys_string[pri->sys_leng++] = '"';
2470Sstevel@tonic-gate }
2480Sstevel@tonic-gate 
2490Sstevel@tonic-gate void
2500Sstevel@tonic-gate prt_stg(private_t *pri, int raw, long val)	/* print as string */
2510Sstevel@tonic-gate {
2520Sstevel@tonic-gate 	char *s = raw? NULL : fetchstring(pri, (long)val, PATH_MAX);
2530Sstevel@tonic-gate 
2540Sstevel@tonic-gate 	if (s == NULL)
2550Sstevel@tonic-gate 		prt_hex(pri, 0, val);
2560Sstevel@tonic-gate 	else
2570Sstevel@tonic-gate 		escape_string(pri, s);
2580Sstevel@tonic-gate }
2590Sstevel@tonic-gate 
2600Sstevel@tonic-gate /* print as string returned from syscall */
2610Sstevel@tonic-gate void
2620Sstevel@tonic-gate prt_rst(private_t *pri, int raw, long val)
2630Sstevel@tonic-gate {
2640Sstevel@tonic-gate 	char *s = (raw || pri->Errno)? NULL :
2654217Seschrock 	    fetchstring(pri, (long)val, PATH_MAX);
2660Sstevel@tonic-gate 
2670Sstevel@tonic-gate 	if (s == NULL)
2680Sstevel@tonic-gate 		prt_hex(pri, 0, val);
2690Sstevel@tonic-gate 	else {
2700Sstevel@tonic-gate 		GROW((int)strlen(s) + 2);
2710Sstevel@tonic-gate 		pri->sys_leng += snprintf(pri->sys_string + pri->sys_leng,
2720Sstevel@tonic-gate 		    pri->sys_ssize - pri->sys_leng, "\"%s\"", s);
2730Sstevel@tonic-gate 	}
2740Sstevel@tonic-gate }
2750Sstevel@tonic-gate 
2760Sstevel@tonic-gate /* print contents of readlink() buffer */
2770Sstevel@tonic-gate void
2780Sstevel@tonic-gate prt_rlk(private_t *pri, int raw, long val)
2790Sstevel@tonic-gate {
2800Sstevel@tonic-gate 	char *s = (raw || pri->Errno || pri->Rval1 <= 0)? NULL :
2814217Seschrock 	    fetchstring(pri, (long)val,
2824217Seschrock 	    (pri->Rval1 > PATH_MAX)? PATH_MAX : (int)pri->Rval1);
2830Sstevel@tonic-gate 
2840Sstevel@tonic-gate 	if (s == NULL)
2850Sstevel@tonic-gate 		prt_hex(pri, 0, val);
2860Sstevel@tonic-gate 	else {
2870Sstevel@tonic-gate 		GROW((int)strlen(s) + 2);
2880Sstevel@tonic-gate 		pri->sys_leng += snprintf(pri->sys_string + pri->sys_leng,
2890Sstevel@tonic-gate 		    pri->sys_ssize - pri->sys_leng, "\"%s\"", s);
2900Sstevel@tonic-gate 	}
2910Sstevel@tonic-gate }
2920Sstevel@tonic-gate 
2930Sstevel@tonic-gate void
2940Sstevel@tonic-gate prt_ioc(private_t *pri, int raw, long val)	/* print ioctl code */
2950Sstevel@tonic-gate {
2960Sstevel@tonic-gate 	const char *s = raw? NULL : ioctlname(pri, (int)val);
2970Sstevel@tonic-gate 
2980Sstevel@tonic-gate 	if (s == NULL)
2990Sstevel@tonic-gate 		prt_hex(pri, 0, val);
3000Sstevel@tonic-gate 	else
3010Sstevel@tonic-gate 		outstring(pri, s);
3020Sstevel@tonic-gate }
3030Sstevel@tonic-gate 
3040Sstevel@tonic-gate void
3050Sstevel@tonic-gate prt_ioa(private_t *pri, int raw, long val)	/* print ioctl argument */
3060Sstevel@tonic-gate {
3070Sstevel@tonic-gate 	const char *s;
3080Sstevel@tonic-gate 
3090Sstevel@tonic-gate 	/* cheating -- look at the ioctl() code */
3100Sstevel@tonic-gate 	switch (pri->sys_args[1]) {
3110Sstevel@tonic-gate 
3120Sstevel@tonic-gate 	/* kstat ioctl()s */
3130Sstevel@tonic-gate 	case KSTAT_IOC_READ:
3140Sstevel@tonic-gate 	case KSTAT_IOC_WRITE:
3150Sstevel@tonic-gate #ifdef _LP64
3160Sstevel@tonic-gate 		if (data_model == PR_MODEL_ILP32)
3170Sstevel@tonic-gate 			prt_stg(pri, raw,
3184217Seschrock 			    val + offsetof(kstat32_t, ks_name[0]));
3190Sstevel@tonic-gate 		else
3200Sstevel@tonic-gate #endif
3210Sstevel@tonic-gate 			prt_stg(pri, raw,
3224217Seschrock 			    val + offsetof(kstat_t, ks_name[0]));
3230Sstevel@tonic-gate 		break;
3240Sstevel@tonic-gate 
3250Sstevel@tonic-gate 	/* streams ioctl()s */
3260Sstevel@tonic-gate 	case I_LOOK:
3270Sstevel@tonic-gate 		prt_rst(pri, raw, val);
3280Sstevel@tonic-gate 		break;
3290Sstevel@tonic-gate 	case I_PUSH:
3300Sstevel@tonic-gate 	case I_FIND:
3310Sstevel@tonic-gate 		prt_stg(pri, raw, val);
3320Sstevel@tonic-gate 		break;
3330Sstevel@tonic-gate 	case I_LINK:
3340Sstevel@tonic-gate 	case I_UNLINK:
3350Sstevel@tonic-gate 	case I_SENDFD:
3360Sstevel@tonic-gate 		prt_dec(pri, 0, val);
3370Sstevel@tonic-gate 		break;
3380Sstevel@tonic-gate 	case I_SRDOPT:
3390Sstevel@tonic-gate 		if (raw || (s = strrdopt(val)) == NULL)
3400Sstevel@tonic-gate 			prt_dec(pri, 0, val);
3410Sstevel@tonic-gate 		else
3420Sstevel@tonic-gate 			outstring(pri, s);
3430Sstevel@tonic-gate 		break;
3440Sstevel@tonic-gate 	case I_SETSIG:
3450Sstevel@tonic-gate 		if (raw || (s = strevents(pri, val)) == NULL)
3460Sstevel@tonic-gate 			prt_hex(pri, 0, val);
3470Sstevel@tonic-gate 		else
3480Sstevel@tonic-gate 			outstring(pri, s);
3490Sstevel@tonic-gate 		break;
3500Sstevel@tonic-gate 	case I_FLUSH:
3510Sstevel@tonic-gate 		if (raw || (s = strflush(val)) == NULL)
3520Sstevel@tonic-gate 			prt_dec(pri, 0, val);
3530Sstevel@tonic-gate 		else
3540Sstevel@tonic-gate 			outstring(pri, s);
3550Sstevel@tonic-gate 		break;
3560Sstevel@tonic-gate 
3570Sstevel@tonic-gate 	/* tty ioctl()s */
3580Sstevel@tonic-gate 	case TCSBRK:
3590Sstevel@tonic-gate 	case TCXONC:
3600Sstevel@tonic-gate 	case TCFLSH:
3610Sstevel@tonic-gate 	case TCDSET:
3620Sstevel@tonic-gate 		prt_dec(pri, 0, val);
3630Sstevel@tonic-gate 		break;
3640Sstevel@tonic-gate 
3650Sstevel@tonic-gate 	default:
3660Sstevel@tonic-gate 		prt_hex(pri, 0, val);
3670Sstevel@tonic-gate 		break;
3680Sstevel@tonic-gate 	}
3690Sstevel@tonic-gate }
3700Sstevel@tonic-gate 
3710Sstevel@tonic-gate void
3720Sstevel@tonic-gate prt_fcn(private_t *pri, int raw, long val)	/* print fcntl code */
3730Sstevel@tonic-gate {
3740Sstevel@tonic-gate 	const char *s = raw? NULL : fcntlname(val);
3750Sstevel@tonic-gate 
3760Sstevel@tonic-gate 	if (s == NULL)
3770Sstevel@tonic-gate 		prt_dec(pri, 0, val);
3780Sstevel@tonic-gate 	else
3790Sstevel@tonic-gate 		outstring(pri, s);
3800Sstevel@tonic-gate }
3810Sstevel@tonic-gate 
3820Sstevel@tonic-gate void
3830Sstevel@tonic-gate prt_s86(private_t *pri, int raw, long val)	/* print sysi86 code */
3840Sstevel@tonic-gate {
3850Sstevel@tonic-gate 
3860Sstevel@tonic-gate 	const char *s = raw? NULL : si86name(val);
3870Sstevel@tonic-gate 
3880Sstevel@tonic-gate 	if (s == NULL)
3890Sstevel@tonic-gate 		prt_dec(pri, 0, val);
3900Sstevel@tonic-gate 	else
3910Sstevel@tonic-gate 		outstring(pri, s);
3920Sstevel@tonic-gate }
3930Sstevel@tonic-gate 
3940Sstevel@tonic-gate void
3950Sstevel@tonic-gate prt_uts(private_t *pri, int raw, long val)	/* print utssys code */
3960Sstevel@tonic-gate {
3970Sstevel@tonic-gate 	const char *s = raw? NULL : utscode(val);
3980Sstevel@tonic-gate 
3990Sstevel@tonic-gate 	if (s == NULL)
4000Sstevel@tonic-gate 		prt_dec(pri, 0, val);
4010Sstevel@tonic-gate 	else
4020Sstevel@tonic-gate 		outstring(pri, s);
4030Sstevel@tonic-gate }
4040Sstevel@tonic-gate 
4050Sstevel@tonic-gate void
4060Sstevel@tonic-gate prt_msc(private_t *pri, int raw, long val)	/* print msgsys command */
4070Sstevel@tonic-gate {
4080Sstevel@tonic-gate 	const char *s = raw? NULL : msgcmd(val);
4090Sstevel@tonic-gate 
4100Sstevel@tonic-gate 	if (s == NULL)
4110Sstevel@tonic-gate 		prt_dec(pri, 0, val);
4120Sstevel@tonic-gate 	else
4130Sstevel@tonic-gate 		outstring(pri, s);
4140Sstevel@tonic-gate }
4150Sstevel@tonic-gate 
4160Sstevel@tonic-gate void
4170Sstevel@tonic-gate prt_msf(private_t *pri, int raw, long val)	/* print msgsys flags */
4180Sstevel@tonic-gate {
4190Sstevel@tonic-gate 	const char *s = raw? NULL : msgflags(pri, (int)val);
4200Sstevel@tonic-gate 
4210Sstevel@tonic-gate 	if (s == NULL)
4220Sstevel@tonic-gate 		prt_oct(pri, 0, val);
4230Sstevel@tonic-gate 	else
4240Sstevel@tonic-gate 		outstring(pri, s);
4250Sstevel@tonic-gate }
4260Sstevel@tonic-gate 
4270Sstevel@tonic-gate void
4280Sstevel@tonic-gate prt_smc(private_t *pri, int raw, long val)	/* print semsys command */
4290Sstevel@tonic-gate {
4300Sstevel@tonic-gate 	const char *s = raw? NULL : semcmd(val);
4310Sstevel@tonic-gate 
4320Sstevel@tonic-gate 	if (s == NULL)
4330Sstevel@tonic-gate 		prt_dec(pri, 0, val);
4340Sstevel@tonic-gate 	else
4350Sstevel@tonic-gate 		outstring(pri, s);
4360Sstevel@tonic-gate }
4370Sstevel@tonic-gate 
4380Sstevel@tonic-gate void
4390Sstevel@tonic-gate prt_sef(private_t *pri, int raw, long val)	/* print semsys flags */
4400Sstevel@tonic-gate {
4410Sstevel@tonic-gate 	const char *s = raw? NULL : semflags(pri, (int)val);
4420Sstevel@tonic-gate 
4430Sstevel@tonic-gate 	if (s == NULL)
4440Sstevel@tonic-gate 		prt_oct(pri, 0, val);
4450Sstevel@tonic-gate 	else
4460Sstevel@tonic-gate 		outstring(pri, s);
4470Sstevel@tonic-gate }
4480Sstevel@tonic-gate 
4490Sstevel@tonic-gate void
4500Sstevel@tonic-gate prt_shc(private_t *pri, int raw, long val)	/* print shmsys command */
4510Sstevel@tonic-gate {
4520Sstevel@tonic-gate 	const char *s = raw? NULL : shmcmd(val);
4530Sstevel@tonic-gate 
4540Sstevel@tonic-gate 	if (s == NULL)
4550Sstevel@tonic-gate 		prt_dec(pri, 0, val);
4560Sstevel@tonic-gate 	else
4570Sstevel@tonic-gate 		outstring(pri, s);
4580Sstevel@tonic-gate }
4590Sstevel@tonic-gate 
4600Sstevel@tonic-gate void
4610Sstevel@tonic-gate prt_shf(private_t *pri, int raw, long val)	/* print shmsys flags */
4620Sstevel@tonic-gate {
4630Sstevel@tonic-gate 	const char *s = raw? NULL : shmflags(pri, (int)val);
4640Sstevel@tonic-gate 
4650Sstevel@tonic-gate 	if (s == NULL)
4660Sstevel@tonic-gate 		prt_oct(pri, 0, val);
4670Sstevel@tonic-gate 	else
4680Sstevel@tonic-gate 		outstring(pri, s);
4690Sstevel@tonic-gate }
4700Sstevel@tonic-gate 
4710Sstevel@tonic-gate void
4720Sstevel@tonic-gate prt_sfs(private_t *pri, int raw, long val)	/* print sysfs code */
4730Sstevel@tonic-gate {
4740Sstevel@tonic-gate 	const char *s = raw? NULL : sfsname(val);
4750Sstevel@tonic-gate 
4760Sstevel@tonic-gate 	if (s == NULL)
4770Sstevel@tonic-gate 		prt_dec(pri, 0, val);
4780Sstevel@tonic-gate 	else
4790Sstevel@tonic-gate 		outstring(pri, s);
4800Sstevel@tonic-gate }
4810Sstevel@tonic-gate 
4820Sstevel@tonic-gate void
4830Sstevel@tonic-gate prt_opn(private_t *pri, int raw, long val)	/* print open code */
4840Sstevel@tonic-gate {
4850Sstevel@tonic-gate 	const char *s = raw? NULL : openarg(pri, val);
4860Sstevel@tonic-gate 
4870Sstevel@tonic-gate 	if (s == NULL)
4880Sstevel@tonic-gate 		prt_oct(pri, 0, val);
4890Sstevel@tonic-gate 	else
4900Sstevel@tonic-gate 		outstring(pri, s);
4910Sstevel@tonic-gate }
4920Sstevel@tonic-gate 
4930Sstevel@tonic-gate void
4940Sstevel@tonic-gate prt_sig(private_t *pri, int raw, long val) /* print signal name plus flags */
4950Sstevel@tonic-gate {
4960Sstevel@tonic-gate 	const char *s = raw? NULL : sigarg(pri, (int)val);
4970Sstevel@tonic-gate 
4980Sstevel@tonic-gate 	if (s == NULL)
4990Sstevel@tonic-gate 		prt_hex(pri, 0, val);
5000Sstevel@tonic-gate 	else
5010Sstevel@tonic-gate 		outstring(pri, s);
5020Sstevel@tonic-gate }
5030Sstevel@tonic-gate 
5040Sstevel@tonic-gate /* print signal name, masked with SIGNO_MASK */
5050Sstevel@tonic-gate void
5060Sstevel@tonic-gate prt_six(private_t *pri, int raw, long val)
5070Sstevel@tonic-gate {
5080Sstevel@tonic-gate 	const char *s = raw? NULL : sigarg(pri, (int)val & SIGNO_MASK);
5090Sstevel@tonic-gate 
5100Sstevel@tonic-gate 	if (s == NULL)
5110Sstevel@tonic-gate 		prt_hex(pri, 0, val);
5120Sstevel@tonic-gate 	else
5130Sstevel@tonic-gate 		outstring(pri, s);
5140Sstevel@tonic-gate }
5150Sstevel@tonic-gate 
5160Sstevel@tonic-gate void
5170Sstevel@tonic-gate prt_act(private_t *pri, int raw, long val)	/* print signal action value */
5180Sstevel@tonic-gate {
5190Sstevel@tonic-gate 	const char *s;
5200Sstevel@tonic-gate 
5210Sstevel@tonic-gate 	if (raw)
5220Sstevel@tonic-gate 		s = NULL;
5230Sstevel@tonic-gate 	else if (val == (int)SIG_DFL)
5240Sstevel@tonic-gate 		s = "SIG_DFL";
5250Sstevel@tonic-gate 	else if (val == (int)SIG_IGN)
5260Sstevel@tonic-gate 		s = "SIG_IGN";
5270Sstevel@tonic-gate 	else if (val == (int)SIG_HOLD)
5280Sstevel@tonic-gate 		s = "SIG_HOLD";
5290Sstevel@tonic-gate 	else
5300Sstevel@tonic-gate 		s = NULL;
5310Sstevel@tonic-gate 
5320Sstevel@tonic-gate 	if (s == NULL)
5330Sstevel@tonic-gate 		prt_hex(pri, 0, val);
5340Sstevel@tonic-gate 	else
5350Sstevel@tonic-gate 		outstring(pri, s);
5360Sstevel@tonic-gate }
5370Sstevel@tonic-gate 
5380Sstevel@tonic-gate void
5390Sstevel@tonic-gate prt_smf(private_t *pri, int raw, long val) /* print streams message flags */
5400Sstevel@tonic-gate {
5410Sstevel@tonic-gate 	switch (val) {
5420Sstevel@tonic-gate 	case 0:
5430Sstevel@tonic-gate 		prt_dec(pri, 0, val);
5440Sstevel@tonic-gate 		break;
5450Sstevel@tonic-gate 	case RS_HIPRI:
5460Sstevel@tonic-gate 		if (raw)
5470Sstevel@tonic-gate 			prt_hhx(pri, 0, val);
5480Sstevel@tonic-gate 		else
5490Sstevel@tonic-gate 			outstring(pri, "RS_HIPRI");
5500Sstevel@tonic-gate 		break;
5510Sstevel@tonic-gate 	default:
5520Sstevel@tonic-gate 		prt_hhx(pri, 0, val);
5530Sstevel@tonic-gate 		break;
5540Sstevel@tonic-gate 	}
5550Sstevel@tonic-gate }
5560Sstevel@tonic-gate 
5570Sstevel@tonic-gate void
5580Sstevel@tonic-gate prt_plk(private_t *pri, int raw, long val)	/* print plock code */
5590Sstevel@tonic-gate {
5600Sstevel@tonic-gate 	const char *s = raw? NULL : plockname(val);
5610Sstevel@tonic-gate 
5620Sstevel@tonic-gate 	if (s == NULL)
5630Sstevel@tonic-gate 		prt_dec(pri, 0, val);
5640Sstevel@tonic-gate 	else
5650Sstevel@tonic-gate 		outstring(pri, s);
5660Sstevel@tonic-gate }
5670Sstevel@tonic-gate 
5680Sstevel@tonic-gate void
5690Sstevel@tonic-gate prt_mtf(private_t *pri, int raw, long val)	/* print mount flags */
5700Sstevel@tonic-gate {
5710Sstevel@tonic-gate 	const char *s = raw? NULL : mountflags(pri, val);
5720Sstevel@tonic-gate 
5730Sstevel@tonic-gate 	if (s == NULL)
5740Sstevel@tonic-gate 		prt_hex(pri, 0, val);
5750Sstevel@tonic-gate 	else
5760Sstevel@tonic-gate 		outstring(pri, s);
5770Sstevel@tonic-gate }
5780Sstevel@tonic-gate 
5790Sstevel@tonic-gate void
5800Sstevel@tonic-gate prt_mft(private_t *pri, int raw, long val) /* print mount file system type */
5810Sstevel@tonic-gate {
5820Sstevel@tonic-gate 	if (val >= 0 && val < 256)
5830Sstevel@tonic-gate 		prt_dec(pri, 0, val);
5840Sstevel@tonic-gate 	else if (raw)
5850Sstevel@tonic-gate 		prt_hex(pri, 0, val);
5860Sstevel@tonic-gate 	else
5870Sstevel@tonic-gate 		prt_stg(pri, raw, val);
5880Sstevel@tonic-gate }
5890Sstevel@tonic-gate 
5900Sstevel@tonic-gate #define	ISREAD(code) \
5910Sstevel@tonic-gate 	((code) == SYS_read || (code) == SYS_pread || (code) == SYS_pread64 || \
5920Sstevel@tonic-gate 	(code) == SYS_recv || (code) == SYS_recvfrom)
5930Sstevel@tonic-gate #define	ISWRITE(code) \
5940Sstevel@tonic-gate 	((code) == SYS_write || (code) == SYS_pwrite || \
5950Sstevel@tonic-gate 	(code) == SYS_pwrite64 || (code) == SYS_send || (code) == SYS_sendto)
5960Sstevel@tonic-gate 
5970Sstevel@tonic-gate /* print contents of read() or write() I/O buffer */
5980Sstevel@tonic-gate void
5990Sstevel@tonic-gate prt_iob(private_t *pri, int raw, long val)
6000Sstevel@tonic-gate {
6010Sstevel@tonic-gate 	const lwpstatus_t *Lsp = pri->lwpstat;
6020Sstevel@tonic-gate 	int syscall = Lsp->pr_what;
6030Sstevel@tonic-gate 	int fdp1 = pri->sys_args[0] + 1;
6040Sstevel@tonic-gate 	ssize_t nbyte = ISWRITE(syscall)? pri->sys_args[2] :
6054217Seschrock 	    (pri->Errno? 0 : pri->Rval1);
6060Sstevel@tonic-gate 	int elsewhere = FALSE;		/* TRUE iff dumped elsewhere */
6070Sstevel@tonic-gate 	char buffer[IOBSIZE];
6080Sstevel@tonic-gate 
6090Sstevel@tonic-gate 	pri->iob_buf[0] = '\0';
6100Sstevel@tonic-gate 
6110Sstevel@tonic-gate 	if (Lsp->pr_why == PR_SYSEXIT && nbyte > IOBSIZE) {
6120Sstevel@tonic-gate 		if (ISREAD(syscall))
6130Sstevel@tonic-gate 			elsewhere = prismember(&readfd, fdp1);
6140Sstevel@tonic-gate 		else
6150Sstevel@tonic-gate 			elsewhere = prismember(&writefd, fdp1);
6160Sstevel@tonic-gate 	}
6170Sstevel@tonic-gate 
6180Sstevel@tonic-gate 	if (nbyte <= 0 || elsewhere)
6190Sstevel@tonic-gate 		prt_hex(pri, 0, val);
6200Sstevel@tonic-gate 	else {
6210Sstevel@tonic-gate 		int nb = nbyte > IOBSIZE? IOBSIZE : (int)nbyte;
6220Sstevel@tonic-gate 
6230Sstevel@tonic-gate 		if (Pread(Proc, buffer, (size_t)nb, (long)val) != nb)
6240Sstevel@tonic-gate 			prt_hex(pri, 0, val);
6250Sstevel@tonic-gate 		else {
6260Sstevel@tonic-gate 			pri->iob_buf[0] = '"';
6270Sstevel@tonic-gate 			showbytes(buffer, nb, pri->iob_buf + 1);
6280Sstevel@tonic-gate 			(void) strlcat(pri->iob_buf,
6294217Seschrock 			    (nb == nbyte)?
6304217Seschrock 			    (const char *)"\"" : (const char *)"\"..",
6314217Seschrock 			    sizeof (pri->iob_buf));
6320Sstevel@tonic-gate 			if (raw)
6330Sstevel@tonic-gate 				prt_hex(pri, 0, val);
6340Sstevel@tonic-gate 			else
6350Sstevel@tonic-gate 				outstring(pri, pri->iob_buf);
6360Sstevel@tonic-gate 		}
6370Sstevel@tonic-gate 	}
6380Sstevel@tonic-gate }
6390Sstevel@tonic-gate #undef	ISREAD
6400Sstevel@tonic-gate #undef	ISWRITE
6410Sstevel@tonic-gate 
6420Sstevel@tonic-gate void
6430Sstevel@tonic-gate prt_idt(private_t *pri, int raw, long val) /* print idtype_t, waitid() arg */
6440Sstevel@tonic-gate {
6450Sstevel@tonic-gate 	const char *s = raw? NULL : idtype_enum(pri, val);
6460Sstevel@tonic-gate 
6470Sstevel@tonic-gate 	if (s == NULL)
6480Sstevel@tonic-gate 		prt_dec(pri, 0, val);
6490Sstevel@tonic-gate 	else
6500Sstevel@tonic-gate 		outstring(pri, s);
6510Sstevel@tonic-gate }
6520Sstevel@tonic-gate 
6530Sstevel@tonic-gate void
6540Sstevel@tonic-gate prt_wop(private_t *pri, int raw, long val)	/* print waitid() options */
6550Sstevel@tonic-gate {
6560Sstevel@tonic-gate 	const char *s = raw? NULL : woptions(pri, (int)val);
6570Sstevel@tonic-gate 
6580Sstevel@tonic-gate 	if (s == NULL)
6590Sstevel@tonic-gate 		prt_oct(pri, 0, val);
6600Sstevel@tonic-gate 	else
6610Sstevel@tonic-gate 		outstring(pri, s);
6620Sstevel@tonic-gate }
6630Sstevel@tonic-gate 
6640Sstevel@tonic-gate void
6650Sstevel@tonic-gate prt_whn(private_t *pri, int raw, long val) /* print lseek() whence argument */
6660Sstevel@tonic-gate {
6670Sstevel@tonic-gate 	const char *s = raw? NULL : whencearg(val);
6680Sstevel@tonic-gate 
6690Sstevel@tonic-gate 	if (s == NULL)
6700Sstevel@tonic-gate 		prt_dec(pri, 0, val);
6710Sstevel@tonic-gate 	else
6720Sstevel@tonic-gate 		outstring(pri, s);
6730Sstevel@tonic-gate }
6740Sstevel@tonic-gate 
6750Sstevel@tonic-gate /*ARGSUSED*/
6760Sstevel@tonic-gate void
6770Sstevel@tonic-gate prt_spm(private_t *pri, int raw, long val)	/* print sigprocmask argument */
6780Sstevel@tonic-gate {
6790Sstevel@tonic-gate 	const char *s = NULL;
6800Sstevel@tonic-gate 
6810Sstevel@tonic-gate 	if (!raw) {
6820Sstevel@tonic-gate 		switch (val) {
6830Sstevel@tonic-gate 		case SIG_BLOCK:		s = "SIG_BLOCK";	break;
6840Sstevel@tonic-gate 		case SIG_UNBLOCK:	s = "SIG_UNBLOCK";	break;
6850Sstevel@tonic-gate 		case SIG_SETMASK:	s = "SIG_SETMASK";	break;
6860Sstevel@tonic-gate 		}
6870Sstevel@tonic-gate 	}
6880Sstevel@tonic-gate 
6890Sstevel@tonic-gate 	if (s == NULL)
6900Sstevel@tonic-gate 		prt_dec(pri, 0, val);
6910Sstevel@tonic-gate 	else
6920Sstevel@tonic-gate 		outstring(pri, s);
6930Sstevel@tonic-gate }
6940Sstevel@tonic-gate 
6950Sstevel@tonic-gate const char *
6960Sstevel@tonic-gate mmap_protect(private_t *pri, long arg)
6970Sstevel@tonic-gate {
6980Sstevel@tonic-gate 	char *str = pri->code_buf;
6990Sstevel@tonic-gate 
7000Sstevel@tonic-gate 	if (arg & ~(PROT_READ|PROT_WRITE|PROT_EXEC))
7010Sstevel@tonic-gate 		return ((char *)NULL);
7020Sstevel@tonic-gate 
7030Sstevel@tonic-gate 	if (arg == PROT_NONE)
7040Sstevel@tonic-gate 		return ("PROT_NONE");
7050Sstevel@tonic-gate 
7060Sstevel@tonic-gate 	*str = '\0';
7070Sstevel@tonic-gate 	if (arg & PROT_READ)
7080Sstevel@tonic-gate 		(void) strlcat(str, "|PROT_READ", sizeof (pri->code_buf));
7090Sstevel@tonic-gate 	if (arg & PROT_WRITE)
7100Sstevel@tonic-gate 		(void) strlcat(str, "|PROT_WRITE", sizeof (pri->code_buf));
7110Sstevel@tonic-gate 	if (arg & PROT_EXEC)
7120Sstevel@tonic-gate 		(void) strlcat(str, "|PROT_EXEC", sizeof (pri->code_buf));
7130Sstevel@tonic-gate 	return ((const char *)(str + 1));
7140Sstevel@tonic-gate }
7150Sstevel@tonic-gate 
7160Sstevel@tonic-gate const char *
7170Sstevel@tonic-gate mmap_type(private_t *pri, long arg)
7180Sstevel@tonic-gate {
7190Sstevel@tonic-gate 	char *str = pri->code_buf;
7200Sstevel@tonic-gate 	size_t used;
7210Sstevel@tonic-gate 
7220Sstevel@tonic-gate #define	CBSIZE	sizeof (pri->code_buf)
7230Sstevel@tonic-gate 	switch (arg & MAP_TYPE) {
7240Sstevel@tonic-gate 	case MAP_SHARED:
7250Sstevel@tonic-gate 		used = strlcpy(str, "MAP_SHARED", CBSIZE);
7260Sstevel@tonic-gate 		break;
7270Sstevel@tonic-gate 	case MAP_PRIVATE:
7280Sstevel@tonic-gate 		used = strlcpy(str, "MAP_PRIVATE", CBSIZE);
7290Sstevel@tonic-gate 		break;
7300Sstevel@tonic-gate 	default:
7310Sstevel@tonic-gate 		used = snprintf(str, CBSIZE, "%ld", arg&MAP_TYPE);
7320Sstevel@tonic-gate 		break;
7330Sstevel@tonic-gate 	}
7340Sstevel@tonic-gate 
7350Sstevel@tonic-gate 	arg &= ~(_MAP_NEW|MAP_TYPE);
7360Sstevel@tonic-gate 
7370Sstevel@tonic-gate 	if (arg & ~(MAP_FIXED|MAP_RENAME|MAP_NORESERVE|MAP_ANON|MAP_ALIGN|
7380Sstevel@tonic-gate 	    MAP_TEXT|MAP_INITDATA))
7390Sstevel@tonic-gate 		(void) snprintf(str + used, sizeof (pri->code_buf) - used,
7404217Seschrock 		    "|0x%lX", arg);
7410Sstevel@tonic-gate 	else {
7420Sstevel@tonic-gate 		if (arg & MAP_FIXED)
7430Sstevel@tonic-gate 			(void) strlcat(str, "|MAP_FIXED", CBSIZE);
7440Sstevel@tonic-gate 		if (arg & MAP_RENAME)
7450Sstevel@tonic-gate 			(void) strlcat(str, "|MAP_RENAME", CBSIZE);
7460Sstevel@tonic-gate 		if (arg & MAP_NORESERVE)
7470Sstevel@tonic-gate 			(void) strlcat(str, "|MAP_NORESERVE", CBSIZE);
7480Sstevel@tonic-gate 		if (arg & MAP_ANON)
7490Sstevel@tonic-gate 			(void) strlcat(str, "|MAP_ANON", CBSIZE);
7500Sstevel@tonic-gate 		if (arg & MAP_ALIGN)
7510Sstevel@tonic-gate 			(void) strlcat(str, "|MAP_ALIGN", CBSIZE);
7520Sstevel@tonic-gate 		if (arg & MAP_TEXT)
7530Sstevel@tonic-gate 			(void) strlcat(str, "|MAP_TEXT", CBSIZE);
7540Sstevel@tonic-gate 		if (arg & MAP_INITDATA)
7550Sstevel@tonic-gate 			(void) strlcat(str, "|MAP_INITDATA", CBSIZE);
7560Sstevel@tonic-gate 	}
7570Sstevel@tonic-gate 
7580Sstevel@tonic-gate 	return ((const char *)str);
7590Sstevel@tonic-gate #undef CBSIZE
7600Sstevel@tonic-gate }
7610Sstevel@tonic-gate 
7620Sstevel@tonic-gate void
7630Sstevel@tonic-gate prt_mpr(private_t *pri, int raw, long val) /* print mmap()/mprotect() flags */
7640Sstevel@tonic-gate {
7650Sstevel@tonic-gate 	const char *s = raw? NULL : mmap_protect(pri, val);
7660Sstevel@tonic-gate 
7670Sstevel@tonic-gate 	if (s == NULL)
7680Sstevel@tonic-gate 		prt_hhx(pri, 0, val);
7690Sstevel@tonic-gate 	else
7700Sstevel@tonic-gate 		outstring(pri, s);
7710Sstevel@tonic-gate }
7720Sstevel@tonic-gate 
7730Sstevel@tonic-gate void
7740Sstevel@tonic-gate prt_mty(private_t *pri, int raw, long val) /* print mmap() mapping type flags */
7750Sstevel@tonic-gate {
7760Sstevel@tonic-gate 	const char *s = raw? NULL : mmap_type(pri, val);
7770Sstevel@tonic-gate 
7780Sstevel@tonic-gate 	if (s == NULL)
7790Sstevel@tonic-gate 		prt_hhx(pri, 0, val);
7800Sstevel@tonic-gate 	else
7810Sstevel@tonic-gate 		outstring(pri, s);
7820Sstevel@tonic-gate }
7830Sstevel@tonic-gate 
78410198SAli.Bahrami@Sun.COM void
78510198SAli.Bahrami@Sun.COM prt_mob(private_t *pri, int raw, long val) /* print mmapobj() flags */
78610198SAli.Bahrami@Sun.COM {
78710198SAli.Bahrami@Sun.COM 	if (val == 0)
78810198SAli.Bahrami@Sun.COM 		prt_dec(pri, 0, val);
78910198SAli.Bahrami@Sun.COM 	else if (raw || (val & ~(MMOBJ_PADDING|MMOBJ_INTERPRET)) != 0)
79010198SAli.Bahrami@Sun.COM 		prt_hhx(pri, 0, val);
79110198SAli.Bahrami@Sun.COM 	else {
79210198SAli.Bahrami@Sun.COM #define	CBSIZE	sizeof (pri->code_buf)
79310198SAli.Bahrami@Sun.COM 		char *s = pri->code_buf;
79410198SAli.Bahrami@Sun.COM 
79510198SAli.Bahrami@Sun.COM 		*s = '\0';
79610198SAli.Bahrami@Sun.COM 		if (val & MMOBJ_PADDING)
79710198SAli.Bahrami@Sun.COM 			(void) strlcat(s, "|MMOBJ_PADDING", CBSIZE);
79810198SAli.Bahrami@Sun.COM 		if (val & MMOBJ_INTERPRET)
79910198SAli.Bahrami@Sun.COM 			(void) strlcat(s, "|MMOBJ_INTERPRET", CBSIZE);
80010198SAli.Bahrami@Sun.COM 		outstring(pri, s + 1);
80110198SAli.Bahrami@Sun.COM #undef CBSIZE
80210198SAli.Bahrami@Sun.COM 	}
80310198SAli.Bahrami@Sun.COM }
80410198SAli.Bahrami@Sun.COM 
8050Sstevel@tonic-gate /*ARGSUSED*/
8060Sstevel@tonic-gate void
8070Sstevel@tonic-gate prt_mcf(private_t *pri, int raw, long val)	/* print memcntl() function */
8080Sstevel@tonic-gate {
8090Sstevel@tonic-gate 	const char *s = NULL;
8100Sstevel@tonic-gate 
8110Sstevel@tonic-gate 	if (!raw) {
8120Sstevel@tonic-gate 		switch (val) {
8130Sstevel@tonic-gate 		case MC_SYNC:		s = "MC_SYNC";		break;
8140Sstevel@tonic-gate 		case MC_LOCK:		s = "MC_LOCK";		break;
8150Sstevel@tonic-gate 		case MC_UNLOCK:		s = "MC_UNLOCK";	break;
8160Sstevel@tonic-gate 		case MC_ADVISE:		s = "MC_ADVISE";	break;
8170Sstevel@tonic-gate 		case MC_LOCKAS:		s = "MC_LOCKAS";	break;
8180Sstevel@tonic-gate 		case MC_UNLOCKAS:	s = "MC_UNLOCKAS";	break;
8190Sstevel@tonic-gate 		case MC_HAT_ADVISE:	s = "MC_HAT_ADVISE";	break;
8200Sstevel@tonic-gate 		}
8210Sstevel@tonic-gate 	}
8220Sstevel@tonic-gate 
8230Sstevel@tonic-gate 	if (s == NULL)
8240Sstevel@tonic-gate 		prt_dec(pri, 0, val);
8250Sstevel@tonic-gate 	else
8260Sstevel@tonic-gate 		outstring(pri, s);
8270Sstevel@tonic-gate }
8280Sstevel@tonic-gate 
8290Sstevel@tonic-gate void
8300Sstevel@tonic-gate prt_mad(private_t *pri, int raw, long val)	/* print madvise() argument */
8310Sstevel@tonic-gate {
8320Sstevel@tonic-gate 	const char *s = NULL;
8330Sstevel@tonic-gate 
8340Sstevel@tonic-gate 	if (!raw) {
8350Sstevel@tonic-gate 		switch (val) {
8360Sstevel@tonic-gate 		case MADV_NORMAL:	s = "MADV_NORMAL";	break;
8370Sstevel@tonic-gate 		case MADV_RANDOM:	s = "MADV_RANDOM";	break;
8380Sstevel@tonic-gate 		case MADV_SEQUENTIAL:	s = "MADV_SEQUENTIAL";	break;
8390Sstevel@tonic-gate 		case MADV_WILLNEED:	s = "MADV_WILLNEED";	break;
8400Sstevel@tonic-gate 		case MADV_DONTNEED:	s = "MADV_DONTNEED";	break;
8410Sstevel@tonic-gate 		case MADV_FREE:		s = "MADV_FREE";	break;
8420Sstevel@tonic-gate 		case MADV_ACCESS_DEFAULT: s = "MADV_ACCESS_DEFAULT";	break;
8430Sstevel@tonic-gate 		case MADV_ACCESS_LWP:	s = "MADV_ACCESS_LWP";	break;
8440Sstevel@tonic-gate 		case MADV_ACCESS_MANY:	s = "MADV_ACCESS_MANY";	break;
8450Sstevel@tonic-gate 		}
8460Sstevel@tonic-gate 	}
8470Sstevel@tonic-gate 
8480Sstevel@tonic-gate 	if (s == NULL)
8490Sstevel@tonic-gate 		prt_dec(pri, 0, val);
8500Sstevel@tonic-gate 	else
8510Sstevel@tonic-gate 		outstring(pri, s);
8520Sstevel@tonic-gate }
8530Sstevel@tonic-gate 
8540Sstevel@tonic-gate void
8550Sstevel@tonic-gate prt_mc4(private_t *pri, int raw, long val) /* print memcntl() (4th) argument */
8560Sstevel@tonic-gate {
8570Sstevel@tonic-gate 	if (val == 0)
8580Sstevel@tonic-gate 		prt_dec(pri, 0, val);
8590Sstevel@tonic-gate 	else if (raw)
8600Sstevel@tonic-gate 		prt_hhx(pri, 0, val);
8610Sstevel@tonic-gate 	else {
8620Sstevel@tonic-gate 		char *s = NULL;
8630Sstevel@tonic-gate 
8640Sstevel@tonic-gate #define	CBSIZE	sizeof (pri->code_buf)
8650Sstevel@tonic-gate 		/* cheating -- look at memcntl func */
8660Sstevel@tonic-gate 		switch (pri->sys_args[2]) {
8670Sstevel@tonic-gate 		case MC_ADVISE:
8680Sstevel@tonic-gate 			prt_mad(pri, 0, val);
8690Sstevel@tonic-gate 			return;
8700Sstevel@tonic-gate 
8710Sstevel@tonic-gate 		case MC_SYNC:
8720Sstevel@tonic-gate 			if ((val & ~(MS_SYNC|MS_ASYNC|MS_INVALIDATE)) == 0) {
8730Sstevel@tonic-gate 				*(s = pri->code_buf) = '\0';
8740Sstevel@tonic-gate 				if (val & MS_SYNC)
8750Sstevel@tonic-gate 					(void) strlcat(s, "|MS_SYNC", CBSIZE);
8760Sstevel@tonic-gate 				if (val & MS_ASYNC)
8770Sstevel@tonic-gate 					(void) strlcat(s, "|MS_ASYNC", CBSIZE);
8780Sstevel@tonic-gate 				if (val & MS_INVALIDATE)
8790Sstevel@tonic-gate 					(void) strlcat(s, "|MS_INVALIDATE",
8804217Seschrock 					    CBSIZE);
8810Sstevel@tonic-gate 			}
8820Sstevel@tonic-gate 			break;
8830Sstevel@tonic-gate 
8840Sstevel@tonic-gate 		case MC_LOCKAS:
8850Sstevel@tonic-gate 		case MC_UNLOCKAS:
8860Sstevel@tonic-gate 			if ((val & ~(MCL_CURRENT|MCL_FUTURE)) == 0) {
8870Sstevel@tonic-gate 				*(s = pri->code_buf) = '\0';
8880Sstevel@tonic-gate 				if (val & MCL_CURRENT)
8890Sstevel@tonic-gate 					(void) strlcat(s, "|MCL_CURRENT",
8904217Seschrock 					    CBSIZE);
8910Sstevel@tonic-gate 				if (val & MCL_FUTURE)
8920Sstevel@tonic-gate 					(void) strlcat(s, "|MCL_FUTURE",
8934217Seschrock 					    CBSIZE);
8940Sstevel@tonic-gate 			}
8950Sstevel@tonic-gate 			break;
8960Sstevel@tonic-gate 		}
8970Sstevel@tonic-gate #undef CBSIZE
8980Sstevel@tonic-gate 
8990Sstevel@tonic-gate 		if (s == NULL || *s == '\0')
9000Sstevel@tonic-gate 			prt_hhx(pri, 0, val);
9010Sstevel@tonic-gate 		else
9020Sstevel@tonic-gate 			outstring(pri, ++s);
9030Sstevel@tonic-gate 	}
9040Sstevel@tonic-gate }
9050Sstevel@tonic-gate 
9060Sstevel@tonic-gate void
9070Sstevel@tonic-gate prt_mc5(private_t *pri, int raw, long val) /* print memcntl() (5th) argument */
9080Sstevel@tonic-gate {
9090Sstevel@tonic-gate 	char *s;
9100Sstevel@tonic-gate 
9110Sstevel@tonic-gate #define	CBSIZE	sizeof (pri->code_buf)
9120Sstevel@tonic-gate 	if (val == 0)
9130Sstevel@tonic-gate 		prt_dec(pri, 0, val);
9140Sstevel@tonic-gate 	else if (raw || (val & ~VALID_ATTR))
9150Sstevel@tonic-gate 		prt_hhx(pri, 0, val);
9160Sstevel@tonic-gate 	else {
9170Sstevel@tonic-gate 		s = pri->code_buf;
9180Sstevel@tonic-gate 		*s = '\0';
9190Sstevel@tonic-gate 		if (val & SHARED)
9200Sstevel@tonic-gate 			(void) strlcat(s, "|SHARED", CBSIZE);
9210Sstevel@tonic-gate 		if (val & PRIVATE)
9220Sstevel@tonic-gate 			(void) strlcat(s, "|PRIVATE", CBSIZE);
9230Sstevel@tonic-gate 		if (val & PROT_READ)
9240Sstevel@tonic-gate 			(void) strlcat(s, "|PROT_READ", CBSIZE);
9250Sstevel@tonic-gate 		if (val & PROT_WRITE)
9260Sstevel@tonic-gate 			(void) strlcat(s, "|PROT_WRITE", CBSIZE);
9270Sstevel@tonic-gate 		if (val & PROT_EXEC)
9280Sstevel@tonic-gate 			(void) strlcat(s, "|PROT_EXEC", CBSIZE);
9290Sstevel@tonic-gate 		if (*s == '\0')
9300Sstevel@tonic-gate 			prt_hhx(pri, 0, val);
9310Sstevel@tonic-gate 		else
9320Sstevel@tonic-gate 			outstring(pri, ++s);
9330Sstevel@tonic-gate 	}
9340Sstevel@tonic-gate #undef CBSIZE
9350Sstevel@tonic-gate }
9360Sstevel@tonic-gate 
9370Sstevel@tonic-gate void
9380Sstevel@tonic-gate prt_ulm(private_t *pri, int raw, long val)	/* print ulimit() argument */
9390Sstevel@tonic-gate {
9400Sstevel@tonic-gate 	const char *s = NULL;
9410Sstevel@tonic-gate 
9420Sstevel@tonic-gate 	if (!raw) {
9430Sstevel@tonic-gate 		switch (val) {
9440Sstevel@tonic-gate 		case UL_GFILLIM:	s = "UL_GFILLIM";	break;
9450Sstevel@tonic-gate 		case UL_SFILLIM:	s = "UL_SFILLIM";	break;
9460Sstevel@tonic-gate 		case UL_GMEMLIM:	s = "UL_GMEMLIM";	break;
9470Sstevel@tonic-gate 		case UL_GDESLIM:	s = "UL_GDESLIM";	break;
9480Sstevel@tonic-gate 		}
9490Sstevel@tonic-gate 	}
9500Sstevel@tonic-gate 
9510Sstevel@tonic-gate 	if (s == NULL)
9520Sstevel@tonic-gate 		prt_dec(pri, 0, val);
9530Sstevel@tonic-gate 	else
9540Sstevel@tonic-gate 		outstring(pri, s);
9550Sstevel@tonic-gate }
9560Sstevel@tonic-gate 
9570Sstevel@tonic-gate void
9580Sstevel@tonic-gate prt_rlm(private_t *pri, int raw, long val) /* print get/setrlimit() argument */
9590Sstevel@tonic-gate {
9600Sstevel@tonic-gate 	const char *s = NULL;
9610Sstevel@tonic-gate 
9620Sstevel@tonic-gate 	if (!raw) {
9630Sstevel@tonic-gate 		switch (val) {
9640Sstevel@tonic-gate 		case RLIMIT_CPU:	s = "RLIMIT_CPU";	break;
9650Sstevel@tonic-gate 		case RLIMIT_FSIZE:	s = "RLIMIT_FSIZE";	break;
9660Sstevel@tonic-gate 		case RLIMIT_DATA:	s = "RLIMIT_DATA";	break;
9670Sstevel@tonic-gate 		case RLIMIT_STACK:	s = "RLIMIT_STACK";	break;
9680Sstevel@tonic-gate 		case RLIMIT_CORE:	s = "RLIMIT_CORE";	break;
9690Sstevel@tonic-gate 		case RLIMIT_NOFILE:	s = "RLIMIT_NOFILE";	break;
9700Sstevel@tonic-gate 		case RLIMIT_VMEM:	s = "RLIMIT_VMEM";	break;
9710Sstevel@tonic-gate 		}
9720Sstevel@tonic-gate 	}
9730Sstevel@tonic-gate 
9740Sstevel@tonic-gate 	if (s == NULL)
9750Sstevel@tonic-gate 		prt_dec(pri, 0, val);
9760Sstevel@tonic-gate 	else
9770Sstevel@tonic-gate 		outstring(pri, s);
9780Sstevel@tonic-gate }
9790Sstevel@tonic-gate 
9800Sstevel@tonic-gate void
9810Sstevel@tonic-gate prt_cnf(private_t *pri, int raw, long val)	/* print sysconfig code */
9820Sstevel@tonic-gate {
9830Sstevel@tonic-gate 	const char *s = raw? NULL : sconfname(val);
9840Sstevel@tonic-gate 
9850Sstevel@tonic-gate 	if (s == NULL)
9860Sstevel@tonic-gate 		prt_dec(pri, 0, val);
9870Sstevel@tonic-gate 	else
9880Sstevel@tonic-gate 		outstring(pri, s);
9890Sstevel@tonic-gate }
9900Sstevel@tonic-gate 
9910Sstevel@tonic-gate void
9920Sstevel@tonic-gate prt_inf(private_t *pri, int raw, long val)	/* print sysinfo code */
9930Sstevel@tonic-gate {
9940Sstevel@tonic-gate 	const char *s = NULL;
9950Sstevel@tonic-gate 
9960Sstevel@tonic-gate 	if (!raw) {
9970Sstevel@tonic-gate 		switch (val) {
9980Sstevel@tonic-gate 		case SI_SYSNAME:	s = "SI_SYSNAME";	break;
9990Sstevel@tonic-gate 		case SI_HOSTNAME:	s = "SI_HOSTNAME";	break;
10000Sstevel@tonic-gate 		case SI_RELEASE:	s = "SI_RELEASE";	break;
10010Sstevel@tonic-gate 		case SI_VERSION:	s = "SI_VERSION";	break;
10020Sstevel@tonic-gate 		case SI_MACHINE:	s = "SI_MACHINE";	break;
10030Sstevel@tonic-gate 		case SI_ARCHITECTURE:	s = "SI_ARCHITECTURE";	break;
10040Sstevel@tonic-gate 		case SI_ARCHITECTURE_32:s = "SI_ARCHITECTURE_32"; break;
10050Sstevel@tonic-gate 		case SI_ARCHITECTURE_64:s = "SI_ARCHITECTURE_64"; break;
10060Sstevel@tonic-gate 		case SI_ARCHITECTURE_K:	s = "SI_ARCHITECTURE_K"; break;
10070Sstevel@tonic-gate 		case SI_HW_SERIAL:	s = "SI_HW_SERIAL";	break;
10080Sstevel@tonic-gate 		case SI_HW_PROVIDER:	s = "SI_HW_PROVIDER";	break;
10090Sstevel@tonic-gate 		case SI_SRPC_DOMAIN:	s = "SI_SRPC_DOMAIN";	break;
10100Sstevel@tonic-gate 		case SI_SET_HOSTNAME:	s = "SI_SET_HOSTNAME";	break;
10110Sstevel@tonic-gate 		case SI_SET_SRPC_DOMAIN: s = "SI_SET_SRPC_DOMAIN"; break;
10120Sstevel@tonic-gate 		case SI_PLATFORM:	s = "SI_PLATFORM";	break;
10130Sstevel@tonic-gate 		case SI_ISALIST:	s = "SI_ISALIST";	break;
10140Sstevel@tonic-gate 		case SI_DHCP_CACHE:	s = "SI_DHCP_CACHE";	break;
10150Sstevel@tonic-gate 		}
10160Sstevel@tonic-gate 	}
10170Sstevel@tonic-gate 
10180Sstevel@tonic-gate 	if (s == NULL)
10190Sstevel@tonic-gate 		prt_dec(pri, 0, val);
10200Sstevel@tonic-gate 	else
10210Sstevel@tonic-gate 		outstring(pri, s);
10220Sstevel@tonic-gate }
10230Sstevel@tonic-gate 
10240Sstevel@tonic-gate void
10250Sstevel@tonic-gate prt_ptc(private_t *pri, int raw, long val)	/* print pathconf code */
10260Sstevel@tonic-gate {
10270Sstevel@tonic-gate 	const char *s = raw? NULL : pathconfname(val);
10280Sstevel@tonic-gate 
10290Sstevel@tonic-gate 	if (s == NULL)
10300Sstevel@tonic-gate 		prt_dec(pri, 0, val);
10310Sstevel@tonic-gate 	else
10320Sstevel@tonic-gate 		outstring(pri, s);
10330Sstevel@tonic-gate }
10340Sstevel@tonic-gate 
10350Sstevel@tonic-gate void
10360Sstevel@tonic-gate prt_fui(private_t *pri, int raw, long val) /* print fusers() input argument */
10370Sstevel@tonic-gate {
10380Sstevel@tonic-gate 	const char *s = raw? NULL : fuiname(val);
10390Sstevel@tonic-gate 
10400Sstevel@tonic-gate 	if (s == NULL)
10410Sstevel@tonic-gate 		prt_hhx(pri, 0, val);
10420Sstevel@tonic-gate 	else
10430Sstevel@tonic-gate 		outstring(pri, s);
10440Sstevel@tonic-gate }
10450Sstevel@tonic-gate 
10460Sstevel@tonic-gate void
10470Sstevel@tonic-gate prt_lwf(private_t *pri, int raw, long val)	/* print lwp_create() flags */
10480Sstevel@tonic-gate {
10490Sstevel@tonic-gate 	char *s;
10500Sstevel@tonic-gate 
10510Sstevel@tonic-gate 	if (val == 0)
10520Sstevel@tonic-gate 		prt_dec(pri, 0, val);
10530Sstevel@tonic-gate 	else if (raw ||
10540Sstevel@tonic-gate 	    (val & ~(LWP_DAEMON|LWP_DETACHED|LWP_SUSPENDED)))
10550Sstevel@tonic-gate 		prt_hhx(pri, 0, val);
10560Sstevel@tonic-gate 	else {
10570Sstevel@tonic-gate #define	CBSIZE	sizeof (pri->code_buf)
10580Sstevel@tonic-gate 		s = pri->code_buf;
10590Sstevel@tonic-gate 		*s = '\0';
10600Sstevel@tonic-gate 		if (val & LWP_DAEMON)
10610Sstevel@tonic-gate 			(void) strlcat(s, "|LWP_DAEMON", CBSIZE);
10620Sstevel@tonic-gate 		if (val & LWP_DETACHED)
10630Sstevel@tonic-gate 			(void) strlcat(s, "|LWP_DETACHED", CBSIZE);
10640Sstevel@tonic-gate 		if (val & LWP_SUSPENDED)
10650Sstevel@tonic-gate 			(void) strlcat(s, "|LWP_SUSPENDED", CBSIZE);
10660Sstevel@tonic-gate 		outstring(pri, ++s);
10670Sstevel@tonic-gate #undef CBSIZE
10680Sstevel@tonic-gate 	}
10690Sstevel@tonic-gate }
10700Sstevel@tonic-gate 
10710Sstevel@tonic-gate void
10720Sstevel@tonic-gate prt_itm(private_t *pri, int raw, long val) /* print [get|set]itimer() arg */
10730Sstevel@tonic-gate {
10740Sstevel@tonic-gate 	const char *s = NULL;
10750Sstevel@tonic-gate 
10760Sstevel@tonic-gate 	if (!raw) {
10770Sstevel@tonic-gate 		switch (val) {
10780Sstevel@tonic-gate 		case ITIMER_REAL:	s = "ITIMER_REAL";	break;
10790Sstevel@tonic-gate 		case ITIMER_VIRTUAL:	s = "ITIMER_VIRTUAL";	break;
10800Sstevel@tonic-gate 		case ITIMER_PROF:	s = "ITIMER_PROF";	break;
10810Sstevel@tonic-gate #ifdef ITIMER_REALPROF
10820Sstevel@tonic-gate 		case ITIMER_REALPROF:	s = "ITIMER_REALPROF";	break;
10830Sstevel@tonic-gate #endif
10840Sstevel@tonic-gate 		}
10850Sstevel@tonic-gate 	}
10860Sstevel@tonic-gate 
10870Sstevel@tonic-gate 	if (s == NULL)
10880Sstevel@tonic-gate 		prt_dec(pri, 0, val);
10890Sstevel@tonic-gate 	else
10900Sstevel@tonic-gate 		outstring(pri, s);
10910Sstevel@tonic-gate }
10920Sstevel@tonic-gate 
10930Sstevel@tonic-gate void
10940Sstevel@tonic-gate prt_mod(private_t *pri, int raw, long val)	/* print modctl() code */
10950Sstevel@tonic-gate {
10960Sstevel@tonic-gate 	const char *s = NULL;
10970Sstevel@tonic-gate 
10980Sstevel@tonic-gate 	if (!raw) {
10990Sstevel@tonic-gate 		switch (val) {
11000Sstevel@tonic-gate 		case MODLOAD:		s = "MODLOAD";		break;
11010Sstevel@tonic-gate 		case MODUNLOAD:		s = "MODUNLOAD";	break;
11020Sstevel@tonic-gate 		case MODINFO:		s = "MODINFO";		break;
11030Sstevel@tonic-gate 		case MODRESERVED:	s = "MODRESERVED";	break;
11040Sstevel@tonic-gate 		case MODSETMINIROOT:	s = "MODSETMINIROOT";	break;
11050Sstevel@tonic-gate 		case MODADDMAJBIND:	s = "MODADDMAJBIND";	break;
11060Sstevel@tonic-gate 		case MODGETPATH:	s = "MODGETPATH";	break;
11070Sstevel@tonic-gate 		case MODGETPATHLEN:	s = "MODGETPATHLEN";	break;
11080Sstevel@tonic-gate 		case MODREADSYSBIND:	s = "MODREADSYSBIND";	break;
11090Sstevel@tonic-gate 		case MODGETMAJBIND:	s = "MODGETMAJBIND";	break;
11100Sstevel@tonic-gate 		case MODGETNAME:	s = "MODGETNAME";	break;
11110Sstevel@tonic-gate 		case MODSIZEOF_DEVID:	s = "MODSIZEOF_DEVID";	break;
11120Sstevel@tonic-gate 		case MODGETDEVID:	s = "MODGETDEVID";	break;
11130Sstevel@tonic-gate 		case MODSIZEOF_MINORNAME: s = "MODSIZEOF_MINORNAME"; break;
11140Sstevel@tonic-gate 		case MODGETMINORNAME:	s = "MODGETMINORNAME";	break;
11150Sstevel@tonic-gate 		case MODGETFBNAME:	s = "MODGETFBNAME";	break;
11160Sstevel@tonic-gate 		case MODEVENTS:		s = "MODEVENTS";	break;
11170Sstevel@tonic-gate 		case MODREREADDACF:	s = "MODREREADDACF";	break;
11180Sstevel@tonic-gate 		case MODLOADDRVCONF:	s = "MODLOADDRVCONF";	break;
11190Sstevel@tonic-gate 		case MODUNLOADDRVCONF:	s = "MODUNLOADDRVCONF";	break;
11200Sstevel@tonic-gate 		case MODREMMAJBIND:	s = "MODREMMAJBIND";	break;
11210Sstevel@tonic-gate 		case MODDEVT2INSTANCE:	s = "MODDEVT2INSTANCE";	break;
11220Sstevel@tonic-gate 		case MODGETDEVFSPATH_LEN: s = "MODGETDEVFSPATH_LEN"; break;
11230Sstevel@tonic-gate 		case MODGETDEVFSPATH:	s = "MODGETDEVFSPATH";	break;
11240Sstevel@tonic-gate 		case MODDEVID2PATHS:	s = "MODDEVID2PATHS";	break;
11250Sstevel@tonic-gate 		case MODSETDEVPOLICY:	s = "MODSETDEVPOLICY";	break;
11260Sstevel@tonic-gate 		case MODGETDEVPOLICY:	s = "MODGETDEVPOLICY";	break;
11270Sstevel@tonic-gate 		case MODALLOCPRIV:	s = "MODALLOCPRIV";	break;
11280Sstevel@tonic-gate 		case MODGETDEVPOLICYBYNAME:
11290Sstevel@tonic-gate 					s = "MODGETDEVPOLICYBYNAME"; break;
11300Sstevel@tonic-gate 		case MODLOADMINORPERM:	s = "MODLOADMINORPERM"; break;
11310Sstevel@tonic-gate 		case MODADDMINORPERM:	s = "MODADDMINORPERM"; break;
11320Sstevel@tonic-gate 		case MODREMMINORPERM:	s = "MODREMMINORPERM"; break;
11330Sstevel@tonic-gate 		case MODREMDRVCLEANUP:	s = "MODREMDRVCLEANUP"; break;
11342621Sllai1 		case MODDEVEXISTS:	s = "MODDEVEXISTS"; break;
11352621Sllai1 		case MODDEVREADDIR:	s = "MODDEVREADDIR"; break;
11366065Scth 		case MODDEVEMPTYDIR:	s = "MODDEVEMPTYDIR"; break;
11372621Sllai1 		case MODDEVNAME:	s = "MODDEVNAME"; break;
11382723Scth 		case MODGETDEVFSPATH_MI_LEN:
11392723Scth 					s = "MODGETDEVFSPATH_MI_LEN"; break;
11402723Scth 		case MODGETDEVFSPATH_MI:
11412723Scth 					s = "MODGETDEVFSPATH_MI"; break;
11428831SJerry.Gilliam@Sun.COM 		case MODREMDRVALIAS:	s = "MODREMDRVALIAS"; break;
11430Sstevel@tonic-gate 		}
11440Sstevel@tonic-gate 	}
11450Sstevel@tonic-gate 
11460Sstevel@tonic-gate 	if (s == NULL)
11470Sstevel@tonic-gate 		prt_dec(pri, 0, val);
11480Sstevel@tonic-gate 	else
11490Sstevel@tonic-gate 		outstring(pri, s);
11500Sstevel@tonic-gate }
11510Sstevel@tonic-gate 
11520Sstevel@tonic-gate void
11530Sstevel@tonic-gate prt_acl(private_t *pri, int raw, long val)	/* print acl() code */
11540Sstevel@tonic-gate {
11550Sstevel@tonic-gate 	const char *s = NULL;
11560Sstevel@tonic-gate 
11570Sstevel@tonic-gate 	if (!raw) {
11580Sstevel@tonic-gate 		switch (val) {
11590Sstevel@tonic-gate 		case GETACL:		s = "GETACL";		break;
11600Sstevel@tonic-gate 		case SETACL:		s = "SETACL";		break;
11610Sstevel@tonic-gate 		case GETACLCNT:		s = "GETACLCNT";	break;
1162789Sahrens 		case ACE_GETACL:	s = "ACE_GETACL";	break;
1163789Sahrens 		case ACE_SETACL:	s = "ACE_SETACL";	break;
1164789Sahrens 		case ACE_GETACLCNT:	s = "ACE_GETACLCNT";	break;
11650Sstevel@tonic-gate 		}
11660Sstevel@tonic-gate 	}
11670Sstevel@tonic-gate 
11680Sstevel@tonic-gate 	if (s == NULL)
11690Sstevel@tonic-gate 		prt_dec(pri, 0, val);
11700Sstevel@tonic-gate 	else
11710Sstevel@tonic-gate 		outstring(pri, s);
11720Sstevel@tonic-gate }
11730Sstevel@tonic-gate 
11740Sstevel@tonic-gate void
11750Sstevel@tonic-gate prt_aio(private_t *pri, int raw, long val)	/* print kaio() code */
11760Sstevel@tonic-gate {
11770Sstevel@tonic-gate 	const char *s = NULL;
11780Sstevel@tonic-gate 	char buf[32];
11790Sstevel@tonic-gate 
11800Sstevel@tonic-gate 	if (!raw) {
11810Sstevel@tonic-gate 		switch (val & ~AIO_POLL_BIT) {
11820Sstevel@tonic-gate 		case AIOREAD:		s = "AIOREAD";		break;
11830Sstevel@tonic-gate 		case AIOWRITE:		s = "AIOWRITE";		break;
11840Sstevel@tonic-gate 		case AIOWAIT:		s = "AIOWAIT";		break;
11850Sstevel@tonic-gate 		case AIOCANCEL:		s = "AIOCANCEL";	break;
11860Sstevel@tonic-gate 		case AIONOTIFY:		s = "AIONOTIFY";	break;
11870Sstevel@tonic-gate 		case AIOINIT:		s = "AIOINIT";		break;
11880Sstevel@tonic-gate 		case AIOSTART:		s = "AIOSTART";		break;
11890Sstevel@tonic-gate 		case AIOLIO:		s = "AIOLIO";		break;
11900Sstevel@tonic-gate 		case AIOSUSPEND:	s = "AIOSUSPEND";	break;
11910Sstevel@tonic-gate 		case AIOERROR:		s = "AIOERROR";		break;
11920Sstevel@tonic-gate 		case AIOLIOWAIT:	s = "AIOLIOWAIT";	break;
11930Sstevel@tonic-gate 		case AIOAREAD:		s = "AIOAREAD";		break;
11940Sstevel@tonic-gate 		case AIOAWRITE:		s = "AIOAWRITE";	break;
11950Sstevel@tonic-gate 		/*
11960Sstevel@tonic-gate 		 * We have to hardcode the values for the 64-bit versions of
11970Sstevel@tonic-gate 		 * these calls, because <sys/aio.h> defines them to be identical
11980Sstevel@tonic-gate 		 * when compiled 64-bit.  If our target is 32-bit, we still need
11990Sstevel@tonic-gate 		 * to decode them correctly.
12000Sstevel@tonic-gate 		 */
12010Sstevel@tonic-gate 		case 13:		s = "AIOLIO64";		break;
12020Sstevel@tonic-gate 		case 14:		s = "AIOSUSPEND64";	break;
12030Sstevel@tonic-gate 		case 15:		s = "AUIOERROR64";	break;
12040Sstevel@tonic-gate 		case 16:		s = "AIOLIOWAIT64";	break;
12050Sstevel@tonic-gate 		case 17:		s = "AIOAREAD64";	break;
12060Sstevel@tonic-gate 		case 18:		s = "AIOAWRITE64";	break;
12070Sstevel@tonic-gate 		case 19:		s = "AIOCANCEL64";	break;
12080Sstevel@tonic-gate 
12090Sstevel@tonic-gate 		/*
12100Sstevel@tonic-gate 		 * AIOFSYNC doesn't correspond to a syscall.
12110Sstevel@tonic-gate 		 */
12120Sstevel@tonic-gate 		case AIOWAITN:		s = "AIOWAITN";		break;
12130Sstevel@tonic-gate 		}
12140Sstevel@tonic-gate 		if (s != NULL && (val & AIO_POLL_BIT)) {
12150Sstevel@tonic-gate 			(void) strlcpy(buf, s, sizeof (buf));
12160Sstevel@tonic-gate 			(void) strlcat(buf, "|AIO_POLL_BIT", sizeof (buf));
12170Sstevel@tonic-gate 			s = (const char *)buf;
12180Sstevel@tonic-gate 		}
12190Sstevel@tonic-gate 	}
12200Sstevel@tonic-gate 
12210Sstevel@tonic-gate 	if (s == NULL)
12220Sstevel@tonic-gate 		prt_dec(pri, 0, val);
12230Sstevel@tonic-gate 	else
12240Sstevel@tonic-gate 		outstring(pri, s);
12250Sstevel@tonic-gate }
12260Sstevel@tonic-gate 
12270Sstevel@tonic-gate void
12280Sstevel@tonic-gate prt_aud(private_t *pri, int raw, long val)	/* print auditsys() code */
12290Sstevel@tonic-gate {
12300Sstevel@tonic-gate 	const char *s = NULL;
12310Sstevel@tonic-gate 
12320Sstevel@tonic-gate 	if (!raw) {
12330Sstevel@tonic-gate 		switch (val) {
12340Sstevel@tonic-gate 		case BSM_GETAUID:	s = "BSM_GETAUID";	break;
12350Sstevel@tonic-gate 		case BSM_SETAUID:	s = "BSM_SETAUID";	break;
12360Sstevel@tonic-gate 		case BSM_GETAUDIT:	s = "BSM_GETAUDIT";	break;
12370Sstevel@tonic-gate 		case BSM_SETAUDIT:	s = "BSM_SETAUDIT";	break;
12380Sstevel@tonic-gate 		case BSM_AUDIT:		s = "BSM_AUDIT";	break;
12390Sstevel@tonic-gate 		case BSM_AUDITON:	s = "BSM_AUDITON";	break;
12400Sstevel@tonic-gate 		case BSM_AUDITCTL:	s = "BSM_AUDITCTL";	break;
12410Sstevel@tonic-gate 		case BSM_GETAUDIT_ADDR:	s = "BSM_GETAUDIT_ADDR"; break;
12420Sstevel@tonic-gate 		case BSM_SETAUDIT_ADDR:	s = "BSM_SETAUDIT_ADDR"; break;
12430Sstevel@tonic-gate 		}
12440Sstevel@tonic-gate 	}
12450Sstevel@tonic-gate 
12460Sstevel@tonic-gate 	if (s == NULL)
12470Sstevel@tonic-gate 		prt_dec(pri, 0, val);
12480Sstevel@tonic-gate 	else
12490Sstevel@tonic-gate 		outstring(pri, s);
12500Sstevel@tonic-gate }
12510Sstevel@tonic-gate 
12520Sstevel@tonic-gate void
12530Sstevel@tonic-gate prt_cor(private_t *pri, int raw, long val)	/* print corectl() subcode */
12540Sstevel@tonic-gate {
12550Sstevel@tonic-gate 	const char *s = NULL;
12560Sstevel@tonic-gate 
12570Sstevel@tonic-gate 	if (!raw) {
12580Sstevel@tonic-gate 		switch (val) {
12590Sstevel@tonic-gate 		case CC_SET_OPTIONS:
12600Sstevel@tonic-gate 			s = "CC_SET_OPTIONS";		break;
12610Sstevel@tonic-gate 		case CC_GET_OPTIONS:
12620Sstevel@tonic-gate 			s = "CC_GET_OPTIONS";		break;
12630Sstevel@tonic-gate 		case CC_SET_GLOBAL_PATH:
12640Sstevel@tonic-gate 			s = "CC_SET_GLOBAL_PATH";	break;
12650Sstevel@tonic-gate 		case CC_GET_GLOBAL_PATH:
12660Sstevel@tonic-gate 			s = "CC_GET_GLOBAL_PATH";	break;
12670Sstevel@tonic-gate 		case CC_SET_PROCESS_PATH:
12680Sstevel@tonic-gate 			s = "CC_SET_PROCESS_PATH";	break;
12690Sstevel@tonic-gate 		case CC_GET_PROCESS_PATH:
12700Sstevel@tonic-gate 			s = "CC_GET_PROCESS_PATH";	break;
12710Sstevel@tonic-gate 		case CC_SET_GLOBAL_CONTENT:
12720Sstevel@tonic-gate 			s = "CC_SET_GLOBAL_CONTENT";	break;
12730Sstevel@tonic-gate 		case CC_GET_GLOBAL_CONTENT:
12740Sstevel@tonic-gate 			s = "CC_GET_GLOBAL_CONTENT";	break;
12750Sstevel@tonic-gate 		case CC_SET_PROCESS_CONTENT:
12760Sstevel@tonic-gate 			s = "CC_SET_PROCESS_CONTENT";	break;
12770Sstevel@tonic-gate 		case CC_GET_PROCESS_CONTENT:
12780Sstevel@tonic-gate 			s = "CC_GET_PROCESS_CONTENT";	break;
12790Sstevel@tonic-gate 		case CC_SET_DEFAULT_PATH:
12800Sstevel@tonic-gate 			s = "CC_SET_DEFAULT_PATH";	break;
12810Sstevel@tonic-gate 		case CC_GET_DEFAULT_PATH:
12820Sstevel@tonic-gate 			s = "CC_GET_DEFAULT_PATH";	break;
12830Sstevel@tonic-gate 		case CC_SET_DEFAULT_CONTENT:
12840Sstevel@tonic-gate 			s = "CC_SET_DEFAULT_CONTENT";	break;
12850Sstevel@tonic-gate 		case CC_GET_DEFAULT_CONTENT:
12860Sstevel@tonic-gate 			s = "CC_GET_DEFAULT_CONTENT";	break;
12870Sstevel@tonic-gate 		}
12880Sstevel@tonic-gate 	}
12890Sstevel@tonic-gate 
12900Sstevel@tonic-gate 	if (s == NULL)
12910Sstevel@tonic-gate 		prt_dec(pri, 0, val);
12920Sstevel@tonic-gate 	else
12930Sstevel@tonic-gate 		outstring(pri, s);
12940Sstevel@tonic-gate }
12950Sstevel@tonic-gate 
12960Sstevel@tonic-gate void
12970Sstevel@tonic-gate prt_cco(private_t *pri, int raw, long val)	/* print corectl() options */
12980Sstevel@tonic-gate {
12990Sstevel@tonic-gate 	char *s;
13000Sstevel@tonic-gate 
13010Sstevel@tonic-gate 	if (val == 0)
13020Sstevel@tonic-gate 		prt_dec(pri, 0, val);
13030Sstevel@tonic-gate 	else if (raw || (val & ~CC_OPTIONS))
13040Sstevel@tonic-gate 		prt_hhx(pri, 0, val);
13050Sstevel@tonic-gate 	else {
13060Sstevel@tonic-gate #define	CBSIZE	sizeof (pri->code_buf)
13070Sstevel@tonic-gate 		s = pri->code_buf;
13080Sstevel@tonic-gate 		*s = '\0';
13090Sstevel@tonic-gate 		if (val & CC_GLOBAL_PATH)
13100Sstevel@tonic-gate 			(void) strlcat(s, "|CC_GLOBAL_PATH", CBSIZE);
13110Sstevel@tonic-gate 		if (val & CC_PROCESS_PATH)
13120Sstevel@tonic-gate 			(void) strlcat(s, "|CC_PROCESS_PATH", CBSIZE);
13130Sstevel@tonic-gate 		if (val & CC_GLOBAL_SETID)
13140Sstevel@tonic-gate 			(void) strlcat(s, "|CC_GLOBAL_SETID", CBSIZE);
13150Sstevel@tonic-gate 		if (val & CC_PROCESS_SETID)
13160Sstevel@tonic-gate 			(void) strlcat(s, "|CC_PROCESS_SETID", CBSIZE);
13170Sstevel@tonic-gate 		if (val & CC_GLOBAL_LOG)
13180Sstevel@tonic-gate 			(void) strlcat(s, "|CC_GLOBAL_LOG", CBSIZE);
13190Sstevel@tonic-gate 		if (*s == '\0')
13200Sstevel@tonic-gate 			prt_hhx(pri, 0, val);
13210Sstevel@tonic-gate 		else
13220Sstevel@tonic-gate 			outstring(pri, ++s);
13230Sstevel@tonic-gate #undef CBSIZE
13240Sstevel@tonic-gate 	}
13250Sstevel@tonic-gate }
13260Sstevel@tonic-gate 
13270Sstevel@tonic-gate void
13280Sstevel@tonic-gate prt_ccc(private_t *pri, int raw, long val)	/* print corectl() content */
13290Sstevel@tonic-gate {
13300Sstevel@tonic-gate 	core_content_t ccc;
13310Sstevel@tonic-gate 
13320Sstevel@tonic-gate 	if (Pread(Proc, &ccc, sizeof (ccc), val) != sizeof (ccc))
13330Sstevel@tonic-gate 		prt_hex(pri, 0, val);
13340Sstevel@tonic-gate 	else if (!raw && proc_content2str(ccc, pri->code_buf,
13350Sstevel@tonic-gate 	    sizeof (pri->code_buf)) >= 0)
13360Sstevel@tonic-gate 		outstring(pri, pri->code_buf);
13370Sstevel@tonic-gate 	else
13380Sstevel@tonic-gate 		prt_hhx(pri, 0, (long)ccc);
13390Sstevel@tonic-gate }
13400Sstevel@tonic-gate 
13410Sstevel@tonic-gate void
13420Sstevel@tonic-gate prt_rcc(private_t *pri, int raw, long val)	/* print corectl() ret. cont. */
13430Sstevel@tonic-gate {
13440Sstevel@tonic-gate 	core_content_t ccc;
13450Sstevel@tonic-gate 
13460Sstevel@tonic-gate 	if (pri->Errno || Pread(Proc, &ccc, sizeof (ccc), val) != sizeof (ccc))
13470Sstevel@tonic-gate 		prt_hex(pri, 0, val);
13480Sstevel@tonic-gate 	else if (!raw && proc_content2str(ccc, pri->code_buf,
13490Sstevel@tonic-gate 	    sizeof (pri->code_buf)) >= 0)
13500Sstevel@tonic-gate 		outstring(pri, pri->code_buf);
13510Sstevel@tonic-gate 	else
13520Sstevel@tonic-gate 		prt_hhx(pri, 0, (long)ccc);
13530Sstevel@tonic-gate }
13540Sstevel@tonic-gate 
13550Sstevel@tonic-gate void
13560Sstevel@tonic-gate prt_cpc(private_t *pri, int raw, long val)	/* print cpc() subcode */
13570Sstevel@tonic-gate {
13580Sstevel@tonic-gate 	const char *s = NULL;
13590Sstevel@tonic-gate 
13600Sstevel@tonic-gate 	if (!raw) {
13610Sstevel@tonic-gate 		switch (val) {
13620Sstevel@tonic-gate 		case CPC_BIND:		s = "CPC_BIND";		break;
13630Sstevel@tonic-gate 		case CPC_SAMPLE:	s = "CPC_SAMPLE";	break;
13640Sstevel@tonic-gate 		case CPC_INVALIDATE:	s = "CPC_INVALIDATE";	break;
13650Sstevel@tonic-gate 		case CPC_RELE:		s = "CPC_RELE";		break;
13660Sstevel@tonic-gate 		case CPC_EVLIST_SIZE:	s = "CPC_EVLIST_SIZE";	break;
13670Sstevel@tonic-gate 		case CPC_LIST_EVENTS:	s = "CPC_LIST_EVENTS";	break;
13680Sstevel@tonic-gate 		case CPC_ATTRLIST_SIZE:	s = "CPC_ATTRLIST_SIZE"; break;
13690Sstevel@tonic-gate 		case CPC_LIST_ATTRS:	s = "CPC_LIST_ATTRS";	break;
13700Sstevel@tonic-gate 		case CPC_IMPL_NAME:	s = "CPC_IMPL_NAME";	break;
13710Sstevel@tonic-gate 		case CPC_CPUREF:	s = "CPC_CPUREF";	break;
13720Sstevel@tonic-gate 		case CPC_USR_EVENTS:	s = "CPC_USR_EVENTS";	break;
13730Sstevel@tonic-gate 		case CPC_SYS_EVENTS:	s = "CPC_SYS_EVENTS";	break;
13740Sstevel@tonic-gate 		case CPC_NPIC:		s = "CPC_NPIC";		break;
13750Sstevel@tonic-gate 		case CPC_CAPS:		s = "CPC_CAPS";		break;
13760Sstevel@tonic-gate 		case CPC_ENABLE:	s = "CPC_ENABLE";	break;
13770Sstevel@tonic-gate 		case CPC_DISABLE:	s = "CPC_DISABLE";	break;
13780Sstevel@tonic-gate 		}
13790Sstevel@tonic-gate 	}
13800Sstevel@tonic-gate 
13810Sstevel@tonic-gate 	if (s == NULL)
13820Sstevel@tonic-gate 		prt_dec(pri, 0, val);
13830Sstevel@tonic-gate 	else
13840Sstevel@tonic-gate 		outstring(pri, s);
13850Sstevel@tonic-gate }
13860Sstevel@tonic-gate 
13870Sstevel@tonic-gate void
13880Sstevel@tonic-gate outstring(private_t *pri, const char *s)
13890Sstevel@tonic-gate {
13900Sstevel@tonic-gate 	int len = strlen(s);
13910Sstevel@tonic-gate 
13920Sstevel@tonic-gate 	GROW(len);
13930Sstevel@tonic-gate 	(void) strcpy(pri->sys_string + pri->sys_leng, s);
13940Sstevel@tonic-gate 	pri->sys_leng += len;
13950Sstevel@tonic-gate }
13960Sstevel@tonic-gate 
13970Sstevel@tonic-gate void
13980Sstevel@tonic-gate grow(private_t *pri, int nbyte)	/* reallocate format buffer if necessary */
13990Sstevel@tonic-gate {
14000Sstevel@tonic-gate 	while (pri->sys_leng + nbyte >= pri->sys_ssize)
14010Sstevel@tonic-gate 		pri->sys_string = my_realloc(pri->sys_string,
14024217Seschrock 		    pri->sys_ssize *= 2, "format buffer");
14030Sstevel@tonic-gate }
14040Sstevel@tonic-gate 
14050Sstevel@tonic-gate void
14060Sstevel@tonic-gate prt_clc(private_t *pri, int raw, long val)
14070Sstevel@tonic-gate {
14080Sstevel@tonic-gate 	const char *s = NULL;
14090Sstevel@tonic-gate 
14100Sstevel@tonic-gate 	if (!raw) {
14110Sstevel@tonic-gate 		switch (val) {
14120Sstevel@tonic-gate 		case CL_INITIALIZE:	s = "CL_INITIALIZE";	break;
14130Sstevel@tonic-gate 		case CL_CONFIG:		s = "CL_CONFIG";	break;
14140Sstevel@tonic-gate 		}
14150Sstevel@tonic-gate 	}
14160Sstevel@tonic-gate 
14170Sstevel@tonic-gate 	if (s == NULL)
14180Sstevel@tonic-gate 		prt_dec(pri, 0, val);
14190Sstevel@tonic-gate 	else
14200Sstevel@tonic-gate 		outstring(pri, s);
14210Sstevel@tonic-gate }
14220Sstevel@tonic-gate 
14230Sstevel@tonic-gate void
14240Sstevel@tonic-gate prt_clf(private_t *pri, int raw, long val)
14250Sstevel@tonic-gate {
14260Sstevel@tonic-gate 	const char *s = NULL;
14270Sstevel@tonic-gate 
14280Sstevel@tonic-gate 	if (!raw) {
14290Sstevel@tonic-gate 		switch (pri->sys_args[0]) {
14300Sstevel@tonic-gate 		case CL_CONFIG:
14310Sstevel@tonic-gate 			switch (pri->sys_args[1]) {
14320Sstevel@tonic-gate 			case CL_NODEID:
14330Sstevel@tonic-gate 				s = "CL_NODEID";		break;
14340Sstevel@tonic-gate 			case CL_HIGHEST_NODEID:
14350Sstevel@tonic-gate 				s = "CL_HIGHEST_NODEID";	break;
14360Sstevel@tonic-gate 			}
14370Sstevel@tonic-gate 			break;
14380Sstevel@tonic-gate 		case CL_INITIALIZE:
14390Sstevel@tonic-gate 			switch (pri->sys_args[1]) {
14400Sstevel@tonic-gate 			case CL_GET_BOOTFLAG:
14410Sstevel@tonic-gate 				s = "CL_GET_BOOTFLAG";		break;
14420Sstevel@tonic-gate 			}
14430Sstevel@tonic-gate 			break;
14440Sstevel@tonic-gate 		}
14450Sstevel@tonic-gate 	}
14460Sstevel@tonic-gate 
14470Sstevel@tonic-gate 	if (s == NULL)
14480Sstevel@tonic-gate 		prt_dec(pri, 0, val);
14490Sstevel@tonic-gate 	else
14500Sstevel@tonic-gate 		outstring(pri, s);
14510Sstevel@tonic-gate }
14520Sstevel@tonic-gate 
14530Sstevel@tonic-gate void
14540Sstevel@tonic-gate prt_sqc(private_t *pri, int raw, long val)	/* print sigqueue() si_code */
14550Sstevel@tonic-gate {
14560Sstevel@tonic-gate 	const char *s = NULL;
14570Sstevel@tonic-gate 
14580Sstevel@tonic-gate 	if (!raw) {
14590Sstevel@tonic-gate 		switch ((int)val) {
14600Sstevel@tonic-gate 		case SI_QUEUE:		s = "SI_QUEUE";		break;
14610Sstevel@tonic-gate 		case SI_TIMER:		s = "SI_TIMER";		break;
14620Sstevel@tonic-gate 		case SI_ASYNCIO:	s = "SI_ASYNCIO";	break;
14630Sstevel@tonic-gate 		case SI_MESGQ:		s = "SI_MESGQ";		break;
14640Sstevel@tonic-gate 		}
14650Sstevel@tonic-gate 	}
14660Sstevel@tonic-gate 
14670Sstevel@tonic-gate 	if (s == NULL)
14680Sstevel@tonic-gate 		prt_dec(pri, 0, val);
14690Sstevel@tonic-gate 	else
14700Sstevel@tonic-gate 		outstring(pri, s);
14710Sstevel@tonic-gate }
14720Sstevel@tonic-gate 
14730Sstevel@tonic-gate /*
14740Sstevel@tonic-gate  * print priocntlsys() (key, value) pair key.
14750Sstevel@tonic-gate  */
14760Sstevel@tonic-gate void
14770Sstevel@tonic-gate print_pck(private_t *pri, int raw, long val)
14780Sstevel@tonic-gate {
14790Sstevel@tonic-gate 	const char	*s = NULL;
14800Sstevel@tonic-gate 	char		clname[PC_CLNMSZ];
14810Sstevel@tonic-gate 
14820Sstevel@tonic-gate 	if ((pri->sys_args[2] != PC_GETXPARMS &&
14830Sstevel@tonic-gate 	    pri->sys_args[2] != PC_SETXPARMS) || val == 0 || raw) {
14840Sstevel@tonic-gate 		prt_dec(pri, 0, val);
14850Sstevel@tonic-gate 		return;
14860Sstevel@tonic-gate 	}
14870Sstevel@tonic-gate 
14880Sstevel@tonic-gate 	if (pri->sys_args[3] == NULL) {
14890Sstevel@tonic-gate 		if (val == PC_KY_CLNAME) {
14900Sstevel@tonic-gate 			s = "PC_KY_CLNAME";
14910Sstevel@tonic-gate 			outstring(pri, s);
14920Sstevel@tonic-gate 		} else
14930Sstevel@tonic-gate 			prt_dec(pri, 0, val);
14940Sstevel@tonic-gate 		return;
14950Sstevel@tonic-gate 	}
14960Sstevel@tonic-gate 
14970Sstevel@tonic-gate 	if (Pread(Proc, &clname, PC_CLNMSZ, pri->sys_args[3]) != PC_CLNMSZ) {
14980Sstevel@tonic-gate 		prt_dec(pri, 0, val);
14990Sstevel@tonic-gate 		return;
15000Sstevel@tonic-gate 	}
15010Sstevel@tonic-gate 
15020Sstevel@tonic-gate 	if (strcmp(clname, "TS") == 0) {
15030Sstevel@tonic-gate 		switch (val) {
15040Sstevel@tonic-gate 		case TS_KY_UPRILIM: 	s = "TS_KY_UPRILIM";	break;
15050Sstevel@tonic-gate 		case TS_KY_UPRI:	s = "TS_KY_UPRI";	break;
15060Sstevel@tonic-gate 		default:					break;
15070Sstevel@tonic-gate 		}
15080Sstevel@tonic-gate 	} else if (strcmp(clname, "IA") == 0) {
15090Sstevel@tonic-gate 		switch (val) {
15100Sstevel@tonic-gate 		case IA_KY_UPRILIM: 	s = "IA_KY_UPRILIM";	break;
15110Sstevel@tonic-gate 		case IA_KY_UPRI:	s = "IA_KY_UPRI";	break;
15120Sstevel@tonic-gate 		case IA_KY_MODE:	s = "IA_KY_MODE";	break;
15130Sstevel@tonic-gate 		default:					break;
15140Sstevel@tonic-gate 		}
15150Sstevel@tonic-gate 	} else if (strcmp(clname, "RT") == 0) {
15160Sstevel@tonic-gate 		switch (val) {
15170Sstevel@tonic-gate 		case RT_KY_PRI: 	s = "RT_KY_PRI";	break;
15180Sstevel@tonic-gate 		case RT_KY_TQSECS:	s = "RT_KY_TQSECS";	break;
15190Sstevel@tonic-gate 		case RT_KY_TQNSECS:	s = "RT_KY_TQNSECS";	break;
15200Sstevel@tonic-gate 		case RT_KY_TQSIG:	s = "RT_KY_TQSIG";	break;
15210Sstevel@tonic-gate 		default:					break;
15220Sstevel@tonic-gate 		}
15230Sstevel@tonic-gate 	} else if (strcmp(clname, "FSS") == 0) {
15240Sstevel@tonic-gate 		switch (val) {
15250Sstevel@tonic-gate 		case FSS_KY_UPRILIM: 	s = "FSS_KY_UPRILIM";	break;
15260Sstevel@tonic-gate 		case FSS_KY_UPRI:	s = "FSS_KY_UPRI";	break;
15270Sstevel@tonic-gate 		default:					break;
15280Sstevel@tonic-gate 		}
15290Sstevel@tonic-gate 	} else if (strcmp(clname, "FX") == 0) {
15300Sstevel@tonic-gate 		switch (val) {
15310Sstevel@tonic-gate 		case FX_KY_UPRILIM: 	s = "FX_KY_UPRILIM";	break;
15320Sstevel@tonic-gate 		case FX_KY_UPRI:	s = "FX_KY_UPRI";	break;
15330Sstevel@tonic-gate 		case FX_KY_TQSECS:	s = "FX_KY_TQSECS";	break;
15340Sstevel@tonic-gate 		case FX_KY_TQNSECS:	s = "FX_KY_TQNSECS";	break;
15350Sstevel@tonic-gate 		default:					break;
15360Sstevel@tonic-gate 		}
15370Sstevel@tonic-gate 	}
15380Sstevel@tonic-gate 
15390Sstevel@tonic-gate 	if (s == NULL)
15400Sstevel@tonic-gate 		prt_dec(pri, 0, val);
15410Sstevel@tonic-gate 	else
15420Sstevel@tonic-gate 		outstring(pri, s);
15430Sstevel@tonic-gate }
15440Sstevel@tonic-gate 
15450Sstevel@tonic-gate /*
15460Sstevel@tonic-gate  * print priocntlsys() fourth argument.
15470Sstevel@tonic-gate  */
15480Sstevel@tonic-gate /*ARGSUSED*/
15490Sstevel@tonic-gate void
15500Sstevel@tonic-gate prt_pc4(private_t *pri, int raw, long val)
15510Sstevel@tonic-gate {
15520Sstevel@tonic-gate 	/* look at pricntlsys function */
15530Sstevel@tonic-gate 	if ((pri->sys_args[2] != PC_GETXPARMS &&
15540Sstevel@tonic-gate 	    pri->sys_args[2] != PC_SETXPARMS))
15550Sstevel@tonic-gate 		prt_hex(pri, 0, val);
15560Sstevel@tonic-gate 	else if (val)
15570Sstevel@tonic-gate 		prt_stg(pri, 0, val);
15580Sstevel@tonic-gate 	else
15590Sstevel@tonic-gate 		prt_dec(pri, 0, val);
15600Sstevel@tonic-gate }
15610Sstevel@tonic-gate 
15620Sstevel@tonic-gate /*
15630Sstevel@tonic-gate  * print priocntlsys() (key, value) pairs (5th argument).
15640Sstevel@tonic-gate  */
15650Sstevel@tonic-gate /*ARGSUSED*/
15660Sstevel@tonic-gate void
15670Sstevel@tonic-gate prt_pc5(private_t *pri, int raw, long val)
15680Sstevel@tonic-gate {
15690Sstevel@tonic-gate 	pc_vaparms_t	prms;
15700Sstevel@tonic-gate 	pc_vaparm_t	*vpp = &prms.pc_parms[0];
15710Sstevel@tonic-gate 	uint_t		cnt;
15720Sstevel@tonic-gate 
15730Sstevel@tonic-gate 
15740Sstevel@tonic-gate 	/* look at pricntlsys function */
15750Sstevel@tonic-gate 	if ((pri->sys_args[2] != PC_GETXPARMS &&
15760Sstevel@tonic-gate 	    pri->sys_args[2] != PC_SETXPARMS) || val == 0) {
15770Sstevel@tonic-gate 		prt_dec(pri, 0, 0);
15780Sstevel@tonic-gate 		return;
15790Sstevel@tonic-gate 	}
15800Sstevel@tonic-gate 
15810Sstevel@tonic-gate 	if (Pread(Proc, &prms, sizeof (prms), val) != sizeof (prms)) {
15820Sstevel@tonic-gate 		prt_hex(pri, 0, val);
15830Sstevel@tonic-gate 		return;
15840Sstevel@tonic-gate 	}
15850Sstevel@tonic-gate 
15860Sstevel@tonic-gate 	if ((cnt = prms.pc_vaparmscnt) > PC_VAPARMCNT)
15870Sstevel@tonic-gate 		return;
15880Sstevel@tonic-gate 
15890Sstevel@tonic-gate 	for (; cnt--; vpp++) {
15900Sstevel@tonic-gate 		print_pck(pri, 0, vpp->pc_key);
15910Sstevel@tonic-gate 		outstring(pri, ", ");
15920Sstevel@tonic-gate 		prt_hex(pri, 0, (long)vpp->pc_parm);
15930Sstevel@tonic-gate 		outstring(pri, ", ");
15940Sstevel@tonic-gate 	}
15950Sstevel@tonic-gate 
15960Sstevel@tonic-gate 	prt_dec(pri, 0, PC_KY_NULL);
15970Sstevel@tonic-gate }
15980Sstevel@tonic-gate 
15990Sstevel@tonic-gate /*
16000Sstevel@tonic-gate  * Print processor set id, including logical expansion of "special" ids.
16010Sstevel@tonic-gate  */
16020Sstevel@tonic-gate void
16030Sstevel@tonic-gate prt_pst(private_t *pri, int raw, long val)
16040Sstevel@tonic-gate {
16050Sstevel@tonic-gate 	const char *s = NULL;
16060Sstevel@tonic-gate 
16070Sstevel@tonic-gate 	if (!raw) {
16080Sstevel@tonic-gate 		switch ((psetid_t)val) {
16090Sstevel@tonic-gate 		case PS_NONE:		s = "PS_NONE";		break;
16100Sstevel@tonic-gate 		case PS_QUERY:		s = "PS_QUERY";		break;
16110Sstevel@tonic-gate 		case PS_MYID:		s = "PS_MYID";		break;
16120Sstevel@tonic-gate 		}
16130Sstevel@tonic-gate 	}
16140Sstevel@tonic-gate 
16150Sstevel@tonic-gate 	if (s == NULL)
16160Sstevel@tonic-gate 		prt_dec(pri, 0, val);
16170Sstevel@tonic-gate 	else
16180Sstevel@tonic-gate 		outstring(pri, s);
16190Sstevel@tonic-gate }
16200Sstevel@tonic-gate 
16210Sstevel@tonic-gate /*
16220Sstevel@tonic-gate  * Print meminfo() argument.
16230Sstevel@tonic-gate  */
16240Sstevel@tonic-gate /*ARGSUSED*/
16250Sstevel@tonic-gate void
16260Sstevel@tonic-gate prt_mif(private_t *pri, int raw, long val)
16270Sstevel@tonic-gate {
16280Sstevel@tonic-gate 	struct meminfo	minfo;
16290Sstevel@tonic-gate 
16300Sstevel@tonic-gate #ifdef _LP64
16310Sstevel@tonic-gate 	if (data_model == PR_MODEL_ILP32) {
16320Sstevel@tonic-gate 		struct meminfo32 minfo32;
16330Sstevel@tonic-gate 
16340Sstevel@tonic-gate 		if (Pread(Proc, &minfo32, sizeof (struct meminfo32), val) !=
16350Sstevel@tonic-gate 			sizeof (struct meminfo32)) {
16360Sstevel@tonic-gate 			prt_dec(pri, 0, pri->sys_args[1]);	/* addr_count */
16370Sstevel@tonic-gate 			outstring(pri, ", ");
16380Sstevel@tonic-gate 			prt_hex(pri, 0, val);
16390Sstevel@tonic-gate 			return;
16400Sstevel@tonic-gate 		}
16410Sstevel@tonic-gate 		/*
16420Sstevel@tonic-gate 		 * arrange the arguments in the order that user calls with
16430Sstevel@tonic-gate 		 */
16440Sstevel@tonic-gate 		prt_hex(pri, 0, minfo32.mi_inaddr);
16450Sstevel@tonic-gate 		outstring(pri, ", ");
16460Sstevel@tonic-gate 		prt_dec(pri, 0, pri->sys_args[1]);	/* addr_count */
16470Sstevel@tonic-gate 		outstring(pri, ", ");
16480Sstevel@tonic-gate 		prt_hex(pri, 0, minfo32.mi_info_req);
16490Sstevel@tonic-gate 		outstring(pri, ", ");
16500Sstevel@tonic-gate 		prt_dec(pri, 0, minfo32.mi_info_count);
16510Sstevel@tonic-gate 		outstring(pri, ", ");
16520Sstevel@tonic-gate 		prt_hex(pri, 0, minfo32.mi_outdata);
16530Sstevel@tonic-gate 		outstring(pri, ", ");
16540Sstevel@tonic-gate 		prt_hex(pri, 0, minfo32.mi_validity);
16550Sstevel@tonic-gate 		return;
16560Sstevel@tonic-gate 	}
16570Sstevel@tonic-gate #endif
16580Sstevel@tonic-gate 	if (Pread(Proc, &minfo, sizeof (struct meminfo), val) !=
16590Sstevel@tonic-gate 		sizeof (struct meminfo)) {
16600Sstevel@tonic-gate 		prt_dec(pri, 0, pri->sys_args[1]);	/* addr_count */
16610Sstevel@tonic-gate 		outstring(pri, ", ");
16620Sstevel@tonic-gate 		prt_hex(pri, 0, val);
16630Sstevel@tonic-gate 		return;
16640Sstevel@tonic-gate 	}
16650Sstevel@tonic-gate 	/*
16660Sstevel@tonic-gate 	 * arrange the arguments in the order that user calls with
16670Sstevel@tonic-gate 	 */
16680Sstevel@tonic-gate 	prt_hex(pri, 0, (long)minfo.mi_inaddr);
16690Sstevel@tonic-gate 	outstring(pri, ", ");
16700Sstevel@tonic-gate 	prt_dec(pri, 0, pri->sys_args[1]);	/* addr_count */
16710Sstevel@tonic-gate 	outstring(pri, ", ");
16720Sstevel@tonic-gate 	prt_hex(pri, 0, (long)minfo.mi_info_req);
16730Sstevel@tonic-gate 	outstring(pri, ", ");
16740Sstevel@tonic-gate 	prt_dec(pri, 0, minfo.mi_info_count);
16750Sstevel@tonic-gate 	outstring(pri, ", ");
16760Sstevel@tonic-gate 	prt_hex(pri, 0, (long)minfo.mi_outdata);
16770Sstevel@tonic-gate 	outstring(pri, ", ");
16780Sstevel@tonic-gate 	prt_hex(pri, 0, (long)minfo.mi_validity);
16790Sstevel@tonic-gate }
16800Sstevel@tonic-gate 
16810Sstevel@tonic-gate 
16820Sstevel@tonic-gate /*
16830Sstevel@tonic-gate  * Print so_socket() 1st argument.
16840Sstevel@tonic-gate  */
16850Sstevel@tonic-gate /*ARGSUSED*/
16860Sstevel@tonic-gate void
16870Sstevel@tonic-gate prt_pfm(private_t *pri, int raw, long val)
16880Sstevel@tonic-gate {
16890Sstevel@tonic-gate 	/* Protocol Families have same names as Address Families */
16900Sstevel@tonic-gate 	if ((ulong_t)val < MAX_AFCODES) {
16910Sstevel@tonic-gate 		outstring(pri, "PF_");
16920Sstevel@tonic-gate 		outstring(pri, afcodes[val]);
16930Sstevel@tonic-gate 	} else {
16940Sstevel@tonic-gate 		prt_dec(pri, 0, val);
16950Sstevel@tonic-gate 	}
16960Sstevel@tonic-gate }
16970Sstevel@tonic-gate 
16980Sstevel@tonic-gate 
16990Sstevel@tonic-gate /*
17000Sstevel@tonic-gate  * Print so_socket() 2nd argument.
17010Sstevel@tonic-gate  */
17020Sstevel@tonic-gate /*ARGSUSED*/
17030Sstevel@tonic-gate void
17040Sstevel@tonic-gate prt_skt(private_t *pri, int raw, long val)
17050Sstevel@tonic-gate {
17060Sstevel@tonic-gate 	const char *s;
17070Sstevel@tonic-gate 
17080Sstevel@tonic-gate 	if ((ulong_t)val <= MAX_SOCKTYPES && (s = socktype_codes[val]) != NULL)
17090Sstevel@tonic-gate 		outstring(pri, s);
17100Sstevel@tonic-gate 	else
17110Sstevel@tonic-gate 		prt_dec(pri, 0, val);
17120Sstevel@tonic-gate }
17130Sstevel@tonic-gate 
17140Sstevel@tonic-gate 
17150Sstevel@tonic-gate /*
17160Sstevel@tonic-gate  * Print so_socket() 3rd argument.
17170Sstevel@tonic-gate  */
17180Sstevel@tonic-gate /*ARGSUSED*/
17190Sstevel@tonic-gate void
17200Sstevel@tonic-gate prt_skp(private_t *pri, int raw, long val)
17210Sstevel@tonic-gate {
17220Sstevel@tonic-gate 	const char *s;
17230Sstevel@tonic-gate 
17240Sstevel@tonic-gate 	/* cheating -- look at the protocol-family */
17250Sstevel@tonic-gate 	switch (pri->sys_args[0]) {
17260Sstevel@tonic-gate 	case PF_INET6:
17270Sstevel@tonic-gate 	case PF_INET:
17280Sstevel@tonic-gate 	case PF_NCA:	if ((s = ipprotos((int)val)) != NULL) {
17290Sstevel@tonic-gate 				outstring(pri, s);
17300Sstevel@tonic-gate 				break;
17310Sstevel@tonic-gate 			}
17320Sstevel@tonic-gate 			/* FALLTHROUGH */
17330Sstevel@tonic-gate 	default:	prt_dec(pri, 0, val);
17340Sstevel@tonic-gate 			break;
17350Sstevel@tonic-gate 	}
17360Sstevel@tonic-gate }
17370Sstevel@tonic-gate 
17380Sstevel@tonic-gate 
17390Sstevel@tonic-gate /*
17400Sstevel@tonic-gate  * Print so_socket() 5th argument.
17410Sstevel@tonic-gate  */
17420Sstevel@tonic-gate /*ARGSUSED*/
17430Sstevel@tonic-gate void
17440Sstevel@tonic-gate prt_skv(private_t *pri, int raw, long val)
17450Sstevel@tonic-gate {
17460Sstevel@tonic-gate 	switch (val) {
17470Sstevel@tonic-gate 	case SOV_STREAM:	outstring(pri, "SOV_STREAM");	break;
17480Sstevel@tonic-gate 	case SOV_DEFAULT:	outstring(pri, "SOV_DEFAULT");	break;
17490Sstevel@tonic-gate 	case SOV_SOCKSTREAM:	outstring(pri, "SOV_SOCKSTREAM");	break;
17500Sstevel@tonic-gate 	case SOV_SOCKBSD:	outstring(pri, "SOV_SOCKBSD");	break;
17510Sstevel@tonic-gate 	case SOV_XPG4_2:	outstring(pri, "SOV_XPG4_2");	break;
17520Sstevel@tonic-gate 	default:		prt_dec(pri, 0, val);		break;
17530Sstevel@tonic-gate 	}
17540Sstevel@tonic-gate }
17550Sstevel@tonic-gate 
17560Sstevel@tonic-gate 
17570Sstevel@tonic-gate /*
17580Sstevel@tonic-gate  * Print setsockopt()/getsockopt() 2nd argument.
17590Sstevel@tonic-gate  */
17600Sstevel@tonic-gate /*ARGSUSED*/
17610Sstevel@tonic-gate void
17620Sstevel@tonic-gate prt_sol(private_t *pri, int raw, long val)
17630Sstevel@tonic-gate {
17640Sstevel@tonic-gate 	if (val == SOL_SOCKET) {
17650Sstevel@tonic-gate 		outstring(pri, "SOL_SOCKET");
17668485SPeter.Memishian@Sun.COM 	} else if (val == SOL_ROUTE) {
17678485SPeter.Memishian@Sun.COM 		outstring(pri, "SOL_ROUTE");
17680Sstevel@tonic-gate 	} else {
17690Sstevel@tonic-gate 		const struct protoent *p;
17700Sstevel@tonic-gate 		struct protoent res;
17710Sstevel@tonic-gate 		char buf[NSS_BUFLEN_PROTOCOLS];
17720Sstevel@tonic-gate 
17730Sstevel@tonic-gate 		if ((p = getprotobynumber_r(val, &res,
17740Sstevel@tonic-gate 		    (char *)buf, sizeof (buf))) != NULL)
17750Sstevel@tonic-gate 			outstring(pri, p->p_name);
17760Sstevel@tonic-gate 		else
17770Sstevel@tonic-gate 			prt_dec(pri, 0, val);
17780Sstevel@tonic-gate 	}
17790Sstevel@tonic-gate }
17800Sstevel@tonic-gate 
17810Sstevel@tonic-gate 
17820Sstevel@tonic-gate const char *
17830Sstevel@tonic-gate sol_optname(private_t *pri, long val)
17840Sstevel@tonic-gate {
17850Sstevel@tonic-gate #define	CBSIZE	sizeof (pri->code_buf)
17860Sstevel@tonic-gate 	if (val >= SO_SNDBUF) {
17870Sstevel@tonic-gate 		switch (val) {
17880Sstevel@tonic-gate 		case SO_SNDBUF:		return ("SO_SNDBUF");
17890Sstevel@tonic-gate 		case SO_RCVBUF:		return ("SO_RCVBUF");
17900Sstevel@tonic-gate 		case SO_SNDLOWAT:	return ("SO_SNDLOWAT");
17910Sstevel@tonic-gate 		case SO_RCVLOWAT:	return ("SO_RCVLOWAT");
17920Sstevel@tonic-gate 		case SO_SNDTIMEO:	return ("SO_SNDTIMEO");
17930Sstevel@tonic-gate 		case SO_RCVTIMEO:	return ("SO_RCVTIMEO");
17940Sstevel@tonic-gate 		case SO_ERROR:		return ("SO_ERROR");
17950Sstevel@tonic-gate 		case SO_TYPE:		return ("SO_TYPE");
17960Sstevel@tonic-gate 		case SO_PROTOTYPE:	return ("SO_PROTOTYPE");
1797*10493SJarrett.Lu@Sun.COM 		case SO_ANON_MLP:	return ("SO_ANON_MLP");
1798*10493SJarrett.Lu@Sun.COM 		case SO_MAC_EXEMPT:	return ("SO_MAC_EXEMPT");
17992263Ssommerfe 		case SO_ALLZONES:	return ("SO_ALLZONES");
18002429Skcpoon 		case SO_EXCLBIND:	return ("SO_EXCLBIND");
18013388Skcpoon 		case SO_DOMAIN:		return ("SO_DOMAIN");
18020Sstevel@tonic-gate 
18030Sstevel@tonic-gate 		default:		(void) snprintf(pri->code_buf, CBSIZE,
18044217Seschrock 					    "0x%lx", val);
18050Sstevel@tonic-gate 					return (pri->code_buf);
18060Sstevel@tonic-gate 		}
18070Sstevel@tonic-gate 	} else {
18080Sstevel@tonic-gate 		char *s = pri->code_buf;
18090Sstevel@tonic-gate 		size_t used = 1;
18100Sstevel@tonic-gate 		long val2;
18110Sstevel@tonic-gate 
18120Sstevel@tonic-gate 		*s = '\0';
18130Sstevel@tonic-gate 		val2 = val & ~(SO_DEBUG|SO_ACCEPTCONN|SO_REUSEADDR|SO_KEEPALIVE|
18140Sstevel@tonic-gate 		    SO_DONTROUTE|SO_BROADCAST|SO_USELOOPBACK|SO_LINGER|
18150Sstevel@tonic-gate 		    SO_OOBINLINE|SO_DGRAM_ERRIND|SO_RECVUCRED);
18160Sstevel@tonic-gate 		if (val2)
18170Sstevel@tonic-gate 			used = snprintf(s, CBSIZE, "|0x%lx", val2);
18180Sstevel@tonic-gate 		if (val & SO_DEBUG)
18190Sstevel@tonic-gate 			used = strlcat(s, "|SO_DEBUG", CBSIZE);
18200Sstevel@tonic-gate 		if (val & SO_ACCEPTCONN)
18210Sstevel@tonic-gate 			used = strlcat(s, "|SO_ACCEPTCONN", CBSIZE);
18220Sstevel@tonic-gate 		if (val & SO_REUSEADDR)
18230Sstevel@tonic-gate 			used = strlcat(s, "|SO_REUSEADDR", CBSIZE);
18240Sstevel@tonic-gate 		if (val & SO_KEEPALIVE)
18250Sstevel@tonic-gate 			used = strlcat(s, "|SO_KEEPALIVE", CBSIZE);
18260Sstevel@tonic-gate 		if (val & SO_DONTROUTE)
18270Sstevel@tonic-gate 			used = strlcat(s, "|SO_DONTROUTE", CBSIZE);
18280Sstevel@tonic-gate 		if (val & SO_BROADCAST)
18290Sstevel@tonic-gate 			used = strlcat(s, "|SO_BROADCAST", CBSIZE);
18300Sstevel@tonic-gate 		if (val & SO_USELOOPBACK)
18310Sstevel@tonic-gate 			used = strlcat(s, "|SO_USELOOPBACK", CBSIZE);
18320Sstevel@tonic-gate 		if (val & SO_LINGER)
18330Sstevel@tonic-gate 			used = strlcat(s, "|SO_LINGER", CBSIZE);
18340Sstevel@tonic-gate 		if (val & SO_OOBINLINE)
18350Sstevel@tonic-gate 			used = strlcat(s, "|SO_OOBINLINE", CBSIZE);
18360Sstevel@tonic-gate 		if (val & SO_DGRAM_ERRIND)
18370Sstevel@tonic-gate 			used = strlcat(s, "|SO_DGRAM_ERRIND", CBSIZE);
18380Sstevel@tonic-gate 		if (val & SO_RECVUCRED)
18390Sstevel@tonic-gate 			used = strlcat(s, "|SO_RECVUCRED", CBSIZE);
18400Sstevel@tonic-gate 		if (used >= CBSIZE || val == 0)
18410Sstevel@tonic-gate 			(void) snprintf(s + 1, CBSIZE-1, "0x%lx", val);
18420Sstevel@tonic-gate 		return ((const char *)(s + 1));
18430Sstevel@tonic-gate 	}
18440Sstevel@tonic-gate #undef CBSIZE
18450Sstevel@tonic-gate }
18460Sstevel@tonic-gate 
18478485SPeter.Memishian@Sun.COM const char *
18488485SPeter.Memishian@Sun.COM route_optname(private_t *pri, long val)
18498485SPeter.Memishian@Sun.COM {
18508485SPeter.Memishian@Sun.COM 	switch (val) {
18518485SPeter.Memishian@Sun.COM 	case RT_AWARE:
18528485SPeter.Memishian@Sun.COM 		return ("RT_AWARE");
18538485SPeter.Memishian@Sun.COM 	default:
18548485SPeter.Memishian@Sun.COM 		(void) snprintf(pri->code_buf, sizeof (pri->code_buf),
18558485SPeter.Memishian@Sun.COM 		    "0x%lx", val);
18568485SPeter.Memishian@Sun.COM 		return (pri->code_buf);
18578485SPeter.Memishian@Sun.COM 	}
18588485SPeter.Memishian@Sun.COM }
18590Sstevel@tonic-gate 
18600Sstevel@tonic-gate const char *
18610Sstevel@tonic-gate tcp_optname(private_t *pri, long val)
18620Sstevel@tonic-gate {
18630Sstevel@tonic-gate 	switch (val) {
18640Sstevel@tonic-gate 	case TCP_NODELAY:		return ("TCP_NODELAY");
18650Sstevel@tonic-gate 	case TCP_MAXSEG:		return ("TCP_MAXSEG");
18660Sstevel@tonic-gate 	case TCP_KEEPALIVE:		return ("TCP_KEEPALIVE");
18670Sstevel@tonic-gate 	case TCP_NOTIFY_THRESHOLD:	return ("TCP_NOTIFY_THRESHOLD");
18680Sstevel@tonic-gate 	case TCP_ABORT_THRESHOLD:	return ("TCP_ABORT_THRESHOLD");
18690Sstevel@tonic-gate 	case TCP_CONN_NOTIFY_THRESHOLD:	return ("TCP_CONN_NOTIFY_THRESHOLD");
18700Sstevel@tonic-gate 	case TCP_CONN_ABORT_THRESHOLD:	return ("TCP_CONN_ABORT_THRESHOLD");
18710Sstevel@tonic-gate 	case TCP_RECVDSTADDR:		return ("TCP_RECVDSTADDR");
18720Sstevel@tonic-gate 	case TCP_ANONPRIVBIND:		return ("TCP_ANONPRIVBIND");
18730Sstevel@tonic-gate 	case TCP_EXCLBIND:		return ("TCP_EXCLBIND");
1874649Skcpoon 	case TCP_INIT_CWND:		return ("TCP_INIT_CWND");
1875649Skcpoon 	case TCP_KEEPALIVE_THRESHOLD:	return ("TCP_KEEPALIVE_THRESHOLD");
1876649Skcpoon 	case TCP_KEEPALIVE_ABORT_THRESHOLD:
1877649Skcpoon 		return ("TCP_KEEPALIVE_ABORT_THRESHOLD");
1878649Skcpoon 	case TCP_CORK:			return ("TCP_CORK");
18790Sstevel@tonic-gate 
18800Sstevel@tonic-gate 	default:			(void) snprintf(pri->code_buf,
18810Sstevel@tonic-gate 					    sizeof (pri->code_buf),
18820Sstevel@tonic-gate 					    "0x%lx", val);
18830Sstevel@tonic-gate 					return (pri->code_buf);
18840Sstevel@tonic-gate 	}
18850Sstevel@tonic-gate }
18860Sstevel@tonic-gate 
18870Sstevel@tonic-gate 
18880Sstevel@tonic-gate const char *
18890Sstevel@tonic-gate sctp_optname(private_t *pri, long val)
18900Sstevel@tonic-gate {
18910Sstevel@tonic-gate 	switch (val) {
18920Sstevel@tonic-gate 	case SCTP_RTOINFO:		return ("SCTP_RTOINFO");
18930Sstevel@tonic-gate 	case SCTP_ASSOCINFO:		return ("SCTP_ASSOCINFO");
18940Sstevel@tonic-gate 	case SCTP_INITMSG:		return ("SCTP_INITMSG");
18950Sstevel@tonic-gate 	case SCTP_NODELAY:		return ("SCTP_NODELAY");
18960Sstevel@tonic-gate 	case SCTP_AUTOCLOSE:		return ("SCTP_AUTOCLOSE");
18970Sstevel@tonic-gate 	case SCTP_SET_PEER_PRIMARY_ADDR:
18980Sstevel@tonic-gate 		return ("SCTP_SET_PEER_PRIMARY_ADDR");
18990Sstevel@tonic-gate 	case SCTP_PRIMARY_ADDR:		return ("SCTP_PRIMARY_ADDR");
19005586Skcpoon 	case SCTP_ADAPTATION_LAYER:	return ("SCTP_ADAPTATION_LAYER");
19010Sstevel@tonic-gate 	case SCTP_DISABLE_FRAGMENTS:	return ("SCTP_DISABLE_FRAGMENTS");
19020Sstevel@tonic-gate 	case SCTP_PEER_ADDR_PARAMS:	return ("SCTP_PEER_ADDR_PARAMS");
19030Sstevel@tonic-gate 	case SCTP_DEFAULT_SEND_PARAM:	return ("SCTP_DEFAULT_SEND_PARAM");
19040Sstevel@tonic-gate 	case SCTP_EVENTS:		return ("SCTP_EVENTS");
19050Sstevel@tonic-gate 	case SCTP_I_WANT_MAPPED_V4_ADDR:
19060Sstevel@tonic-gate 		return ("SCTP_I_WANT_MAPPED_V4_ADDR");
19070Sstevel@tonic-gate 	case SCTP_MAXSEG:		return ("SCTP_MAXSEG");
19080Sstevel@tonic-gate 	case SCTP_STATUS:		return ("SCTP_STATUS");
19090Sstevel@tonic-gate 	case SCTP_GET_PEER_ADDR_INFO:	return ("SCTP_GET_PEER_ADDR_INFO");
19100Sstevel@tonic-gate 
19110Sstevel@tonic-gate 	case SCTP_ADD_ADDR:		return ("SCTP_ADD_ADDR");
19120Sstevel@tonic-gate 	case SCTP_REM_ADDR:		return ("SCTP_REM_ADDR");
19130Sstevel@tonic-gate 
19140Sstevel@tonic-gate 	default:			(void) snprintf(pri->code_buf,
19150Sstevel@tonic-gate 					    sizeof (pri->code_buf),
19160Sstevel@tonic-gate 					    "0x%lx", val);
19170Sstevel@tonic-gate 					return (pri->code_buf);
19180Sstevel@tonic-gate 	}
19190Sstevel@tonic-gate }
19200Sstevel@tonic-gate 
19210Sstevel@tonic-gate 
19220Sstevel@tonic-gate const char *
19230Sstevel@tonic-gate udp_optname(private_t *pri, long val)
19240Sstevel@tonic-gate {
1925649Skcpoon 	switch (val) {
1926649Skcpoon 	case UDP_CHECKSUM:		return ("UDP_CHECKSUM");
1927649Skcpoon 	case UDP_ANONPRIVBIND:		return ("UDP_ANONPRIVBIND");
1928649Skcpoon 	case UDP_EXCLBIND:		return ("UDP_EXCLBIND");
1929649Skcpoon 	case UDP_RCVHDR:		return ("UDP_RCVHDR");
19304987Sdanmcd 	case UDP_NAT_T_ENDPOINT:	return ("UDP_NAT_T_ENDPOINT");
19310Sstevel@tonic-gate 
1932649Skcpoon 	default:			(void) snprintf(pri->code_buf,
1933649Skcpoon 					    sizeof (pri->code_buf), "0x%lx",
1934649Skcpoon 					    val);
1935649Skcpoon 					return (pri->code_buf);
1936649Skcpoon 	}
19370Sstevel@tonic-gate }
19380Sstevel@tonic-gate 
19390Sstevel@tonic-gate 
19400Sstevel@tonic-gate /*
19410Sstevel@tonic-gate  * Print setsockopt()/getsockopt() 3rd argument.
19420Sstevel@tonic-gate  */
19430Sstevel@tonic-gate /*ARGSUSED*/
19440Sstevel@tonic-gate void
19450Sstevel@tonic-gate prt_son(private_t *pri, int raw, long val)
19460Sstevel@tonic-gate {
19470Sstevel@tonic-gate 	/* cheating -- look at the level */
19480Sstevel@tonic-gate 	switch (pri->sys_args[1]) {
19490Sstevel@tonic-gate 	case SOL_SOCKET:	outstring(pri, sol_optname(pri, val));
19500Sstevel@tonic-gate 				break;
19518485SPeter.Memishian@Sun.COM 	case SOL_ROUTE:		outstring(pri, route_optname(pri, val));
19528485SPeter.Memishian@Sun.COM 				break;
19530Sstevel@tonic-gate 	case IPPROTO_TCP:	outstring(pri, tcp_optname(pri, val));
19540Sstevel@tonic-gate 				break;
19550Sstevel@tonic-gate 	case IPPROTO_UDP:	outstring(pri, udp_optname(pri, val));
19560Sstevel@tonic-gate 				break;
19570Sstevel@tonic-gate 	case IPPROTO_SCTP:	outstring(pri, sctp_optname(pri, val));
19580Sstevel@tonic-gate 				break;
19590Sstevel@tonic-gate 	default:		prt_dec(pri, 0, val);
19600Sstevel@tonic-gate 				break;
19610Sstevel@tonic-gate 	}
19620Sstevel@tonic-gate }
19630Sstevel@tonic-gate 
19640Sstevel@tonic-gate 
19650Sstevel@tonic-gate /*
19660Sstevel@tonic-gate  * Print utrap type
19670Sstevel@tonic-gate  */
19680Sstevel@tonic-gate /*ARGSUSED*/
19690Sstevel@tonic-gate void
19700Sstevel@tonic-gate prt_utt(private_t *pri, int raw, long val)
19710Sstevel@tonic-gate {
19720Sstevel@tonic-gate 	const char *s = NULL;
19730Sstevel@tonic-gate 
19740Sstevel@tonic-gate #ifdef __sparc
19750Sstevel@tonic-gate 	if (!raw) {
19760Sstevel@tonic-gate 		switch (val) {
19770Sstevel@tonic-gate 		case UT_INSTRUCTION_DISABLED:
19780Sstevel@tonic-gate 			s = "UT_INSTRUCTION_DISABLED"; break;
19790Sstevel@tonic-gate 		case UT_INSTRUCTION_ERROR:
19800Sstevel@tonic-gate 			s = "UT_INSTRUCTION_ERROR"; break;
19810Sstevel@tonic-gate 		case UT_INSTRUCTION_PROTECTION:
19820Sstevel@tonic-gate 			s = "UT_INSTRUCTION_PROTECTION"; break;
19830Sstevel@tonic-gate 		case UT_ILLTRAP_INSTRUCTION:
19840Sstevel@tonic-gate 			s = "UT_ILLTRAP_INSTRUCTION"; break;
19850Sstevel@tonic-gate 		case UT_ILLEGAL_INSTRUCTION:
19860Sstevel@tonic-gate 			s = "UT_ILLEGAL_INSTRUCTION"; break;
19870Sstevel@tonic-gate 		case UT_PRIVILEGED_OPCODE:
19880Sstevel@tonic-gate 			s = "UT_PRIVILEGED_OPCODE"; break;
19890Sstevel@tonic-gate 		case UT_FP_DISABLED:
19900Sstevel@tonic-gate 			s = "UT_FP_DISABLED"; break;
19910Sstevel@tonic-gate 		case UT_FP_EXCEPTION_IEEE_754:
19920Sstevel@tonic-gate 			s = "UT_FP_EXCEPTION_IEEE_754"; break;
19930Sstevel@tonic-gate 		case UT_FP_EXCEPTION_OTHER:
19940Sstevel@tonic-gate 			s = "UT_FP_EXCEPTION_OTHER"; break;
19950Sstevel@tonic-gate 		case UT_TAG_OVERFLOW:
19960Sstevel@tonic-gate 			s = "UT_TAG_OVERFLOW"; break;
19970Sstevel@tonic-gate 		case UT_DIVISION_BY_ZERO:
19980Sstevel@tonic-gate 			s = "UT_DIVISION_BY_ZERO"; break;
19990Sstevel@tonic-gate 		case UT_DATA_EXCEPTION:
20000Sstevel@tonic-gate 			s = "UT_DATA_EXCEPTION"; break;
20010Sstevel@tonic-gate 		case UT_DATA_ERROR:
20020Sstevel@tonic-gate 			s = "UT_DATA_ERROR"; break;
20030Sstevel@tonic-gate 		case UT_DATA_PROTECTION:
20040Sstevel@tonic-gate 			s = "UT_DATA_PROTECTION"; break;
20050Sstevel@tonic-gate 		case UT_MEM_ADDRESS_NOT_ALIGNED:
20060Sstevel@tonic-gate 			s = "UT_MEM_ADDRESS_NOT_ALIGNED"; break;
20070Sstevel@tonic-gate 		case UT_PRIVILEGED_ACTION:
20080Sstevel@tonic-gate 			s = "UT_PRIVILEGED_ACTION"; break;
20090Sstevel@tonic-gate 		case UT_ASYNC_DATA_ERROR:
20100Sstevel@tonic-gate 			s = "UT_ASYNC_DATA_ERROR"; break;
20110Sstevel@tonic-gate 		case UT_TRAP_INSTRUCTION_16:
20120Sstevel@tonic-gate 			s = "UT_TRAP_INSTRUCTION_16"; break;
20130Sstevel@tonic-gate 		case UT_TRAP_INSTRUCTION_17:
20140Sstevel@tonic-gate 			s = "UT_TRAP_INSTRUCTION_17"; break;
20150Sstevel@tonic-gate 		case UT_TRAP_INSTRUCTION_18:
20160Sstevel@tonic-gate 			s = "UT_TRAP_INSTRUCTION_18"; break;
20170Sstevel@tonic-gate 		case UT_TRAP_INSTRUCTION_19:
20180Sstevel@tonic-gate 			s = "UT_TRAP_INSTRUCTION_19"; break;
20190Sstevel@tonic-gate 		case UT_TRAP_INSTRUCTION_20:
20200Sstevel@tonic-gate 			s = "UT_TRAP_INSTRUCTION_20"; break;
20210Sstevel@tonic-gate 		case UT_TRAP_INSTRUCTION_21:
20220Sstevel@tonic-gate 			s = "UT_TRAP_INSTRUCTION_21"; break;
20230Sstevel@tonic-gate 		case UT_TRAP_INSTRUCTION_22:
20240Sstevel@tonic-gate 			s = "UT_TRAP_INSTRUCTION_22"; break;
20250Sstevel@tonic-gate 		case UT_TRAP_INSTRUCTION_23:
20260Sstevel@tonic-gate 			s = "UT_TRAP_INSTRUCTION_23"; break;
20270Sstevel@tonic-gate 		case UT_TRAP_INSTRUCTION_24:
20280Sstevel@tonic-gate 			s = "UT_TRAP_INSTRUCTION_24"; break;
20290Sstevel@tonic-gate 		case UT_TRAP_INSTRUCTION_25:
20300Sstevel@tonic-gate 			s = "UT_TRAP_INSTRUCTION_25"; break;
20310Sstevel@tonic-gate 		case UT_TRAP_INSTRUCTION_26:
20320Sstevel@tonic-gate 			s = "UT_TRAP_INSTRUCTION_26"; break;
20330Sstevel@tonic-gate 		case UT_TRAP_INSTRUCTION_27:
20340Sstevel@tonic-gate 			s = "UT_TRAP_INSTRUCTION_27"; break;
20350Sstevel@tonic-gate 		case UT_TRAP_INSTRUCTION_28:
20360Sstevel@tonic-gate 			s = "UT_TRAP_INSTRUCTION_28"; break;
20370Sstevel@tonic-gate 		case UT_TRAP_INSTRUCTION_29:
20380Sstevel@tonic-gate 			s = "UT_TRAP_INSTRUCTION_29"; break;
20390Sstevel@tonic-gate 		case UT_TRAP_INSTRUCTION_30:
20400Sstevel@tonic-gate 			s = "UT_TRAP_INSTRUCTION_30"; break;
20410Sstevel@tonic-gate 		case UT_TRAP_INSTRUCTION_31:
20420Sstevel@tonic-gate 			s = "UT_TRAP_INSTRUCTION_31"; break;
20430Sstevel@tonic-gate 		}
20440Sstevel@tonic-gate 	}
20450Sstevel@tonic-gate #endif /* __sparc */
20460Sstevel@tonic-gate 
20470Sstevel@tonic-gate 	if (s == NULL)
20480Sstevel@tonic-gate 		prt_dec(pri, 0, val);
20490Sstevel@tonic-gate 	else
20500Sstevel@tonic-gate 		outstring(pri, s);
20510Sstevel@tonic-gate }
20520Sstevel@tonic-gate 
20530Sstevel@tonic-gate 
20540Sstevel@tonic-gate /*
20550Sstevel@tonic-gate  * Print utrap handler
20560Sstevel@tonic-gate  */
20570Sstevel@tonic-gate void
20580Sstevel@tonic-gate prt_uth(private_t *pri, int raw, long val)
20590Sstevel@tonic-gate {
20600Sstevel@tonic-gate 	const char *s = NULL;
20610Sstevel@tonic-gate 
20620Sstevel@tonic-gate 	if (!raw) {
20630Sstevel@tonic-gate 		switch (val) {
20640Sstevel@tonic-gate 		case (long)UTH_NOCHANGE:	s = "UTH_NOCHANGE"; break;
20650Sstevel@tonic-gate 		}
20660Sstevel@tonic-gate 	}
20670Sstevel@tonic-gate 
20680Sstevel@tonic-gate 	if (s == NULL)
20690Sstevel@tonic-gate 		prt_hex(pri, 0, val);
20700Sstevel@tonic-gate 	else
20710Sstevel@tonic-gate 		outstring(pri, s);
20720Sstevel@tonic-gate }
20730Sstevel@tonic-gate 
20740Sstevel@tonic-gate const char *
20750Sstevel@tonic-gate access_flags(private_t *pri, long arg)
20760Sstevel@tonic-gate {
20770Sstevel@tonic-gate #define	E_OK 010
20780Sstevel@tonic-gate 	char *str = pri->code_buf;
20790Sstevel@tonic-gate 
20800Sstevel@tonic-gate 	if (arg & ~(R_OK|W_OK|X_OK|E_OK))
20810Sstevel@tonic-gate 		return (NULL);
20820Sstevel@tonic-gate 
20830Sstevel@tonic-gate 	/* NB: F_OK == 0 */
20840Sstevel@tonic-gate 	if (arg == F_OK)
20850Sstevel@tonic-gate 		return ("F_OK");
20860Sstevel@tonic-gate 	if (arg == E_OK)
20870Sstevel@tonic-gate 		return ("F_OK|E_OK");
20880Sstevel@tonic-gate 
20890Sstevel@tonic-gate 	*str = '\0';
20900Sstevel@tonic-gate 	if (arg & R_OK)
20910Sstevel@tonic-gate 		(void) strlcat(str, "|R_OK", sizeof (pri->code_buf));
20920Sstevel@tonic-gate 	if (arg & W_OK)
20930Sstevel@tonic-gate 		(void) strlcat(str, "|W_OK", sizeof (pri->code_buf));
20940Sstevel@tonic-gate 	if (arg & X_OK)
20950Sstevel@tonic-gate 		(void) strlcat(str, "|X_OK", sizeof (pri->code_buf));
20960Sstevel@tonic-gate 	if (arg & E_OK)
20970Sstevel@tonic-gate 		(void) strlcat(str, "|E_OK", sizeof (pri->code_buf));
20980Sstevel@tonic-gate 	return ((const char *)(str + 1));
20990Sstevel@tonic-gate #undef E_OK
21000Sstevel@tonic-gate }
21010Sstevel@tonic-gate 
21020Sstevel@tonic-gate /*
21030Sstevel@tonic-gate  * Print access() flags.
21040Sstevel@tonic-gate  */
21050Sstevel@tonic-gate void
21060Sstevel@tonic-gate prt_acc(private_t *pri, int raw, long val)
21070Sstevel@tonic-gate {
21080Sstevel@tonic-gate 	const char *s = raw? NULL : access_flags(pri, val);
21090Sstevel@tonic-gate 
21100Sstevel@tonic-gate 	if (s == NULL)
21110Sstevel@tonic-gate 		prt_dex(pri, 0, val);
21120Sstevel@tonic-gate 	else
21130Sstevel@tonic-gate 		outstring(pri, s);
21140Sstevel@tonic-gate }
21150Sstevel@tonic-gate 
21160Sstevel@tonic-gate /*
21170Sstevel@tonic-gate  * Print shutdown() "how" (2nd) argument
21180Sstevel@tonic-gate  */
21190Sstevel@tonic-gate void
21200Sstevel@tonic-gate prt_sht(private_t *pri, int raw, long val)
21210Sstevel@tonic-gate {
21220Sstevel@tonic-gate 	if (raw) {
21230Sstevel@tonic-gate 		prt_dex(pri, 0, val);
21240Sstevel@tonic-gate 		return;
21250Sstevel@tonic-gate 	}
21260Sstevel@tonic-gate 	switch (val) {
21270Sstevel@tonic-gate 	case SHUT_RD:	outstring(pri, "SHUT_RD");	break;
21280Sstevel@tonic-gate 	case SHUT_WR:	outstring(pri, "SHUT_WR");	break;
21290Sstevel@tonic-gate 	case SHUT_RDWR:	outstring(pri, "SHUT_RDWR");	break;
21300Sstevel@tonic-gate 	default:	prt_dec(pri, 0, val);		break;
21310Sstevel@tonic-gate 	}
21320Sstevel@tonic-gate }
21330Sstevel@tonic-gate 
21340Sstevel@tonic-gate /*
21350Sstevel@tonic-gate  * Print fcntl() F_SETFL flags (3rd) argument or fdsync flag (2nd arg)
21360Sstevel@tonic-gate  */
21370Sstevel@tonic-gate static struct fcntl_flags {
21380Sstevel@tonic-gate 	long		val;
21390Sstevel@tonic-gate 	const char	*name;
21400Sstevel@tonic-gate } fcntl_flags[] = {
21410Sstevel@tonic-gate #define	FC_FL(flag)	{ (long)flag, "|" # flag }
21420Sstevel@tonic-gate 	FC_FL(FREVOKED),
21430Sstevel@tonic-gate 	FC_FL(FREAD),
21440Sstevel@tonic-gate 	FC_FL(FWRITE),
21450Sstevel@tonic-gate 	FC_FL(FNDELAY),
21460Sstevel@tonic-gate 	FC_FL(FAPPEND),
21470Sstevel@tonic-gate 	FC_FL(FSYNC),
21480Sstevel@tonic-gate 	FC_FL(FDSYNC),
21490Sstevel@tonic-gate 	FC_FL(FRSYNC),
21500Sstevel@tonic-gate 	FC_FL(FOFFMAX),
21510Sstevel@tonic-gate 	FC_FL(FNONBLOCK),
21520Sstevel@tonic-gate 	FC_FL(FCREAT),
21530Sstevel@tonic-gate 	FC_FL(FTRUNC),
21540Sstevel@tonic-gate 	FC_FL(FEXCL),
21550Sstevel@tonic-gate 	FC_FL(FNOCTTY),
21560Sstevel@tonic-gate 	FC_FL(FXATTR),
21570Sstevel@tonic-gate 	FC_FL(FASYNC),
21580Sstevel@tonic-gate 	FC_FL(FNODSYNC)
21590Sstevel@tonic-gate #undef FC_FL
21600Sstevel@tonic-gate };
21610Sstevel@tonic-gate 
21620Sstevel@tonic-gate void
21630Sstevel@tonic-gate prt_ffg(private_t *pri, int raw, long val)
21640Sstevel@tonic-gate {
21650Sstevel@tonic-gate #define	CBSIZE	sizeof (pri->code_buf)
21660Sstevel@tonic-gate 	char *s = pri->code_buf;
21670Sstevel@tonic-gate 	size_t used = 1;
21680Sstevel@tonic-gate 	struct fcntl_flags *fp;
21690Sstevel@tonic-gate 
21700Sstevel@tonic-gate 	if (raw) {
21710Sstevel@tonic-gate 		(void) snprintf(s, CBSIZE, "0x%lx", val);
21720Sstevel@tonic-gate 		outstring(pri, s);
21730Sstevel@tonic-gate 		return;
21740Sstevel@tonic-gate 	}
21750Sstevel@tonic-gate 	if (val == 0) {
21760Sstevel@tonic-gate 		outstring(pri, "(no flags)");
21770Sstevel@tonic-gate 		return;
21780Sstevel@tonic-gate 	}
21790Sstevel@tonic-gate 
21800Sstevel@tonic-gate 	*s = '\0';
21810Sstevel@tonic-gate 	for (fp = fcntl_flags;
21820Sstevel@tonic-gate 	    fp < &fcntl_flags[sizeof (fcntl_flags) / sizeof (*fp)]; fp++) {
21830Sstevel@tonic-gate 		if (val & fp->val) {
21840Sstevel@tonic-gate 			used = strlcat(s, fp->name, CBSIZE);
21850Sstevel@tonic-gate 			val &= ~fp->val;
21860Sstevel@tonic-gate 		}
21870Sstevel@tonic-gate 	}
21880Sstevel@tonic-gate 
21890Sstevel@tonic-gate 	if (val != 0 && used <= CBSIZE)
21900Sstevel@tonic-gate 		used += snprintf(s + used, CBSIZE - used, "|0x%lx", val);
21910Sstevel@tonic-gate 
21920Sstevel@tonic-gate 	if (used >= CBSIZE)
21930Sstevel@tonic-gate 		(void) snprintf(s + 1, CBSIZE-1, "0x%lx", val);
21940Sstevel@tonic-gate 	outstring(pri, s + 1);
21950Sstevel@tonic-gate #undef CBSIZE
21960Sstevel@tonic-gate }
21970Sstevel@tonic-gate 
21980Sstevel@tonic-gate void
21990Sstevel@tonic-gate prt_prs(private_t *pri, int raw, long val)
22000Sstevel@tonic-gate {
22010Sstevel@tonic-gate 	static size_t setsize;
22020Sstevel@tonic-gate 	priv_set_t *set = priv_allocset();
22030Sstevel@tonic-gate 
22040Sstevel@tonic-gate 	if (setsize == 0) {
22050Sstevel@tonic-gate 		const priv_impl_info_t *info = getprivimplinfo();
22060Sstevel@tonic-gate 		if (info != NULL)
22070Sstevel@tonic-gate 			setsize = info->priv_setsize * sizeof (priv_chunk_t);
22080Sstevel@tonic-gate 	}
22090Sstevel@tonic-gate 
22100Sstevel@tonic-gate 	if (setsize != 0 && !raw && set != NULL &&
22110Sstevel@tonic-gate 	    Pread(Proc, set, setsize, val) == setsize) {
22120Sstevel@tonic-gate 		int i;
22130Sstevel@tonic-gate 
22140Sstevel@tonic-gate 		outstring(pri, "{");
22150Sstevel@tonic-gate 		for (i = 0; i < setsize / sizeof (priv_chunk_t); i++) {
22160Sstevel@tonic-gate 			char buf[9];	/* 8 hex digits + '\0' */
22170Sstevel@tonic-gate 			(void) snprintf(buf, sizeof (buf), "%08x",
22180Sstevel@tonic-gate 			    ((priv_chunk_t *)set)[i]);
22190Sstevel@tonic-gate 			outstring(pri, buf);
22200Sstevel@tonic-gate 		}
22210Sstevel@tonic-gate 
22220Sstevel@tonic-gate 		outstring(pri, "}");
22230Sstevel@tonic-gate 	} else {
22240Sstevel@tonic-gate 		prt_hex(pri, 0, val);
22250Sstevel@tonic-gate 	}
22260Sstevel@tonic-gate 
22270Sstevel@tonic-gate 	if (set != NULL)
22280Sstevel@tonic-gate 		priv_freeset(set);
22290Sstevel@tonic-gate }
22300Sstevel@tonic-gate 
22310Sstevel@tonic-gate /*
22320Sstevel@tonic-gate  * Print privilege set operation.
22330Sstevel@tonic-gate  */
22340Sstevel@tonic-gate void
22350Sstevel@tonic-gate prt_pro(private_t *pri, int raw, long val)
22360Sstevel@tonic-gate {
22370Sstevel@tonic-gate 	const char *s = NULL;
22380Sstevel@tonic-gate 
22390Sstevel@tonic-gate 	if (!raw) {
22400Sstevel@tonic-gate 		switch ((priv_op_t)val) {
22410Sstevel@tonic-gate 		case PRIV_ON:		s = "PRIV_ON";		break;
22420Sstevel@tonic-gate 		case PRIV_OFF:		s = "PRIV_OFF";		break;
22430Sstevel@tonic-gate 		case PRIV_SET:		s = "PRIV_SET";		break;
22440Sstevel@tonic-gate 		}
22450Sstevel@tonic-gate 	}
22460Sstevel@tonic-gate 
22470Sstevel@tonic-gate 	if (s == NULL)
22480Sstevel@tonic-gate 		prt_dec(pri, 0, val);
22490Sstevel@tonic-gate 	else
22500Sstevel@tonic-gate 		outstring(pri, s);
22510Sstevel@tonic-gate }
22520Sstevel@tonic-gate 
22530Sstevel@tonic-gate /*
22540Sstevel@tonic-gate  * Print privilege set name
22550Sstevel@tonic-gate  */
22560Sstevel@tonic-gate void
22570Sstevel@tonic-gate prt_prn(private_t *pri, int raw, long val)
22580Sstevel@tonic-gate {
22590Sstevel@tonic-gate 	const char *s = NULL;
22600Sstevel@tonic-gate 
22610Sstevel@tonic-gate 	if (!raw)
22620Sstevel@tonic-gate 		s = priv_getsetbynum((int)val);
22630Sstevel@tonic-gate 
22640Sstevel@tonic-gate 	if (s == NULL)
22650Sstevel@tonic-gate 		prt_dec(pri, 0, val);
22660Sstevel@tonic-gate 	else {
22670Sstevel@tonic-gate 		char *dup = strdup(s);
22680Sstevel@tonic-gate 		char *q;
22690Sstevel@tonic-gate 
22700Sstevel@tonic-gate 		/* Do the best we can in this case */
22710Sstevel@tonic-gate 		if (dup == NULL) {
22720Sstevel@tonic-gate 			outstring(pri, s);
22730Sstevel@tonic-gate 			return;
22740Sstevel@tonic-gate 		}
22750Sstevel@tonic-gate 
22760Sstevel@tonic-gate 		outstring(pri, "PRIV_");
22770Sstevel@tonic-gate 
22780Sstevel@tonic-gate 		q = dup;
22790Sstevel@tonic-gate 
22800Sstevel@tonic-gate 		while (*q != '\0') {
22810Sstevel@tonic-gate 			*q = toupper(*q);
22820Sstevel@tonic-gate 			q++;
22830Sstevel@tonic-gate 		}
22840Sstevel@tonic-gate 		outstring(pri, dup);
22850Sstevel@tonic-gate 		free(dup);
22860Sstevel@tonic-gate 	}
22870Sstevel@tonic-gate }
22880Sstevel@tonic-gate 
22890Sstevel@tonic-gate /*
22900Sstevel@tonic-gate  * Print process flag names.
22910Sstevel@tonic-gate  */
22920Sstevel@tonic-gate void
22930Sstevel@tonic-gate prt_pfl(private_t *pri, int raw, long val)
22940Sstevel@tonic-gate {
22950Sstevel@tonic-gate 	const char *s = NULL;
22960Sstevel@tonic-gate 
22970Sstevel@tonic-gate 	if (!raw) {
22980Sstevel@tonic-gate 		switch ((int)val) {
22990Sstevel@tonic-gate 		case PRIV_DEBUG:	s = "PRIV_DEBUG";	break;
23000Sstevel@tonic-gate 		case PRIV_AWARE:	s = "PRIV_AWARE";	break;
23016134Scasper 		case PRIV_XPOLICY:	s = "PRIV_XPOLICY";	break;
23029799SCasper.Dik@Sun.COM 		case PRIV_AWARE_RESET:  s = "PRIV_AWARE_RESET"; break;
23036134Scasper 		case NET_MAC_AWARE:	s =  "NET_MAC_AWARE";	break;
23046134Scasper 		case NET_MAC_AWARE_INHERIT:
23056134Scasper 			s = "NET_MAC_AWARE_INHERIT";
23066134Scasper 			break;
23070Sstevel@tonic-gate 		}
23080Sstevel@tonic-gate 	}
23090Sstevel@tonic-gate 
23100Sstevel@tonic-gate 	if (s == NULL)
23110Sstevel@tonic-gate 		prt_dec(pri, 0, val);
23120Sstevel@tonic-gate 	else
23130Sstevel@tonic-gate 		outstring(pri, s);
23140Sstevel@tonic-gate }
23150Sstevel@tonic-gate 
23160Sstevel@tonic-gate /*
23170Sstevel@tonic-gate  * Print lgrp_affinity_{get,set}() arguments.
23180Sstevel@tonic-gate  */
23190Sstevel@tonic-gate /*ARGSUSED*/
23200Sstevel@tonic-gate void
23210Sstevel@tonic-gate prt_laf(private_t *pri, int raw, long val)
23220Sstevel@tonic-gate {
23230Sstevel@tonic-gate 	lgrp_affinity_args_t	laff;
23240Sstevel@tonic-gate 
23250Sstevel@tonic-gate 	if (Pread(Proc, &laff, sizeof (lgrp_affinity_args_t), val) !=
23264217Seschrock 	    sizeof (lgrp_affinity_args_t)) {
23270Sstevel@tonic-gate 		prt_hex(pri, 0, val);
23280Sstevel@tonic-gate 		return;
23290Sstevel@tonic-gate 	}
23300Sstevel@tonic-gate 	/*
23310Sstevel@tonic-gate 	 * arrange the arguments in the order that user calls with
23320Sstevel@tonic-gate 	 */
23330Sstevel@tonic-gate 	prt_dec(pri, 0, laff.idtype);
23340Sstevel@tonic-gate 	outstring(pri, ", ");
23350Sstevel@tonic-gate 	prt_dec(pri, 0, laff.id);
23360Sstevel@tonic-gate 	outstring(pri, ", ");
23370Sstevel@tonic-gate 	prt_dec(pri, 0, laff.lgrp);
23380Sstevel@tonic-gate 	outstring(pri, ", ");
23390Sstevel@tonic-gate 	if (pri->sys_args[0] == LGRP_SYS_AFFINITY_SET)
23400Sstevel@tonic-gate 		prt_dec(pri, 0, laff.aff);
23410Sstevel@tonic-gate }
23420Sstevel@tonic-gate 
23430Sstevel@tonic-gate /*
23440Sstevel@tonic-gate  * Print a key_t as IPC_PRIVATE if it is 0.
23450Sstevel@tonic-gate  */
23460Sstevel@tonic-gate void
23470Sstevel@tonic-gate prt_key(private_t *pri, int raw, long val)
23480Sstevel@tonic-gate {
23490Sstevel@tonic-gate 	if (!raw && val == 0)
23500Sstevel@tonic-gate 		outstring(pri, "IPC_PRIVATE");
23510Sstevel@tonic-gate 	else
23520Sstevel@tonic-gate 		prt_dec(pri, 0, val);
23530Sstevel@tonic-gate }
23540Sstevel@tonic-gate 
23550Sstevel@tonic-gate 
23560Sstevel@tonic-gate /*
23570Sstevel@tonic-gate  * Print zone_getattr() attribute types.
23580Sstevel@tonic-gate  */
23590Sstevel@tonic-gate void
23600Sstevel@tonic-gate prt_zga(private_t *pri, int raw, long val)
23610Sstevel@tonic-gate {
23620Sstevel@tonic-gate 	const char *s = NULL;
23630Sstevel@tonic-gate 
23640Sstevel@tonic-gate 	if (!raw) {
23650Sstevel@tonic-gate 		switch ((int)val) {
23660Sstevel@tonic-gate 		case ZONE_ATTR_NAME:	s = "ZONE_ATTR_NAME";	break;
23670Sstevel@tonic-gate 		case ZONE_ATTR_ROOT:	s = "ZONE_ATTR_ROOT";	break;
23680Sstevel@tonic-gate 		case ZONE_ATTR_STATUS:	s = "ZONE_ATTR_STATUS";	break;
23690Sstevel@tonic-gate 		case ZONE_ATTR_PRIVSET:	s = "ZONE_ATTR_PRIVSET"; break;
23700Sstevel@tonic-gate 		case ZONE_ATTR_UNIQID:	s = "ZONE_ATTR_UNIQID"; break;
23710Sstevel@tonic-gate 		case ZONE_ATTR_POOLID:	s = "ZONE_ATTR_POOLID"; break;
23720Sstevel@tonic-gate 		case ZONE_ATTR_INITPID:	s = "ZONE_ATTR_INITPID"; break;
23731676Sjpk 		case ZONE_ATTR_SLBL:	s = "ZONE_ATTR_SLBL"; break;
23742267Sdp 		case ZONE_ATTR_INITNAME:	s = "ZONE_ATTR_INITNAME"; break;
23752267Sdp 		case ZONE_ATTR_BOOTARGS:	s = "ZONE_ATTR_BOOTARGS"; break;
23763009Snn35248 		case ZONE_ATTR_BRAND:	s = "ZONE_ATTR_BRAND"; break;
23773448Sdh155122 		case ZONE_ATTR_FLAGS:	s = "ZONE_ATTR_FLAGS"; break;
23783247Sgjelinek 		case ZONE_ATTR_PHYS_MCAP: s = "ZONE_ATTR_PHYS_MCAP"; break;
23790Sstevel@tonic-gate 		}
23800Sstevel@tonic-gate 	}
23810Sstevel@tonic-gate 
23820Sstevel@tonic-gate 	if (s == NULL)
23830Sstevel@tonic-gate 		prt_dec(pri, 0, val);
23840Sstevel@tonic-gate 	else
23850Sstevel@tonic-gate 		outstring(pri, s);
23860Sstevel@tonic-gate }
23870Sstevel@tonic-gate 
23880Sstevel@tonic-gate /*
23890Sstevel@tonic-gate  * Print a file descriptor as AT_FDCWD if necessary
23900Sstevel@tonic-gate  */
23910Sstevel@tonic-gate void
23920Sstevel@tonic-gate prt_atc(private_t *pri, int raw, long val)
23930Sstevel@tonic-gate {
23940Sstevel@tonic-gate 	if (!raw && val == AT_FDCWD)
23950Sstevel@tonic-gate 		outstring(pri, "AT_FDCWD");
23960Sstevel@tonic-gate 	else
23970Sstevel@tonic-gate 		prt_dec(pri, 0, val);
23980Sstevel@tonic-gate }
23990Sstevel@tonic-gate 
24000Sstevel@tonic-gate /*
24011676Sjpk  * Print Trusted Networking database operation codes (labelsys; tn*)
24021676Sjpk  */
24031676Sjpk static void
24041676Sjpk prt_tnd(private_t *pri, int raw, long val)
24051676Sjpk {
24061676Sjpk 	const char *s = NULL;
24071676Sjpk 
24081676Sjpk 	if (!raw) {
24091676Sjpk 		switch ((tsol_dbops_t)val) {
24101676Sjpk 		case TNDB_NOOP:		s = "TNDB_NOOP";	break;
24111676Sjpk 		case TNDB_LOAD:		s = "TNDB_LOAD";	break;
24121676Sjpk 		case TNDB_DELETE:	s = "TNDB_DELETE";	break;
24131676Sjpk 		case TNDB_FLUSH:	s = "TNDB_FLUSH";	break;
24141676Sjpk 		case TNDB_GET:		s = "TNDB_GET";		break;
24151676Sjpk 		}
24161676Sjpk 	}
24171676Sjpk 
24181676Sjpk 	if (s == NULL)
24191676Sjpk 		prt_dec(pri, 0, val);
24201676Sjpk 	else
24211676Sjpk 		outstring(pri, s);
24221676Sjpk }
24231676Sjpk 
24241676Sjpk /*
24250Sstevel@tonic-gate  * Print LIO_XX flags
24260Sstevel@tonic-gate  */
24270Sstevel@tonic-gate void
24280Sstevel@tonic-gate prt_lio(private_t *pri, int raw, long val)
24290Sstevel@tonic-gate {
24300Sstevel@tonic-gate 	if (raw)
24310Sstevel@tonic-gate 		prt_dec(pri, 0, val);
24320Sstevel@tonic-gate 	else if (val == LIO_WAIT)
24330Sstevel@tonic-gate 		outstring(pri, "LIO_WAIT");
24340Sstevel@tonic-gate 	else if (val == LIO_NOWAIT)
24350Sstevel@tonic-gate 		outstring(pri, "LIO_NOWAIT");
24360Sstevel@tonic-gate 	else
24370Sstevel@tonic-gate 		prt_dec(pri, 0, val);
24380Sstevel@tonic-gate }
24390Sstevel@tonic-gate 
24400Sstevel@tonic-gate const char *
24410Sstevel@tonic-gate door_flags(private_t *pri, long val)
24420Sstevel@tonic-gate {
24430Sstevel@tonic-gate 	door_attr_t attr = (door_attr_t)val;
24440Sstevel@tonic-gate 	char *str = pri->code_buf;
24450Sstevel@tonic-gate 
24460Sstevel@tonic-gate 	*str = '\0';
24470Sstevel@tonic-gate #define	PROCESS_FLAG(flg)						\
24480Sstevel@tonic-gate 	if (attr & flg) {						\
24490Sstevel@tonic-gate 		(void) strlcat(str, "|" #flg, sizeof (pri->code_buf));	\
24500Sstevel@tonic-gate 		attr &= ~flg;						\
24510Sstevel@tonic-gate 	}
24520Sstevel@tonic-gate 
24530Sstevel@tonic-gate 	PROCESS_FLAG(DOOR_UNREF);
24540Sstevel@tonic-gate 	PROCESS_FLAG(DOOR_UNREF_MULTI);
24550Sstevel@tonic-gate 	PROCESS_FLAG(DOOR_PRIVATE);
24560Sstevel@tonic-gate 	PROCESS_FLAG(DOOR_REFUSE_DESC);
24570Sstevel@tonic-gate 	PROCESS_FLAG(DOOR_NO_CANCEL);
24580Sstevel@tonic-gate 	PROCESS_FLAG(DOOR_LOCAL);
24590Sstevel@tonic-gate 	PROCESS_FLAG(DOOR_REVOKED);
24600Sstevel@tonic-gate 	PROCESS_FLAG(DOOR_IS_UNREF);
24610Sstevel@tonic-gate #undef PROCESS_FLAG
24620Sstevel@tonic-gate 
24630Sstevel@tonic-gate 	if (attr != 0 || *str == '\0') {
24640Sstevel@tonic-gate 		size_t len = strlen(str);
24650Sstevel@tonic-gate 		(void) snprintf(str + len, sizeof (pri->code_buf) - len,
24660Sstevel@tonic-gate 		    "|0x%X", attr);
24670Sstevel@tonic-gate 	}
24680Sstevel@tonic-gate 
24690Sstevel@tonic-gate 	return (str + 1);
24700Sstevel@tonic-gate }
24710Sstevel@tonic-gate 
24720Sstevel@tonic-gate /*
24730Sstevel@tonic-gate  * Print door_create() flags
24740Sstevel@tonic-gate  */
24750Sstevel@tonic-gate void
24760Sstevel@tonic-gate prt_dfl(private_t *pri, int raw, long val)
24770Sstevel@tonic-gate {
24780Sstevel@tonic-gate 	if (raw)
24790Sstevel@tonic-gate 		prt_hex(pri, 0, val);
24800Sstevel@tonic-gate 	else
24810Sstevel@tonic-gate 		outstring(pri, door_flags(pri, val));
24820Sstevel@tonic-gate }
24830Sstevel@tonic-gate 
24840Sstevel@tonic-gate /*
24850Sstevel@tonic-gate  * Print door_*param() param argument
24860Sstevel@tonic-gate  */
24870Sstevel@tonic-gate void
24880Sstevel@tonic-gate prt_dpm(private_t *pri, int raw, long val)
24890Sstevel@tonic-gate {
24900Sstevel@tonic-gate 	if (raw)
24910Sstevel@tonic-gate 		prt_hex(pri, 0, val);
24920Sstevel@tonic-gate 	else if (val == DOOR_PARAM_DESC_MAX)
24930Sstevel@tonic-gate 		outstring(pri, "DOOR_PARAM_DESC_MAX");
24940Sstevel@tonic-gate 	else if (val == DOOR_PARAM_DATA_MIN)
24950Sstevel@tonic-gate 		outstring(pri, "DOOR_PARAM_DATA_MIN");
24960Sstevel@tonic-gate 	else if (val == DOOR_PARAM_DATA_MAX)
24970Sstevel@tonic-gate 		outstring(pri, "DOOR_PARAM_DATA_MAX");
24980Sstevel@tonic-gate 	else
24990Sstevel@tonic-gate 		prt_hex(pri, 0, val);
25000Sstevel@tonic-gate }
25010Sstevel@tonic-gate 
25020Sstevel@tonic-gate /*
25032447Snf202958  * Print rctlsys subcodes
25042447Snf202958  */
25052447Snf202958 void
25062447Snf202958 prt_rsc(private_t *pri, int raw, long val)	/* print utssys code */
25072447Snf202958 {
25082447Snf202958 	const char *s = raw? NULL : rctlsyscode(val);
25092447Snf202958 
25102447Snf202958 	if (s == NULL)
25112447Snf202958 		prt_dec(pri, 0, val);
25122447Snf202958 	else
25132447Snf202958 		outstring(pri, s);
25142447Snf202958 }
25152447Snf202958 
25162447Snf202958 /*
25172447Snf202958  * Print getrctl flags
25182447Snf202958  */
25192447Snf202958 void
25202447Snf202958 prt_rgf(private_t *pri, int raw, long val)
25212447Snf202958 {
25222447Snf202958 	long action = val & (~RCTLSYS_ACTION_MASK);
25232447Snf202958 
25242447Snf202958 	if (raw)
25252447Snf202958 		prt_hex(pri, 0, val);
25262447Snf202958 	else if (action == RCTL_FIRST)
25272447Snf202958 		outstring(pri, "RCTL_FIRST");
25282447Snf202958 	else if (action == RCTL_NEXT)
25292447Snf202958 		outstring(pri, "RCTL_NEXT");
25302447Snf202958 	else if (action == RCTL_USAGE)
25312447Snf202958 		outstring(pri, "RCTL_USAGE");
25322447Snf202958 	else
25332447Snf202958 		prt_hex(pri, 0, val);
25342447Snf202958 }
25352447Snf202958 
25362447Snf202958 /*
25372447Snf202958  * Print setrctl flags
25382447Snf202958  */
25392447Snf202958 void
25402447Snf202958 prt_rsf(private_t *pri, int raw, long val)
25412447Snf202958 {
25422447Snf202958 	long action = val & (~RCTLSYS_ACTION_MASK);
25432447Snf202958 	long pval = val & RCTL_LOCAL_ACTION_MASK;
25442447Snf202958 	char *s = pri->code_buf;
25452447Snf202958 
25462447Snf202958 	if (raw) {
25472447Snf202958 		prt_hex(pri, 0, val);
25482447Snf202958 		return;
25492447Snf202958 	} else if (action == RCTL_INSERT)
25502447Snf202958 		(void) strcpy(s, "RCTL_INSERT");
25512447Snf202958 	else if (action == RCTL_DELETE)
25522447Snf202958 		(void) strcpy(s, "RCTL_DELETE");
25532447Snf202958 	else if (action == RCTL_REPLACE)
25542447Snf202958 		(void) strcpy(s, "RCTL_REPLACE");
25552447Snf202958 	else {
25562447Snf202958 		prt_hex(pri, 0, val);
25572447Snf202958 		return;
25582447Snf202958 	}
25592447Snf202958 
25602447Snf202958 	if (pval & RCTL_USE_RECIPIENT_PID) {
25612447Snf202958 		pval ^= RCTL_USE_RECIPIENT_PID;
25622447Snf202958 		(void) strlcat(s, "|RCTL_USE_RECIPIENT_PID",
25632447Snf202958 		    sizeof (pri->code_buf));
25642447Snf202958 	}
25652447Snf202958 
25662447Snf202958 	if ((pval & RCTLSYS_ACTION_MASK) != 0)
25672447Snf202958 		prt_hex(pri, 0, val);
25682447Snf202958 	else if (*s != '\0')
25692447Snf202958 		outstring(pri, s);
25702447Snf202958 	else
25712447Snf202958 		prt_hex(pri, 0, val);
25722447Snf202958 }
25732447Snf202958 
25742447Snf202958 /*
25752447Snf202958  * Print rctlctl flags
25762447Snf202958  */
25772447Snf202958 void
25782447Snf202958 prt_rcf(private_t *pri, int raw, long val)
25792447Snf202958 {
25802447Snf202958 	long action = val & (~RCTLSYS_ACTION_MASK);
25812447Snf202958 
25822447Snf202958 	if (raw)
25832447Snf202958 		prt_hex(pri, 0, val);
25842447Snf202958 	else if (action == RCTLCTL_GET)
25852447Snf202958 		outstring(pri, "RCTLCTL_GET");
25862447Snf202958 	else if (action == RCTLCTL_SET)
25872447Snf202958 		outstring(pri, "RCTLCTL_SET");
25882447Snf202958 	else
25892447Snf202958 		prt_hex(pri, 0, val);
25902447Snf202958 }
25912447Snf202958 
25923235Sraf /*
25933684Srd117015  * Print setprojrctl flags
25943684Srd117015  */
25953684Srd117015 void
25963684Srd117015 prt_spf(private_t *pri, int raw, long val)
25973684Srd117015 {
25983684Srd117015 	long action = val & TASK_PROJ_MASK;
25993684Srd117015 
26003684Srd117015 	if (!raw && (action == TASK_PROJ_PURGE))
26013684Srd117015 		outstring(pri, "TASK_PROJ_PURGE");
26023684Srd117015 	else
26033684Srd117015 		prt_hex(pri, 0, val);
26043684Srd117015 }
26053684Srd117015 
26063684Srd117015 /*
26073235Sraf  * Print forkx() flags
26083235Sraf  */
26093235Sraf void
26103235Sraf prt_fxf(private_t *pri, int raw, long val)
26113235Sraf {
26123235Sraf 	char *str;
26133235Sraf 
26143235Sraf 	if (val == 0)
26153235Sraf 		outstring(pri, "0");
26163235Sraf 	else if (raw || (val & ~(FORK_NOSIGCHLD | FORK_WAITPID)))
26173235Sraf 		prt_hhx(pri, 0, val);
26183235Sraf 	else {
26193235Sraf 		str = pri->code_buf;
26203235Sraf 		*str = '\0';
26213235Sraf 		if (val & FORK_NOSIGCHLD)
26223235Sraf 			(void) strlcat(str, "|FORK_NOSIGCHLD",
26233235Sraf 			    sizeof (pri->code_buf));
26243235Sraf 		if (val & FORK_WAITPID)
26253235Sraf 			(void) strlcat(str, "|FORK_WAITPID",
26263235Sraf 			    sizeof (pri->code_buf));
26273235Sraf 		outstring(pri, str + 1);
26283235Sraf 	}
26293235Sraf }
26302447Snf202958 
26312447Snf202958 /*
263210440SRoger.Faulkner@Sun.COM  * Print utimensat() flag
263310440SRoger.Faulkner@Sun.COM  */
263410440SRoger.Faulkner@Sun.COM void
263510440SRoger.Faulkner@Sun.COM prt_utf(private_t *pri, int raw, long val)
263610440SRoger.Faulkner@Sun.COM {
263710440SRoger.Faulkner@Sun.COM 	if (val == 0)
263810440SRoger.Faulkner@Sun.COM 		outstring(pri, "0");
263910440SRoger.Faulkner@Sun.COM 	else if (!raw && val == AT_SYMLINK_NOFOLLOW)
264010440SRoger.Faulkner@Sun.COM 		outstring(pri, "AT_SYMLINK_NOFOLLOW");
264110440SRoger.Faulkner@Sun.COM 	else
264210440SRoger.Faulkner@Sun.COM 		prt_hex(pri, 0, val);
264310440SRoger.Faulkner@Sun.COM }
264410440SRoger.Faulkner@Sun.COM 
264510440SRoger.Faulkner@Sun.COM /*
26460Sstevel@tonic-gate  * Array of pointers to print functions, one for each format.
26470Sstevel@tonic-gate  */
26480Sstevel@tonic-gate void (* const Print[])() = {
26490Sstevel@tonic-gate 	prt_nov,	/* NOV -- no value */
26500Sstevel@tonic-gate 	prt_dec,	/* DEC -- print value in decimal */
26510Sstevel@tonic-gate 	prt_oct,	/* OCT -- print value in octal */
26520Sstevel@tonic-gate 	prt_hex,	/* HEX -- print value in hexadecimal */
26530Sstevel@tonic-gate 	prt_dex,	/* DEX -- print value in hexadecimal if big enough */
26540Sstevel@tonic-gate 	prt_stg,	/* STG -- print value as string */
26550Sstevel@tonic-gate 	prt_ioc,	/* IOC -- print ioctl code */
26560Sstevel@tonic-gate 	prt_fcn,	/* FCN -- print fcntl code */
26570Sstevel@tonic-gate 	prt_s86,	/* S86 -- print sysi86 code */
26580Sstevel@tonic-gate 	prt_uts,	/* UTS -- print utssys code */
26590Sstevel@tonic-gate 	prt_opn,	/* OPN -- print open code */
26600Sstevel@tonic-gate 	prt_sig,	/* SIG -- print signal name plus flags */
26610Sstevel@tonic-gate 	prt_act,	/* ACT -- print signal action value */
26620Sstevel@tonic-gate 	prt_msc,	/* MSC -- print msgsys command */
26630Sstevel@tonic-gate 	prt_msf,	/* MSF -- print msgsys flags */
26640Sstevel@tonic-gate 	prt_smc,	/* SMC -- print semsys command */
26650Sstevel@tonic-gate 	prt_sef,	/* SEF -- print semsys flags */
26660Sstevel@tonic-gate 	prt_shc,	/* SHC -- print shmsys command */
26670Sstevel@tonic-gate 	prt_shf,	/* SHF -- print shmsys flags */
26680Sstevel@tonic-gate 	prt_plk,	/* PLK -- print plock code */
26690Sstevel@tonic-gate 	prt_sfs,	/* SFS -- print sysfs code */
26700Sstevel@tonic-gate 	prt_rst,	/* RST -- print string returned by syscall */
26710Sstevel@tonic-gate 	prt_smf,	/* SMF -- print streams message flags */
26720Sstevel@tonic-gate 	prt_ioa,	/* IOA -- print ioctl argument */
26730Sstevel@tonic-gate 	prt_six,	/* SIX -- print signal, masked with SIGNO_MASK */
26740Sstevel@tonic-gate 	prt_mtf,	/* MTF -- print mount flags */
26750Sstevel@tonic-gate 	prt_mft,	/* MFT -- print mount file system type */
26760Sstevel@tonic-gate 	prt_iob,	/* IOB -- print contents of I/O buffer */
26770Sstevel@tonic-gate 	prt_hhx,	/* HHX -- print value in hexadecimal (half size) */
26780Sstevel@tonic-gate 	prt_wop,	/* WOP -- print waitsys() options */
26790Sstevel@tonic-gate 	prt_spm,	/* SPM -- print sigprocmask argument */
26800Sstevel@tonic-gate 	prt_rlk,	/* RLK -- print readlink buffer */
26810Sstevel@tonic-gate 	prt_mpr,	/* MPR -- print mmap()/mprotect() flags */
26820Sstevel@tonic-gate 	prt_mty,	/* MTY -- print mmap() mapping type flags */
26830Sstevel@tonic-gate 	prt_mcf,	/* MCF -- print memcntl() function */
26840Sstevel@tonic-gate 	prt_mc4,	/* MC4 -- print memcntl() (fourth) argument */
26850Sstevel@tonic-gate 	prt_mc5,	/* MC5 -- print memcntl() (fifth) argument */
26860Sstevel@tonic-gate 	prt_mad,	/* MAD -- print madvise() argument */
26870Sstevel@tonic-gate 	prt_ulm,	/* ULM -- print ulimit() argument */
26880Sstevel@tonic-gate 	prt_rlm,	/* RLM -- print get/setrlimit() argument */
26890Sstevel@tonic-gate 	prt_cnf,	/* CNF -- print sysconfig() argument */
26900Sstevel@tonic-gate 	prt_inf,	/* INF -- print sysinfo() argument */
26910Sstevel@tonic-gate 	prt_ptc,	/* PTC -- print pathconf/fpathconf() argument */
26920Sstevel@tonic-gate 	prt_fui,	/* FUI -- print fusers() input argument */
26930Sstevel@tonic-gate 	prt_idt,	/* IDT -- print idtype_t, waitid() argument */
26940Sstevel@tonic-gate 	prt_lwf,	/* LWF -- print lwp_create() flags */
26950Sstevel@tonic-gate 	prt_itm,	/* ITM -- print [get|set]itimer() arg */
26960Sstevel@tonic-gate 	prt_llo,	/* LLO -- print long long offset arg */
26970Sstevel@tonic-gate 	prt_mod,	/* MOD -- print modctl() subcode */
26980Sstevel@tonic-gate 	prt_whn,	/* WHN -- print lseek() whence arguiment */
26990Sstevel@tonic-gate 	prt_acl,	/* ACL -- print acl() code */
27000Sstevel@tonic-gate 	prt_aio,	/* AIO -- print kaio() code */
27010Sstevel@tonic-gate 	prt_aud,	/* AUD -- print auditsys() code */
27020Sstevel@tonic-gate 	prt_uns,	/* DEC -- print value in unsigned decimal */
27030Sstevel@tonic-gate 	prt_clc,	/* CLC -- print cladm command argument */
27040Sstevel@tonic-gate 	prt_clf,	/* CLF -- print cladm flag argument */
27050Sstevel@tonic-gate 	prt_cor,	/* COR -- print corectl() subcode */
27060Sstevel@tonic-gate 	prt_cco,	/* CCO -- print corectl() options */
27070Sstevel@tonic-gate 	prt_ccc,	/* CCC -- print corectl() content */
27080Sstevel@tonic-gate 	prt_rcc,	/* RCC -- print corectl() returned content */
27090Sstevel@tonic-gate 	prt_cpc,	/* CPC -- print cpc() subcode */
27100Sstevel@tonic-gate 	prt_sqc,	/* SQC -- print sigqueue() si_code argument */
27110Sstevel@tonic-gate 	prt_pc4,	/* PC4 -- print priocntlsys() (fourth) argument */
27120Sstevel@tonic-gate 	prt_pc5,	/* PC5 -- print priocntlsys() (key, value) pairs */
27130Sstevel@tonic-gate 	prt_pst,	/* PST -- print processor set id */
27140Sstevel@tonic-gate 	prt_mif,	/* MIF -- print meminfo() arguments */
27150Sstevel@tonic-gate 	prt_pfm,	/* PFM -- print so_socket() proto-family (1st) arg */
27160Sstevel@tonic-gate 	prt_skt,	/* SKT -- print so_socket() socket-type (2nd) arg */
27170Sstevel@tonic-gate 	prt_skp,	/* SKP -- print so_socket() protocol (3rd) arg */
27180Sstevel@tonic-gate 	prt_skv,	/* SKV -- print socket version arg */
27190Sstevel@tonic-gate 	prt_sol,	/* SOL -- print [sg]etsockopt() level (2nd) arg */
27200Sstevel@tonic-gate 	prt_son,	/* SON -- print [sg]etsockopt() opt-name (3rd) arg */
27210Sstevel@tonic-gate 	prt_utt,	/* UTT -- print utrap type */
27220Sstevel@tonic-gate 	prt_uth,	/* UTH -- print utrap handler */
27230Sstevel@tonic-gate 	prt_acc,	/* ACC -- print access() flags */
27240Sstevel@tonic-gate 	prt_sht,	/* SHT -- print shutdown() how (2nd) argument */
27250Sstevel@tonic-gate 	prt_ffg,	/* FFG -- print fcntl() flags (3rd) argument */
27260Sstevel@tonic-gate 	prt_prs,	/* PRS -- print privilege set */
27270Sstevel@tonic-gate 	prt_pro,	/* PRO -- print privilege set operation */
27280Sstevel@tonic-gate 	prt_prn,	/* PRN -- print privilege set name */
27290Sstevel@tonic-gate 	prt_pfl,	/* PFL -- print privilege/process flag name */
27300Sstevel@tonic-gate 	prt_laf,	/* LAF -- print lgrp_affinity arguments */
27310Sstevel@tonic-gate 	prt_key,	/* KEY -- print key_t 0 as IPC_PRIVATE */
27320Sstevel@tonic-gate 	prt_zga,	/* ZGA -- print zone_getattr attribute types */
27330Sstevel@tonic-gate 	prt_atc,	/* ATC -- print AT_FDCWD or file descriptor */
27340Sstevel@tonic-gate 	prt_lio,	/* LIO -- print LIO_XX flags */
27350Sstevel@tonic-gate 	prt_dfl,	/* DFL -- print door_create() flags */
27360Sstevel@tonic-gate 	prt_dpm,	/* DPM -- print DOOR_PARAM_XX flags */
27371676Sjpk 	prt_tnd,	/* TND -- print trusted network data base opcode */
27382447Snf202958 	prt_rsc,	/* RSC -- print rctlsys() subcodes */
27392447Snf202958 	prt_rgf,	/* RGF -- print getrctl() flags */
27402447Snf202958 	prt_rsf,	/* RSF -- print setrctl() flags */
27412447Snf202958 	prt_rcf,	/* RCF -- print rctlsys_ctl() flags */
27423235Sraf 	prt_fxf,	/* FXF -- print forkx() flags */
27433684Srd117015 	prt_spf,	/* SPF -- print rctlsys_projset() flags */
27444321Scasper 	prt_un1,	/* UN1 -- as prt_uns except for -1 */
274510198SAli.Bahrami@Sun.COM 	prt_mob,	/* MOB -- print mmapobj() flags */
274610440SRoger.Faulkner@Sun.COM 	prt_utf,	/* UTF -- print utimensat() flag */
27470Sstevel@tonic-gate 	prt_dec,	/* HID -- hidden argument, make this the last one */
27480Sstevel@tonic-gate };
2749