print.c revision f4b3ec61df05330d25f55a36b975b4d7519fdeb1
4b22b9337f359bfd063322244f5336cc7c6ffcfars * CDDL HEADER START
4b22b9337f359bfd063322244f5336cc7c6ffcfars * The contents of this file are subject to the terms of the
4b22b9337f359bfd063322244f5336cc7c6ffcfars * Common Development and Distribution License (the "License").
4b22b9337f359bfd063322244f5336cc7c6ffcfars * You may not use this file except in compliance with the License.
4b22b9337f359bfd063322244f5336cc7c6ffcfars * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
4b22b9337f359bfd063322244f5336cc7c6ffcfars * See the License for the specific language governing permissions
4b22b9337f359bfd063322244f5336cc7c6ffcfars * and limitations under the License.
4b22b9337f359bfd063322244f5336cc7c6ffcfars * When distributing Covered Code, include this CDDL HEADER in each
4b22b9337f359bfd063322244f5336cc7c6ffcfars * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
4b22b9337f359bfd063322244f5336cc7c6ffcfars * If applicable, add the following below this CDDL HEADER, with the
4b22b9337f359bfd063322244f5336cc7c6ffcfars * fields enclosed by brackets "[]" replaced with your own identifying
4b22b9337f359bfd063322244f5336cc7c6ffcfars * information: Portions Copyright [yyyy] [name of copyright owner]
4b22b9337f359bfd063322244f5336cc7c6ffcfars * CDDL HEADER END
4b22b9337f359bfd063322244f5336cc7c6ffcfars * Copyright 2007 Sun Microsystems, Inc. All rights reserved.
4b22b9337f359bfd063322244f5336cc7c6ffcfars * Use is subject to license terms.
4b22b9337f359bfd063322244f5336cc7c6ffcfars/* Copyright (c) 1984, 1986, 1987, 1988, 1989 AT&T */
4b22b9337f359bfd063322244f5336cc7c6ffcfars/* All Rights Reserved */
4b22b9337f359bfd063322244f5336cc7c6ffcfars#pragma ident "%Z%%M% %I% %E% SMI"
4b22b9337f359bfd063322244f5336cc7c6ffcfars#define _SYSCALL32 /* make 32-bit compat headers visible */
4b22b9337f359bfd063322244f5336cc7c6ffcfars#define GROW(nb) if (pri->sys_leng + (nb) >= pri->sys_ssize) grow(pri, (nb))
4b22b9337f359bfd063322244f5336cc7c6ffcfars/*ARGSUSED*/
4b22b9337f359bfd063322244f5336cc7c6ffcfarsprt_nov(private_t *pri, int raw, long val) /* print nothing */
4b22b9337f359bfd063322244f5336cc7c6ffcfars/*ARGSUSED*/
4b22b9337f359bfd063322244f5336cc7c6ffcfarsprt_dec(private_t *pri, int raw, long val) /* print as decimal */
4b22b9337f359bfd063322244f5336cc7c6ffcfars pri->sys_leng += sprintf(pri->sys_string + pri->sys_leng,
4b22b9337f359bfd063322244f5336cc7c6ffcfars pri->sys_leng += sprintf(pri->sys_string + pri->sys_leng,
4b22b9337f359bfd063322244f5336cc7c6ffcfarsprt_uns(private_t *pri, int raw, long val) /* print as unsigned decimal */
4b22b9337f359bfd063322244f5336cc7c6ffcfars pri->sys_leng += sprintf(pri->sys_string + pri->sys_leng,
4b22b9337f359bfd063322244f5336cc7c6ffcfars pri->sys_leng += sprintf(pri->sys_string + pri->sys_leng,
4b22b9337f359bfd063322244f5336cc7c6ffcfars/*ARGSUSED*/
4b22b9337f359bfd063322244f5336cc7c6ffcfarsprt_oct(private_t *pri, int raw, long val) /* print as octal */
4b22b9337f359bfd063322244f5336cc7c6ffcfars pri->sys_leng += sprintf(pri->sys_string + pri->sys_leng,
4b22b9337f359bfd063322244f5336cc7c6ffcfars pri->sys_leng += sprintf(pri->sys_string + pri->sys_leng,
4b22b9337f359bfd063322244f5336cc7c6ffcfars/*ARGSUSED*/
4b22b9337f359bfd063322244f5336cc7c6ffcfarsprt_hex(private_t *pri, int raw, long val) /* print as hexadecimal */
4b22b9337f359bfd063322244f5336cc7c6ffcfars pri->sys_leng += sprintf(pri->sys_string + pri->sys_leng,
4b22b9337f359bfd063322244f5336cc7c6ffcfars pri->sys_leng += sprintf(pri->sys_string + pri->sys_leng,
4b22b9337f359bfd063322244f5336cc7c6ffcfars/* print as hexadecimal (half size) */
4b22b9337f359bfd063322244f5336cc7c6ffcfars/*ARGSUSED*/
4b22b9337f359bfd063322244f5336cc7c6ffcfars pri->sys_leng += sprintf(pri->sys_string + pri->sys_leng,
4b22b9337f359bfd063322244f5336cc7c6ffcfars pri->sys_leng += sprintf(pri->sys_string + pri->sys_leng,
4b22b9337f359bfd063322244f5336cc7c6ffcfars/* print as decimal if small, else hexadecimal */
4b22b9337f359bfd063322244f5336cc7c6ffcfars/*ARGSUSED*/
4b22b9337f359bfd063322244f5336cc7c6ffcfars/* print long long offset */
4b22b9337f359bfd063322244f5336cc7c6ffcfars/*ARGSUSED*/
4b22b9337f359bfd063322244f5336cc7c6ffcfars * We want to avoid outputting unprintable characters that may
4b22b9337f359bfd063322244f5336cc7c6ffcfars * destroy the user's terminal. So we do one pass to find any
4b22b9337f359bfd063322244f5336cc7c6ffcfars * unprintable characters, size the array appropriately, and
4b22b9337f359bfd063322244f5336cc7c6ffcfars * then walk each character by hand. Those that are unprintable
4b22b9337f359bfd063322244f5336cc7c6ffcfars * are replaced by a hex escape (\xNN). We also escape quotes for
4b22b9337f359bfd063322244f5336cc7c6ffcfars * completeness.
4b22b9337f359bfd063322244f5336cc7c6ffcfars if (!isprint(s[i]))
4b22b9337f359bfd063322244f5336cc7c6ffcfars if (s[i] == '"')
4b22b9337f359bfd063322244f5336cc7c6ffcfars for (i = 0; i < len; i++) {
4b22b9337f359bfd063322244f5336cc7c6ffcfars if (s[i] == '"')
4b22b9337f359bfd063322244f5336cc7c6ffcfars if (isprint(s[i])) {
4b22b9337f359bfd063322244f5336cc7c6ffcfarsprt_stg(private_t *pri, int raw, long val) /* print as string */
4b22b9337f359bfd063322244f5336cc7c6ffcfars char *s = raw? NULL : fetchstring(pri, (long)val, PATH_MAX);
4b22b9337f359bfd063322244f5336cc7c6ffcfars/* print as string returned from syscall */
4b22b9337f359bfd063322244f5336cc7c6ffcfars pri->sys_leng += snprintf(pri->sys_string + pri->sys_leng,
4b22b9337f359bfd063322244f5336cc7c6ffcfars/* print contents of readlink() buffer */
4b22b9337f359bfd063322244f5336cc7c6ffcfars pri->sys_leng += snprintf(pri->sys_string + pri->sys_leng,
4b22b9337f359bfd063322244f5336cc7c6ffcfarsprt_ioc(private_t *pri, int raw, long val) /* print ioctl code */
case KSTAT_IOC_READ:
case KSTAT_IOC_WRITE:
#ifdef _LP64
case I_LOOK:
case I_PUSH:
case I_FIND:
case I_LINK:
case I_UNLINK:
case I_SENDFD:
case I_SRDOPT:
case I_SETSIG:
case I_FLUSH:
case TCSBRK:
case TCXONC:
case TCFLSH:
case TCDSET:
if (s == NULL)
if (s == NULL)
if (s == NULL)
if (s == NULL)
if (s == NULL)
if (s == NULL)
if (s == NULL)
if (s == NULL)
if (s == NULL)
if (s == NULL)
if (s == NULL)
if (s == NULL)
if (s == NULL)
if (raw)
s = NULL;
s = NULL;
if (s == NULL)
switch (val) {
case RS_HIPRI:
if (raw)
if (s == NULL)
if (s == NULL)
else if (raw)
if (raw)
if (s == NULL)
if (s == NULL)
if (s == NULL)
const char *s = NULL;
if (!raw) {
switch (val) {
if (s == NULL)
return ((char *)NULL);
case MAP_SHARED:
case MAP_PRIVATE:
return ((const char *)str);
if (s == NULL)
if (s == NULL)
const char *s = NULL;
if (!raw) {
switch (val) {
if (s == NULL)
const char *s = NULL;
if (!raw) {
switch (val) {
if (s == NULL)
if (val == 0)
else if (raw)
char *s = NULL;
case MC_ADVISE:
case MC_SYNC:
CBSIZE);
case MC_LOCKAS:
case MC_UNLOCKAS:
CBSIZE);
CBSIZE);
if (val == 0)
const char *s = NULL;
if (!raw) {
switch (val) {
if (s == NULL)
const char *s = NULL;
if (!raw) {
switch (val) {
if (s == NULL)
if (s == NULL)
const char *s = NULL;
if (!raw) {
switch (val) {
if (s == NULL)
if (s == NULL)
if (s == NULL)
if (val == 0)
else if (raw ||
const char *s = NULL;
if (!raw) {
switch (val) {
#ifdef ITIMER_REALPROF
if (s == NULL)
const char *s = NULL;
if (!raw) {
switch (val) {
case MODGETDEVPOLICYBYNAME:
case MODGETDEVFSPATH_MI_LEN:
case MODGETDEVFSPATH_MI:
if (s == NULL)
const char *s = NULL;
if (!raw) {
switch (val) {
if (s == NULL)
const char *s = NULL;
if (!raw) {
s = (const char *)buf;
if (s == NULL)
const char *s = NULL;
if (!raw) {
switch (val) {
if (s == NULL)
const char *s = NULL;
if (!raw) {
switch (val) {
case CC_SET_OPTIONS:
case CC_GET_OPTIONS:
case CC_SET_GLOBAL_PATH:
case CC_GET_GLOBAL_PATH:
case CC_SET_PROCESS_PATH:
case CC_GET_PROCESS_PATH:
case CC_SET_GLOBAL_CONTENT:
case CC_GET_GLOBAL_CONTENT:
case CC_SET_PROCESS_CONTENT:
case CC_GET_PROCESS_CONTENT:
case CC_SET_DEFAULT_PATH:
case CC_GET_DEFAULT_PATH:
case CC_SET_DEFAULT_CONTENT:
case CC_GET_DEFAULT_CONTENT:
if (s == NULL)
if (val == 0)
const char *s = NULL;
if (!raw) {
switch (val) {
if (s == NULL)
const char *s = NULL;
if (!raw) {
switch (val) {
if (s == NULL)
const char *s = NULL;
if (!raw) {
case CL_CONFIG:
case CL_NODEID:
case CL_HIGHEST_NODEID:
case CL_INITIALIZE:
case CL_GET_BOOTFLAG:
if (s == NULL)
const char *s = NULL;
if (!raw) {
switch ((int)val) {
if (s == NULL)
const char *s = NULL;
switch (val) {
switch (val) {
switch (val) {
switch (val) {
switch (val) {
if (s == NULL)
else if (val)
const char *s = NULL;
if (!raw) {
if (s == NULL)
#ifdef _LP64
sizeof (struct meminfo32)) {
sizeof (struct meminfo)) {
case PF_INET6:
case PF_INET:
switch (val) {
const struct protoent *p;
switch (val) {
long val2;
if (val2)
switch (val) {
switch (val) {
switch (val) {
val);
const char *s = NULL;
#ifdef __sparc
if (!raw) {
switch (val) {
case UT_INSTRUCTION_DISABLED:
case UT_INSTRUCTION_ERROR:
case UT_ILLTRAP_INSTRUCTION:
case UT_ILLEGAL_INSTRUCTION:
case UT_PRIVILEGED_OPCODE:
case UT_FP_DISABLED:
case UT_FP_EXCEPTION_IEEE_754:
case UT_FP_EXCEPTION_OTHER:
case UT_TAG_OVERFLOW:
case UT_DIVISION_BY_ZERO:
case UT_DATA_EXCEPTION:
case UT_DATA_ERROR:
case UT_DATA_PROTECTION:
case UT_PRIVILEGED_ACTION:
case UT_ASYNC_DATA_ERROR:
case UT_TRAP_INSTRUCTION_16:
case UT_TRAP_INSTRUCTION_17:
case UT_TRAP_INSTRUCTION_18:
case UT_TRAP_INSTRUCTION_19:
case UT_TRAP_INSTRUCTION_20:
case UT_TRAP_INSTRUCTION_21:
case UT_TRAP_INSTRUCTION_22:
case UT_TRAP_INSTRUCTION_23:
case UT_TRAP_INSTRUCTION_24:
case UT_TRAP_INSTRUCTION_25:
case UT_TRAP_INSTRUCTION_26:
case UT_TRAP_INSTRUCTION_27:
case UT_TRAP_INSTRUCTION_28:
case UT_TRAP_INSTRUCTION_29:
case UT_TRAP_INSTRUCTION_30:
case UT_TRAP_INSTRUCTION_31:
if (s == NULL)
const char *s = NULL;
if (!raw) {
switch (val) {
if (s == NULL)
return (NULL);
if (s == NULL)
if (raw) {
switch (val) {
static struct fcntl_flags {
long val;
const char *name;
} fcntl_flags[] = {
#ifdef C2_AUDIT
if (raw) {
if (val == 0) {
if (setsize == 0) {
const char *s = NULL;
if (!raw) {
if (s == NULL)
const char *s = NULL;
if (!raw)
if (s == NULL)
q = dup;
*q = toupper(*q);
const char *s = NULL;
if (!raw) {
switch ((int)val) {
if (s == NULL)
sizeof (lgrp_affinity_args_t)) {
const char *s = NULL;
if (!raw) {
switch ((int)val) {
if (s == NULL)
const char *s = NULL;
if (!raw) {
if (s == NULL)
if (raw)
if (raw)
if (raw)
if (s == NULL)
if (raw)
if (raw) {
if (raw)
char *str;
if (val == 0)
void (* const Print[])() = {