17c478bdstevel@tonic-gate/*
27c478bdstevel@tonic-gate * CDDL HEADER START
37c478bdstevel@tonic-gate *
47c478bdstevel@tonic-gate * The contents of this file are subject to the terms of the
52caf0dcrshoaib * Common Development and Distribution License (the "License").
62caf0dcrshoaib * You may not use this file except in compliance with the License.
77c478bdstevel@tonic-gate *
87c478bdstevel@tonic-gate * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
97c478bdstevel@tonic-gate * or http://www.opensolaris.org/os/licensing.
107c478bdstevel@tonic-gate * See the License for the specific language governing permissions
117c478bdstevel@tonic-gate * and limitations under the License.
127c478bdstevel@tonic-gate *
137c478bdstevel@tonic-gate * When distributing Covered Code, include this CDDL HEADER in each
147c478bdstevel@tonic-gate * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
157c478bdstevel@tonic-gate * If applicable, add the following below this CDDL HEADER, with the
167c478bdstevel@tonic-gate * fields enclosed by brackets "[]" replaced with your own identifying
177c478bdstevel@tonic-gate * information: Portions Copyright [yyyy] [name of copyright owner]
187c478bdstevel@tonic-gate *
197c478bdstevel@tonic-gate * CDDL HEADER END
207c478bdstevel@tonic-gate */
212caf0dcrshoaib
227c478bdstevel@tonic-gate/*
23a803cc2Gordon Ross * Copyright 2012 Nexenta Systems, Inc.  All rights reserved.
243e95bd4Anders Persson * Copyright (c) 1989, 2010, Oracle and/or its affiliates. All rights reserved.
259c3fd12Matthew Ahrens * Copyright (c) 2012, 2014 by Delphix. All rights reserved.
267a5aac9Jerry Jelinek * Copyright 2015 Joyent, Inc.
277c478bdstevel@tonic-gate */
287c478bdstevel@tonic-gate
297c478bdstevel@tonic-gate/*	Copyright (c) 1984, 1986, 1987, 1988, 1989 AT&T	*/
3027aa481Toomas Soome/*	  All Rights Reserved	*/
317c478bdstevel@tonic-gate
327c478bdstevel@tonic-gate#define	_SYSCALL32
337c478bdstevel@tonic-gate
347c478bdstevel@tonic-gate#include <stdio.h>
357c478bdstevel@tonic-gate#include <stdlib.h>
367c478bdstevel@tonic-gate#include <unistd.h>
377c478bdstevel@tonic-gate#include <ctype.h>
387c478bdstevel@tonic-gate#include <sys/types.h>
397c478bdstevel@tonic-gate#include <sys/mman.h>
407c478bdstevel@tonic-gate#include <libproc.h>
417c478bdstevel@tonic-gate#include <string.h>
427c478bdstevel@tonic-gate#include <limits.h>
437c478bdstevel@tonic-gate#include <sys/statfs.h>
447c478bdstevel@tonic-gate#include <sys/times.h>
457c478bdstevel@tonic-gate#include <sys/timex.h>
467c478bdstevel@tonic-gate#include <sys/utssys.h>
477c478bdstevel@tonic-gate#include <sys/utsname.h>
487c478bdstevel@tonic-gate#include <sys/ipc.h>
497c478bdstevel@tonic-gate#include <sys/ipc_impl.h>
507c478bdstevel@tonic-gate#include <sys/msg.h>
517c478bdstevel@tonic-gate#include <sys/msg_impl.h>
527c478bdstevel@tonic-gate#include <sys/sem.h>
537c478bdstevel@tonic-gate#include <sys/sem_impl.h>
547c478bdstevel@tonic-gate#include <sys/shm.h>
557c478bdstevel@tonic-gate#include <sys/shm_impl.h>
567c478bdstevel@tonic-gate#include <sys/dirent.h>
577c478bdstevel@tonic-gate#include <ustat.h>
587c478bdstevel@tonic-gate#include <fcntl.h>
597c478bdstevel@tonic-gate#include <time.h>
607c478bdstevel@tonic-gate#include <sys/termios.h>
617c478bdstevel@tonic-gate#include <sys/termiox.h>
627c478bdstevel@tonic-gate#include <sys/termio.h>
637c478bdstevel@tonic-gate#include <sys/ttold.h>
647c478bdstevel@tonic-gate#include <sys/jioctl.h>
657c478bdstevel@tonic-gate#include <sys/filio.h>
667c478bdstevel@tonic-gate#include <stropts.h>
677c478bdstevel@tonic-gate#include <poll.h>
687c478bdstevel@tonic-gate#include <sys/uio.h>
697c478bdstevel@tonic-gate#include <sys/resource.h>
707c478bdstevel@tonic-gate#include <sys/statvfs.h>
717c478bdstevel@tonic-gate#include <sys/time.h>
727c478bdstevel@tonic-gate#include <sys/aio.h>
737c478bdstevel@tonic-gate#include <sys/socket.h>
747c478bdstevel@tonic-gate#include <netinet/in.h>
757c478bdstevel@tonic-gate#include <sys/un.h>
767c478bdstevel@tonic-gate#include <sys/byteorder.h>
777c478bdstevel@tonic-gate#include <arpa/inet.h>
787c478bdstevel@tonic-gate#include <sys/audioio.h>
797c478bdstevel@tonic-gate#include <sys/cladm.h>
807c478bdstevel@tonic-gate#include <sys/synch.h>
817c478bdstevel@tonic-gate#include <sys/synch32.h>
827c478bdstevel@tonic-gate#include <sys/sysmacros.h>
837c478bdstevel@tonic-gate#include <sys/sendfile.h>
847c478bdstevel@tonic-gate#include <priv.h>
857c478bdstevel@tonic-gate#include <ucred.h>
867c478bdstevel@tonic-gate#include <sys/ucred.h>
877c478bdstevel@tonic-gate#include <sys/port_impl.h>
88821c4a9dp#include <sys/zone.h>
89821c4a9dp#include <sys/priv_impl.h>
90821c4a9dp#include <sys/priv.h>
9145916cdjpk#include <tsol/label.h>
92aa4a4f3nf#include <sys/nvpair.h>
93aa4a4f3nf#include <libnvpair.h>
94532877crd#include <sys/rctl_impl.h>
953e95bd4Anders Persson#include <sys/socketvar.h>
96a803cc2Gordon Ross#include <sys/fs/zfs.h>
97a803cc2Gordon Ross#include <sys/zfs_ioctl.h>
987c478bdstevel@tonic-gate
997c478bdstevel@tonic-gate#include "ramdata.h"
1007c478bdstevel@tonic-gate#include "systable.h"
1017c478bdstevel@tonic-gate#include "proto.h"
1027c478bdstevel@tonic-gate
1037c478bdstevel@tonic-gatevoid	show_sigset(private_t *, long, const char *);
1047c478bdstevel@tonic-gatevoid	show_ioctl(private_t *, int, long);
105a803cc2Gordon Rossvoid	show_zfs_ioc(private_t *, long);
1067c478bdstevel@tonic-gate
1073b862e9Roger A. Faulknerstatic void
1083b862e9Roger A. Faulknermk_ctime(char *str, size_t maxsize, time_t value)
1093b862e9Roger A. Faulkner{
1103b862e9Roger A. Faulkner	(void) strftime(str, maxsize, "%b %e %H:%M:%S %Z %Y",
1113b862e9Roger A. Faulkner	    localtime(&value));
1123b862e9Roger A. Faulkner}
1133b862e9Roger A. Faulkner
1147c478bdstevel@tonic-gatevoid
1157c478bdstevel@tonic-gateprtime(private_t *pri, const char *name, time_t value)
1167c478bdstevel@tonic-gate{
1177c478bdstevel@tonic-gate	char str[80];
1187c478bdstevel@tonic-gate
1193b862e9Roger A. Faulkner	mk_ctime(str, sizeof (str), value);
1203b862e9Roger A. Faulkner	(void) printf("%s\t%s%s  [ %lu ]\n",
1217c478bdstevel@tonic-gate	    pri->pname,
1227c478bdstevel@tonic-gate	    name,
1237c478bdstevel@tonic-gate	    str,
1243b862e9Roger A. Faulkner	    value);
1257c478bdstevel@tonic-gate}
1267c478bdstevel@tonic-gate
1277c478bdstevel@tonic-gatevoid
1283b862e9Roger A. Faulknerprtimeval(private_t *pri, const char *name, struct timeval *value)
1297c478bdstevel@tonic-gate{
1303b862e9Roger A. Faulkner	char str[80];
1313b862e9Roger A. Faulkner
1323b862e9Roger A. Faulkner	mk_ctime(str, sizeof (str), value->tv_sec);
1333b862e9Roger A. Faulkner	(void) printf("%s\t%s%s  [ %lu.%6.6lu ]\n",
1343b862e9Roger A. Faulkner	    pri->pname,
1353b862e9Roger A. Faulkner	    name,
1363b862e9Roger A. Faulkner	    str,
1373b862e9Roger A. Faulkner	    value->tv_sec,
1383b862e9Roger A. Faulkner	    value->tv_usec);
1397c478bdstevel@tonic-gate}
1407c478bdstevel@tonic-gate
1417c478bdstevel@tonic-gatevoid
1423b862e9Roger A. Faulknerprtimestruc(private_t *pri, const char *name, timestruc_t *value)
1433b862e9Roger A. Faulkner{
1443b862e9Roger A. Faulkner	char str[80];
1453b862e9Roger A. Faulkner
1463b862e9Roger A. Faulkner	mk_ctime(str, sizeof (str), value->tv_sec);
1473b862e9Roger A. Faulkner	(void) printf("%s\t%s%s  [ %lu.%9.9lu ]\n",
1483b862e9Roger A. Faulkner	    pri->pname,
1493b862e9Roger A. Faulkner	    name,
1503b862e9Roger A. Faulkner	    str,
1513b862e9Roger A. Faulkner	    value->tv_sec,
1523b862e9Roger A. Faulkner	    value->tv_nsec);
1533b862e9Roger A. Faulkner}
1543b862e9Roger A. Faulkner
1553b862e9Roger A. Faulknerstatic void
1563b862e9Roger A. Faulknershow_utimens(private_t *pri, long offset)
1573b862e9Roger A. Faulkner{
1583b862e9Roger A. Faulkner	struct {
1593b862e9Roger A. Faulkner		timespec_t atime;
1603b862e9Roger A. Faulkner		timespec_t mtime;
1613b862e9Roger A. Faulkner	} utimbuf;
1623b862e9Roger A. Faulkner
1633b862e9Roger A. Faulkner	if (offset == 0)
1643b862e9Roger A. Faulkner		return;
1653b862e9Roger A. Faulkner
1663b862e9Roger A. Faulkner	if (data_model == PR_MODEL_NATIVE) {
1673b862e9Roger A. Faulkner		if (Pread(Proc, &utimbuf, sizeof (utimbuf), offset)
1683b862e9Roger A. Faulkner		    != sizeof (utimbuf))
1693b862e9Roger A. Faulkner			return;
1703b862e9Roger A. Faulkner	} else {
1713b862e9Roger A. Faulkner		struct {
1723b862e9Roger A. Faulkner			timespec32_t atime;
1733b862e9Roger A. Faulkner			timespec32_t mtime;
1743b862e9Roger A. Faulkner		} utimbuf32;
1753b862e9Roger A. Faulkner
1763b862e9Roger A. Faulkner		if (Pread(Proc, &utimbuf32, sizeof (utimbuf32), offset)
1773b862e9Roger A. Faulkner		    != sizeof (utimbuf32))
1783b862e9Roger A. Faulkner			return;
1793b862e9Roger A. Faulkner
1803b862e9Roger A. Faulkner		TIMESPEC32_TO_TIMESPEC(&utimbuf.atime, &utimbuf32.atime);
1813b862e9Roger A. Faulkner		TIMESPEC32_TO_TIMESPEC(&utimbuf.mtime, &utimbuf32.mtime);
1823b862e9Roger A. Faulkner	}
1833b862e9Roger A. Faulkner
1843b862e9Roger A. Faulkner	/* print access and modification times */
1853b862e9Roger A. Faulkner	if (utimbuf.atime.tv_nsec == UTIME_OMIT)
1863b862e9Roger A. Faulkner		(void) printf("%s\tat = UTIME_OMIT\n", pri->pname);
1873b862e9Roger A. Faulkner	else if (utimbuf.atime.tv_nsec == UTIME_NOW)
1883b862e9Roger A. Faulkner		(void) printf("%s\tat = UTIME_NOW\n", pri->pname);
1893b862e9Roger A. Faulkner	else
1903b862e9Roger A. Faulkner		prtimestruc(pri, "at = ", &utimbuf.atime);
1913b862e9Roger A. Faulkner	if (utimbuf.mtime.tv_nsec == UTIME_OMIT)
1923b862e9Roger A. Faulkner		(void) printf("%s\tmt = UTIME_OMIT\n", pri->pname);
1933b862e9Roger A. Faulkner	else if (utimbuf.mtime.tv_nsec == UTIME_NOW)
1943b862e9Roger A. Faulkner		(void) printf("%s\tmt = UTIME_NOW\n", pri->pname);
1953b862e9Roger A. Faulkner	else
19635da9b4Pavel Filipensky		prtimestruc(pri, "mt = ", &utimbuf.mtime);
1977c478bdstevel@tonic-gate}
1987c478bdstevel@tonic-gate
1997c478bdstevel@tonic-gatevoid
2007c478bdstevel@tonic-gateshow_timeofday(private_t *pri)
2017c478bdstevel@tonic-gate{
2027c478bdstevel@tonic-gate	struct timeval tod;
2037c478bdstevel@tonic-gate	long offset;
2047c478bdstevel@tonic-gate
20527aa481Toomas Soome	if (pri->sys_nargs < 1 || (offset = pri->sys_args[0]) == 0)
2067c478bdstevel@tonic-gate		return;
2077c478bdstevel@tonic-gate
2087c478bdstevel@tonic-gate	if (data_model == PR_MODEL_NATIVE) {
2097c478bdstevel@tonic-gate		if (Pread(Proc, &tod, sizeof (tod), offset)
2107c478bdstevel@tonic-gate		    != sizeof (tod))
2117c478bdstevel@tonic-gate			return;
2127c478bdstevel@tonic-gate	} else {
2137c478bdstevel@tonic-gate		struct timeval32 tod32;
2147c478bdstevel@tonic-gate
2157c478bdstevel@tonic-gate		if (Pread(Proc, &tod32, sizeof (tod32), offset)
2167c478bdstevel@tonic-gate		    != sizeof (tod32))
2177c478bdstevel@tonic-gate			return;
2187c478bdstevel@tonic-gate
2197c478bdstevel@tonic-gate		TIMEVAL32_TO_TIMEVAL(&tod, &tod32);
2207c478bdstevel@tonic-gate	}
2217c478bdstevel@tonic-gate
2223b862e9Roger A. Faulkner	prtimeval(pri, "time: ", &tod);
2237c478bdstevel@tonic-gate}
2247c478bdstevel@tonic-gate
2257c478bdstevel@tonic-gatevoid
2267c478bdstevel@tonic-gateshow_itimerval(private_t *pri, long offset, const char *name)
2277c478bdstevel@tonic-gate{
2287c478bdstevel@tonic-gate	struct itimerval itimerval;
2297c478bdstevel@tonic-gate
2303b862e9Roger A. Faulkner	if (offset == 0)
2317c478bdstevel@tonic-gate		return;
2327c478bdstevel@tonic-gate
2337c478bdstevel@tonic-gate	if (data_model == PR_MODEL_NATIVE) {
2347c478bdstevel@tonic-gate		if (Pread(Proc, &itimerval, sizeof (itimerval), offset)
2357c478bdstevel@tonic-gate		    != sizeof (itimerval))
2367c478bdstevel@tonic-gate			return;
2377c478bdstevel@tonic-gate	} else {
2387c478bdstevel@tonic-gate		struct itimerval32 itimerval32;
2397c478bdstevel@tonic-gate
2407c478bdstevel@tonic-gate		if (Pread(Proc, &itimerval32, sizeof (itimerval32), offset)
2417c478bdstevel@tonic-gate		    != sizeof (itimerval32))
2427c478bdstevel@tonic-gate			return;
2437c478bdstevel@tonic-gate
2447c478bdstevel@tonic-gate		ITIMERVAL32_TO_ITIMERVAL(&itimerval, &itimerval32);
2457c478bdstevel@tonic-gate	}
2467c478bdstevel@tonic-gate
2477c478bdstevel@tonic-gate	(void) printf(
2487c478bdstevel@tonic-gate	    "%s\t%s:  interval: %4ld.%6.6ld sec  value: %4ld.%6.6ld sec\n",
2497c478bdstevel@tonic-gate	    pri->pname,
2507c478bdstevel@tonic-gate	    name,
2517c478bdstevel@tonic-gate	    itimerval.it_interval.tv_sec,
2527c478bdstevel@tonic-gate	    itimerval.it_interval.tv_usec,
2537c478bdstevel@tonic-gate	    itimerval.it_value.tv_sec,
2547c478bdstevel@tonic-gate	    itimerval.it_value.tv_usec);
2557c478bdstevel@tonic-gate}
2567c478bdstevel@tonic-gate
2577c478bdstevel@tonic-gatevoid
2587c478bdstevel@tonic-gateshow_timeval(private_t *pri, long offset, const char *name)
2597c478bdstevel@tonic-gate{
2607c478bdstevel@tonic-gate	struct timeval timeval;
2617c478bdstevel@tonic-gate
2623b862e9Roger A. Faulkner	if (offset == 0)
2637c478bdstevel@tonic-gate		return;
2647c478bdstevel@tonic-gate
2657c478bdstevel@tonic-gate	if (data_model == PR_MODEL_NATIVE) {
2667c478bdstevel@tonic-gate		if (Pread(Proc, &timeval, sizeof (timeval), offset)
2677c478bdstevel@tonic-gate		    != sizeof (timeval))
2687c478bdstevel@tonic-gate			return;
2697c478bdstevel@tonic-gate	} else {
2707c478bdstevel@tonic-gate		struct timeval32 timeval32;
2717c478bdstevel@tonic-gate
2727c478bdstevel@tonic-gate		if (Pread(Proc, &timeval32, sizeof (timeval32), offset)
2737c478bdstevel@tonic-gate		    != sizeof (timeval32))
2747c478bdstevel@tonic-gate			return;
2757c478bdstevel@tonic-gate
2767c478bdstevel@tonic-gate		TIMEVAL32_TO_TIMEVAL(&timeval, &timeval32);
2777c478bdstevel@tonic-gate	}
2787c478bdstevel@tonic-gate
2797c478bdstevel@tonic-gate	(void) printf(
2807c478bdstevel@tonic-gate	    "%s\t%s: %ld.%6.6ld sec\n",
2817c478bdstevel@tonic-gate	    pri->pname,
2827c478bdstevel@tonic-gate	    name,
2837c478bdstevel@tonic-gate	    timeval.tv_sec,
2847c478bdstevel@tonic-gate	    timeval.tv_usec);
2857c478bdstevel@tonic-gate}
2867c478bdstevel@tonic-gate
2877c478bdstevel@tonic-gatevoid
2887c478bdstevel@tonic-gateshow_timestruc(private_t *pri, long offset, const char *name)
2897c478bdstevel@tonic-gate{
2907c478bdstevel@tonic-gate	timestruc_t timestruc;
2917c478bdstevel@tonic-gate
2923b862e9Roger A. Faulkner	if (offset == 0)
2937c478bdstevel@tonic-gate		return;
2947c478bdstevel@tonic-gate
2957c478bdstevel@tonic-gate	if (data_model == PR_MODEL_NATIVE) {
2967c478bdstevel@tonic-gate		if (Pread(Proc, &timestruc, sizeof (timestruc), offset)
2977c478bdstevel@tonic-gate		    != sizeof (timestruc))
2987c478bdstevel@tonic-gate			return;
2997c478bdstevel@tonic-gate	} else {
3007c478bdstevel@tonic-gate		timestruc32_t timestruc32;
3017c478bdstevel@tonic-gate
3027c478bdstevel@tonic-gate		if (Pread(Proc, &timestruc32, sizeof (timestruc32), offset)
3037c478bdstevel@tonic-gate		    != sizeof (timestruc32))
3047c478bdstevel@tonic-gate			return;
3057c478bdstevel@tonic-gate
3067c478bdstevel@tonic-gate		TIMESPEC32_TO_TIMESPEC(&timestruc, &timestruc32);
3077c478bdstevel@tonic-gate	}
3087c478bdstevel@tonic-gate
3097c478bdstevel@tonic-gate	(void) printf(
3107c478bdstevel@tonic-gate	    "%s\t%s: %ld.%9.9ld sec\n",
3117c478bdstevel@tonic-gate	    pri->pname,
3127c478bdstevel@tonic-gate	    name,
3137c478bdstevel@tonic-gate	    timestruc.tv_sec,
3147c478bdstevel@tonic-gate	    timestruc.tv_nsec);
3157c478bdstevel@tonic-gate}
3167c478bdstevel@tonic-gate
3177c478bdstevel@tonic-gatevoid
3187c478bdstevel@tonic-gateshow_stime(private_t *pri)
3197c478bdstevel@tonic-gate{
3207c478bdstevel@tonic-gate	if (pri->sys_nargs >= 1) {
3217c478bdstevel@tonic-gate		/* print new system time */
3227c478bdstevel@tonic-gate		prtime(pri, "systime = ", (time_t)pri->sys_args[0]);
3237c478bdstevel@tonic-gate	}
3247c478bdstevel@tonic-gate}
3257c478bdstevel@tonic-gate
3267c478bdstevel@tonic-gatevoid
3277c478bdstevel@tonic-gateshow_times(private_t *pri)
3287c478bdstevel@tonic-gate{
3297c478bdstevel@tonic-gate	long hz = sysconf(_SC_CLK_TCK);
3307c478bdstevel@tonic-gate	long offset;
3317c478bdstevel@tonic-gate	struct tms tms;
3327c478bdstevel@tonic-gate
33327aa481Toomas Soome	if (pri->sys_nargs < 1 || (offset = pri->sys_args[0]) == 0)
3347c478bdstevel@tonic-gate		return;
3357c478bdstevel@tonic-gate
3367c478bdstevel@tonic-gate	if (data_model == PR_MODEL_NATIVE) {
3377c478bdstevel@tonic-gate		if (Pread(Proc, &tms, sizeof (tms), offset)
3387c478bdstevel@tonic-gate		    != sizeof (tms))
3397c478bdstevel@tonic-gate			return;
3407c478bdstevel@tonic-gate	} else {
3417c478bdstevel@tonic-gate		struct tms32 tms32;
3427c478bdstevel@tonic-gate
3437c478bdstevel@tonic-gate		if (Pread(Proc, &tms32, sizeof (tms32), offset)
3447c478bdstevel@tonic-gate		    != sizeof (tms32))
3457c478bdstevel@tonic-gate			return;
3467c478bdstevel@tonic-gate
3477c478bdstevel@tonic-gate		/*
3487c478bdstevel@tonic-gate		 * This looks a bit odd (since the values are actually
3497c478bdstevel@tonic-gate		 * signed), but we need to suppress sign extension to
3507c478bdstevel@tonic-gate		 * preserve compatibility (we've always printed these
3517c478bdstevel@tonic-gate		 * numbers as unsigned quantities).
3527c478bdstevel@tonic-gate		 */
3537c478bdstevel@tonic-gate		tms.tms_utime = (unsigned)tms32.tms_utime;
3547c478bdstevel@tonic-gate		tms.tms_stime = (unsigned)tms32.tms_stime;
3557c478bdstevel@tonic-gate		tms.tms_cutime = (unsigned)tms32.tms_cutime;
3567c478bdstevel@tonic-gate		tms.tms_cstime = (unsigned)tms32.tms_cstime;
3577c478bdstevel@tonic-gate	}
3587c478bdstevel@tonic-gate
3597c478bdstevel@tonic-gate	(void) printf(
3607c478bdstevel@tonic-gate	    "%s\tutim=%-6lu stim=%-6lu cutim=%-6lu cstim=%-6lu (HZ=%ld)\n",
3617c478bdstevel@tonic-gate	    pri->pname,
3627c478bdstevel@tonic-gate	    tms.tms_utime,
3637c478bdstevel@tonic-gate	    tms.tms_stime,
3647c478bdstevel@tonic-gate	    tms.tms_cutime,
3657c478bdstevel@tonic-gate	    tms.tms_cstime,
3667c478bdstevel@tonic-gate	    hz);
3677c478bdstevel@tonic-gate}
3687c478bdstevel@tonic-gate
3697c478bdstevel@tonic-gatevoid
3707c478bdstevel@tonic-gateshow_uname(private_t *pri, long offset)
3717c478bdstevel@tonic-gate{
3727c478bdstevel@tonic-gate	/*
3737c478bdstevel@tonic-gate	 * Old utsname buffer (no longer accessible in <sys/utsname.h>).
3747c478bdstevel@tonic-gate	 */
3757c478bdstevel@tonic-gate	struct {
3767c478bdstevel@tonic-gate		char	sysname[9];
3777c478bdstevel@tonic-gate		char	nodename[9];
3787c478bdstevel@tonic-gate		char	release[9];
3797c478bdstevel@tonic-gate		char	version[9];
3807c478bdstevel@tonic-gate		char	machine[9];
3817c478bdstevel@tonic-gate	} ubuf;
3827c478bdstevel@tonic-gate
38327aa481Toomas Soome	if (offset != 0 &&
3847c478bdstevel@tonic-gate	    Pread(Proc, &ubuf, sizeof (ubuf), offset) == sizeof (ubuf)) {
3857c478bdstevel@tonic-gate		(void) printf(
386019c3c4raf		    "%s\tsys=%-9.9snod=%-9.9srel=%-9.9sver=%-9.9smch=%.9s\n",
387019c3c4raf		    pri->pname,
388019c3c4raf		    ubuf.sysname,
389019c3c4raf		    ubuf.nodename,
390019c3c4raf		    ubuf.release,
391019c3c4raf		    ubuf.version,
392019c3c4raf		    ubuf.machine);
3937c478bdstevel@tonic-gate	}
3947c478bdstevel@tonic-gate}
3957c478bdstevel@tonic-gate
3967c478bdstevel@tonic-gate/* XX64 -- definition of 'struct ustat' is strange -- check out the defn */
3977c478bdstevel@tonic-gatevoid
3987c478bdstevel@tonic-gateshow_ustat(private_t *pri, long offset)
3997c478bdstevel@tonic-gate{
4007c478bdstevel@tonic-gate	struct ustat ubuf;
4017c478bdstevel@tonic-gate
40227aa481Toomas Soome	if (offset != 0 &&
4037c478bdstevel@tonic-gate	    Pread(Proc, &ubuf, sizeof (ubuf), offset) == sizeof (ubuf)) {
4047c478bdstevel@tonic-gate		(void) printf(
405019c3c4raf		    "%s\ttfree=%-6ld tinode=%-5lu fname=%-6.6s fpack=%-.6s\n",
406019c3c4raf		    pri->pname,
407019c3c4raf		    ubuf.f_tfree,
408019c3c4raf		    ubuf.f_tinode,
409019c3c4raf		    ubuf.f_fname,
410019c3c4raf		    ubuf.f_fpack);
4117c478bdstevel@tonic-gate	}
4127c478bdstevel@tonic-gate}
4137c478bdstevel@tonic-gate
4147c478bdstevel@tonic-gate#ifdef _LP64
4157c478bdstevel@tonic-gatevoid
4167c478bdstevel@tonic-gateshow_ustat32(private_t *pri, long offset)
4177c478bdstevel@tonic-gate{
4187c478bdstevel@tonic-gate	struct ustat32 ubuf;
4197c478bdstevel@tonic-gate
42027aa481Toomas Soome	if (offset != 0 &&
4217c478bdstevel@tonic-gate	    Pread(Proc, &ubuf, sizeof (ubuf), offset) == sizeof (ubuf)) {
4227c478bdstevel@tonic-gate		(void) printf(
423019c3c4raf		    "%s\ttfree=%-6d tinode=%-5u fname=%-6.6s fpack=%-.6s\n",
424019c3c4raf		    pri->pname,
425019c3c4raf		    ubuf.f_tfree,
426019c3c4raf		    ubuf.f_tinode,
427019c3c4raf		    ubuf.f_fname,
428019c3c4raf		    ubuf.f_fpack);
4297c478bdstevel@tonic-gate	}
4307c478bdstevel@tonic-gate}
4317c478bdstevel@tonic-gate#endif	/* _LP64 */
4327c478bdstevel@tonic-gate
4337c478bdstevel@tonic-gatevoid
4347c478bdstevel@tonic-gateshow_fusers(private_t *pri, long offset, long nproc)
4357c478bdstevel@tonic-gate{
4367c478bdstevel@tonic-gate	f_user_t fubuf;
4377c478bdstevel@tonic-gate	int serial = (nproc > 4);
4387c478bdstevel@tonic-gate
4393b862e9Roger A. Faulkner	if (offset == 0)
4407c478bdstevel@tonic-gate		return;
4417c478bdstevel@tonic-gate
4427c478bdstevel@tonic-gate	/* enter region of lengthy output */
4437c478bdstevel@tonic-gate	if (serial)
4447c478bdstevel@tonic-gate		Eserialize();
4457c478bdstevel@tonic-gate
4467c478bdstevel@tonic-gate	while (nproc > 0 &&
4477c478bdstevel@tonic-gate	    Pread(Proc, &fubuf, sizeof (fubuf), offset) == sizeof (fubuf)) {
448f48205bcasper		(void) printf("%s\tpid=%-5d uid=%-5u flags=%s\n",
4497c478bdstevel@tonic-gate		    pri->pname,
4507c478bdstevel@tonic-gate		    (int)fubuf.fu_pid,
451f48205bcasper		    fubuf.fu_uid,
4527c478bdstevel@tonic-gate		    fuflags(pri, fubuf.fu_flags));
4537c478bdstevel@tonic-gate		nproc--;
4547c478bdstevel@tonic-gate		offset += sizeof (fubuf);
4557c478bdstevel@tonic-gate	}
4567c478bdstevel@tonic-gate
4577c478bdstevel@tonic-gate	/* exit region of lengthy output */
4587c478bdstevel@tonic-gate	if (serial)
4597c478bdstevel@tonic-gate		Xserialize();
4607c478bdstevel@tonic-gate}
4617c478bdstevel@tonic-gate
4627c478bdstevel@tonic-gatevoid
4637c478bdstevel@tonic-gateshow_utssys(private_t *pri, long r0)
4647c478bdstevel@tonic-gate{
4657c478bdstevel@tonic-gate	if (pri->sys_nargs >= 3) {
4667c478bdstevel@tonic-gate		switch (pri->sys_args[2]) {
4677c478bdstevel@tonic-gate		case UTS_UNAME:
4687c478bdstevel@tonic-gate			show_uname(pri, (long)pri->sys_args[0]);
4697c478bdstevel@tonic-gate			break;
4707c478bdstevel@tonic-gate		case UTS_USTAT:
4717c478bdstevel@tonic-gate			show_ustat(pri, (long)pri->sys_args[0]);
4727c478bdstevel@tonic-gate			break;
4737c478bdstevel@tonic-gate		case UTS_FUSERS:
4747c478bdstevel@tonic-gate			show_fusers(pri, (long)pri->sys_args[3], r0);
4757c478bdstevel@tonic-gate			break;
4767c478bdstevel@tonic-gate		}
4777c478bdstevel@tonic-gate	}
4787c478bdstevel@tonic-gate}
4797c478bdstevel@tonic-gate
4807c478bdstevel@tonic-gate#ifdef _LP64
4817c478bdstevel@tonic-gatevoid
4827c478bdstevel@tonic-gateshow_utssys32(private_t *pri, long r0)
4837c478bdstevel@tonic-gate{
4847c478bdstevel@tonic-gate	if (pri->sys_nargs >= 3) {
4857c478bdstevel@tonic-gate		switch (pri->sys_args[2]) {
4867c478bdstevel@tonic-gate		case UTS_UNAME:
4877c478bdstevel@tonic-gate			show_uname(pri, (long)pri->sys_args[0]);
4887c478bdstevel@tonic-gate			break;
4897c478bdstevel@tonic-gate		case UTS_USTAT:
4907c478bdstevel@tonic-gate			show_ustat32(pri, (long)pri->sys_args[0]);
4917c478bdstevel@tonic-gate			break;
4927c478bdstevel@tonic-gate		case UTS_FUSERS:
4937c478bdstevel@tonic-gate			show_fusers(pri, (long)pri->sys_args[3], r0);
4947c478bdstevel@tonic-gate			break;
4957c478bdstevel@tonic-gate		}
4967c478bdstevel@tonic-gate	}
4977c478bdstevel@tonic-gate}
4987c478bdstevel@tonic-gate#endif	/* _LP64 */
4997c478bdstevel@tonic-gate
5007c478bdstevel@tonic-gatevoid
5017c478bdstevel@tonic-gateshow_cladm(private_t *pri, int code, int function, long offset)
5027c478bdstevel@tonic-gate{
5037c478bdstevel@tonic-gate	int	arg;
5047c478bdstevel@tonic-gate
5057c478bdstevel@tonic-gate	switch (code) {
5067c478bdstevel@tonic-gate	case CL_INITIALIZE:
5077c478bdstevel@tonic-gate		switch (function) {
5087c478bdstevel@tonic-gate		case CL_GET_BOOTFLAG:
5097c478bdstevel@tonic-gate			if (Pread(Proc, &arg, sizeof (arg), offset)
5107c478bdstevel@tonic-gate			    == sizeof (arg)) {
5117c478bdstevel@tonic-gate				if (arg & CLUSTER_CONFIGURED)
5127c478bdstevel@tonic-gate					(void) printf("%s\tbootflags="
5137c478bdstevel@tonic-gate					    "CLUSTER_CONFIGURED", pri->pname);
5147c478bdstevel@tonic-gate				if (arg & CLUSTER_BOOTED)
5157c478bdstevel@tonic-gate					(void) printf("|CLUSTER_BOOTED\n");
5167c478bdstevel@tonic-gate			}
5177c478bdstevel@tonic-gate			break;
5187c478bdstevel@tonic-gate		}
5197c478bdstevel@tonic-gate		break;
5207c478bdstevel@tonic-gate	case CL_CONFIG:
5217c478bdstevel@tonic-gate		switch (function) {
5227c478bdstevel@tonic-gate		case CL_NODEID:
5237c478bdstevel@tonic-gate		case CL_HIGHEST_NODEID:
5247c478bdstevel@tonic-gate			if (Pread(Proc, &arg, sizeof (arg), offset)
5257c478bdstevel@tonic-gate			    == sizeof (arg))
5267c478bdstevel@tonic-gate				(void) printf("%s\tnodeid=%d\n",
527019c3c4raf				    pri->pname, arg);
5287c478bdstevel@tonic-gate		}
5297c478bdstevel@tonic-gate		break;
5307c478bdstevel@tonic-gate	}
5317c478bdstevel@tonic-gate}
5327c478bdstevel@tonic-gate
533883492draf#define	ALL_LOCK_TYPES						\
53427aa481Toomas Soome	(USYNC_PROCESS | LOCK_ERRORCHECK | LOCK_RECURSIVE |	\
53527aa481Toomas Soome	LOCK_PRIO_INHERIT | LOCK_PRIO_PROTECT | LOCK_ROBUST |	\
536883492draf	USYNC_PROCESS_ROBUST)
5377c478bdstevel@tonic-gate
5387c478bdstevel@tonic-gate/* return cv and mutex types */
5397c478bdstevel@tonic-gateconst char *
5407c478bdstevel@tonic-gatesynch_type(private_t *pri, uint_t type)
5417c478bdstevel@tonic-gate{
5427c478bdstevel@tonic-gate	char *str = pri->code_buf;
5437c478bdstevel@tonic-gate
5447c478bdstevel@tonic-gate	if (type & USYNC_PROCESS)
5457c478bdstevel@tonic-gate		(void) strcpy(str, "USYNC_PROCESS");
5467c478bdstevel@tonic-gate	else
5477c478bdstevel@tonic-gate		(void) strcpy(str, "USYNC_THREAD");
5487c478bdstevel@tonic-gate
5497c478bdstevel@tonic-gate	if (type & LOCK_ERRORCHECK)
5507c478bdstevel@tonic-gate		(void) strcat(str, "|LOCK_ERRORCHECK");
5517c478bdstevel@tonic-gate	if (type & LOCK_RECURSIVE)
5527c478bdstevel@tonic-gate		(void) strcat(str, "|LOCK_RECURSIVE");
5537c478bdstevel@tonic-gate	if (type & LOCK_PRIO_INHERIT)
5547c478bdstevel@tonic-gate		(void) strcat(str, "|LOCK_PRIO_INHERIT");
5557c478bdstevel@tonic-gate	if (type & LOCK_PRIO_PROTECT)
5567c478bdstevel@tonic-gate		(void) strcat(str, "|LOCK_PRIO_PROTECT");
557883492draf	if (type & LOCK_ROBUST)
558883492draf		(void) strcat(str, "|LOCK_ROBUST");
559883492draf	if (type & USYNC_PROCESS_ROBUST)
560883492draf		(void) strcat(str, "|USYNC_PROCESS_ROBUST");
5617c478bdstevel@tonic-gate
5627c478bdstevel@tonic-gate	if ((type &= ~ALL_LOCK_TYPES) != 0)
5637c478bdstevel@tonic-gate		(void) sprintf(str + strlen(str), "|0x%.4X", type);
5647c478bdstevel@tonic-gate
5657c478bdstevel@tonic-gate	return ((const char *)str);
5667c478bdstevel@tonic-gate}
5677c478bdstevel@tonic-gate
5687c478bdstevel@tonic-gatevoid
5697c478bdstevel@tonic-gateshow_mutex(private_t *pri, long offset)
5707c478bdstevel@tonic-gate{
5717c478bdstevel@tonic-gate	lwp_mutex_t mutex;
5727c478bdstevel@tonic-gate
5737c478bdstevel@tonic-gate	if (Pread(Proc, &mutex, sizeof (mutex), offset) == sizeof (mutex)) {
5747c478bdstevel@tonic-gate		(void) printf("%s\tmutex type: %s\n",
575019c3c4raf		    pri->pname,
576019c3c4raf		    synch_type(pri, mutex.mutex_type));
5777c478bdstevel@tonic-gate	}
5787c478bdstevel@tonic-gate}
5797c478bdstevel@tonic-gate
5807c478bdstevel@tonic-gatevoid
5817c478bdstevel@tonic-gateshow_condvar(private_t *pri, long offset)
5827c478bdstevel@tonic-gate{
5837c478bdstevel@tonic-gate	lwp_cond_t condvar;
5847c478bdstevel@tonic-gate
5857c478bdstevel@tonic-gate	if (Pread(Proc, &condvar, sizeof (condvar), offset)
5867c478bdstevel@tonic-gate	    == sizeof (condvar)) {
5877c478bdstevel@tonic-gate		(void) printf("%s\tcondvar type: %s\n",
588019c3c4raf		    pri->pname,
589019c3c4raf		    synch_type(pri, condvar.cond_type));
5907c478bdstevel@tonic-gate	}
5917c478bdstevel@tonic-gate}
5927c478bdstevel@tonic-gate
5937c478bdstevel@tonic-gatevoid
5947c478bdstevel@tonic-gateshow_sema(private_t *pri, long offset)
5957c478bdstevel@tonic-gate{
5967c478bdstevel@tonic-gate	lwp_sema_t sema;
5977c478bdstevel@tonic-gate
5987c478bdstevel@tonic-gate	if (Pread(Proc, &sema, sizeof (sema), offset) == sizeof (sema)) {
5997c478bdstevel@tonic-gate		(void) printf("%s\tsema type: %s  count = %u\n",
600019c3c4raf		    pri->pname,
601019c3c4raf		    synch_type(pri, sema.sema_type),
602019c3c4raf		    sema.sema_count);
6037c478bdstevel@tonic-gate	}
6047c478bdstevel@tonic-gate}
6057c478bdstevel@tonic-gate
6067c478bdstevel@tonic-gatevoid
6077c478bdstevel@tonic-gateshow_rwlock(private_t *pri, long offset)
6087c478bdstevel@tonic-gate{
6097c478bdstevel@tonic-gate	lwp_rwlock_t rwlock;
6107c478bdstevel@tonic-gate
6117c478bdstevel@tonic-gate	if (Pread(Proc, &rwlock, sizeof (rwlock), offset) == sizeof (rwlock)) {
6127c478bdstevel@tonic-gate		(void) printf("%s\trwlock type: %s  readers = %d\n",
613019c3c4raf		    pri->pname,
614019c3c4raf		    synch_type(pri, rwlock.rwlock_type),
615019c3c4raf		    rwlock.rwlock_readers);
6167c478bdstevel@tonic-gate	}
6177c478bdstevel@tonic-gate}
6187c478bdstevel@tonic-gate
6197c478bdstevel@tonic-gate/* represent character as itself ('c') or octal (012) */
6207c478bdstevel@tonic-gatechar *
6217c478bdstevel@tonic-gateshow_char(char *buf, int c)
6227c478bdstevel@tonic-gate{
6237c478bdstevel@tonic-gate	const char *fmt;
6247c478bdstevel@tonic-gate
6257c478bdstevel@tonic-gate	if (c >= ' ' && c < 0177)
6267c478bdstevel@tonic-gate		fmt = "'%c'";
6277c478bdstevel@tonic-gate	else
6287c478bdstevel@tonic-gate		fmt = "%.3o";
6297c478bdstevel@tonic-gate
6307c478bdstevel@tonic-gate	(void) sprintf(buf, fmt, c&0xff);
6317c478bdstevel@tonic-gate	return (buf);
6327c478bdstevel@tonic-gate}
6337c478bdstevel@tonic-gate
6347c478bdstevel@tonic-gatevoid
6357c478bdstevel@tonic-gateshow_termio(private_t *pri, long offset)
6367c478bdstevel@tonic-gate{
6377c478bdstevel@tonic-gate	struct termio termio;
6387c478bdstevel@tonic-gate	char cbuf[8];
6397c478bdstevel@tonic-gate	int i;
6407c478bdstevel@tonic-gate
6417c478bdstevel@tonic-gate	if (Pread(Proc, &termio, sizeof (termio), offset) == sizeof (termio)) {
6427c478bdstevel@tonic-gate		(void) printf(
6437c478bdstevel@tonic-gate		"%s\tiflag=0%.6o oflag=0%.6o cflag=0%.6o lflag=0%.6o line=%d\n",
644019c3c4raf		    pri->pname,
645019c3c4raf		    termio.c_iflag,
646019c3c4raf		    termio.c_oflag,
647019c3c4raf		    termio.c_cflag,
648019c3c4raf		    termio.c_lflag,
649019c3c4raf		    termio.c_line);
6507c478bdstevel@tonic-gate		(void) printf("%s\t    cc: ", pri->pname);
6517c478bdstevel@tonic-gate		for (i = 0; i < NCC; i++)
6527c478bdstevel@tonic-gate			(void) printf(" %s",
653019c3c4raf			    show_char(cbuf, (int)termio.c_cc[i]));
6547c478bdstevel@tonic-gate		(void) fputc('\n', stdout);
6557c478bdstevel@tonic-gate	}
6567c478bdstevel@tonic-gate}
6577c478bdstevel@tonic-gate
6587c478bdstevel@tonic-gatevoid
6597c478bdstevel@tonic-gateshow_termios(private_t *pri, long offset)
6607c478bdstevel@tonic-gate{
6617c478bdstevel@tonic-gate	struct termios termios;
6627c478bdstevel@tonic-gate	char cbuf[8];
6637c478bdstevel@tonic-gate	int i;
6647c478bdstevel@tonic-gate
6657c478bdstevel@tonic-gate	if (Pread(Proc, &termios, sizeof (termios), offset)
6667c478bdstevel@tonic-gate	    == sizeof (termios)) {
6677c478bdstevel@tonic-gate		(void) printf(
668019c3c4raf		    "%s\tiflag=0%.6o oflag=0%.6o cflag=0%.6o lflag=0%.6o\n",
669019c3c4raf		    pri->pname,
670019c3c4raf		    termios.c_iflag,
671019c3c4raf		    termios.c_oflag,
672019c3c4raf		    termios.c_cflag,
673019c3c4raf		    termios.c_lflag);
6747c478bdstevel@tonic-gate		(void) printf("%s\t    cc: ", pri->pname);
6757c478bdstevel@tonic-gate		for (i = 0; i < NCCS; i++) {
6767c478bdstevel@tonic-gate			if (i == NCC)	/* show new chars on new line */
6777c478bdstevel@tonic-gate				(void) printf("\n%s\t\t", pri->pname);
6787c478bdstevel@tonic-gate			(void) printf(" %s",
679019c3c4raf			    show_char(cbuf, (int)termios.c_cc[i]));
6807c478bdstevel@tonic-gate		}
6817c478bdstevel@tonic-gate		(void) fputc('\n', stdout);
6827c478bdstevel@tonic-gate	}
6837c478bdstevel@tonic-gate}
6847c478bdstevel@tonic-gate
6857c478bdstevel@tonic-gatevoid
6867c478bdstevel@tonic-gateshow_termiox(private_t *pri, long offset)
6877c478bdstevel@tonic-gate{
6887c478bdstevel@tonic-gate	struct termiox termiox;
6897c478bdstevel@tonic-gate	int i;
6907c478bdstevel@tonic-gate
6917c478bdstevel@tonic-gate	if (Pread(Proc, &termiox, sizeof (termiox), offset)
6927c478bdstevel@tonic-gate	    == sizeof (termiox)) {
6937c478bdstevel@tonic-gate		(void) printf("%s\thflag=0%.3o cflag=0%.3o rflag=0%.3o",
694019c3c4raf		    pri->pname,
695019c3c4raf		    termiox.x_hflag,
696019c3c4raf		    termiox.x_cflag,
697019c3c4raf		    termiox.x_rflag[0]);
6987c478bdstevel@tonic-gate		for (i = 1; i < NFF; i++)
6997c478bdstevel@tonic-gate			(void) printf(",0%.3o", termiox.x_rflag[i]);
7007c478bdstevel@tonic-gate		(void) printf(" sflag=0%.3o\n",
701019c3c4raf		    termiox.x_sflag);
7027c478bdstevel@tonic-gate	}
7037c478bdstevel@tonic-gate}
7047c478bdstevel@tonic-gate
7057c478bdstevel@tonic-gatevoid
7067c478bdstevel@tonic-gateshow_sgttyb(private_t *pri, long offset)
7077c478bdstevel@tonic-gate{
7087c478bdstevel@tonic-gate	struct sgttyb sgttyb;
7097c478bdstevel@tonic-gate
7107c478bdstevel@tonic-gate	if (Pread(Proc, &sgttyb, sizeof (sgttyb), offset) == sizeof (sgttyb)) {
7117c478bdstevel@tonic-gate		char erase[8];
7127c478bdstevel@tonic-gate		char kill[8];
7137c478bdstevel@tonic-gate
7147c478bdstevel@tonic-gate		(void) printf(
7157c478bdstevel@tonic-gate		"%s\tispeed=%-2d ospeed=%-2d erase=%s kill=%s flags=0x%.8x\n",
716019c3c4raf		    pri->pname,
717019c3c4raf		    sgttyb.sg_ispeed&0xff,
718019c3c4raf		    sgttyb.sg_ospeed&0xff,
719019c3c4raf		    show_char(erase, sgttyb.sg_erase),
720019c3c4raf		    show_char(kill, sgttyb.sg_kill),
721019c3c4raf		    sgttyb.sg_flags);
7227c478bdstevel@tonic-gate	}
7237c478bdstevel@tonic-gate}
7247c478bdstevel@tonic-gate
7257c478bdstevel@tonic-gatevoid
7267c478bdstevel@tonic-gateshow_ltchars(private_t *pri, long offset)
7277c478bdstevel@tonic-gate{
7287c478bdstevel@tonic-gate	struct ltchars ltchars;
7297c478bdstevel@tonic-gate	char *p;
7307c478bdstevel@tonic-gate	char cbuf[8];
7317c478bdstevel@tonic-gate	int i;
7327c478bdstevel@tonic-gate
7337c478bdstevel@tonic-gate	if (Pread(Proc, &ltchars, sizeof (ltchars), offset)
7347c478bdstevel@tonic-gate	    == sizeof (ltchars)) {
7357c478bdstevel@tonic-gate		(void) printf("%s\t    cc: ", pri->pname);
7367c478bdstevel@tonic-gate		for (p = (char *)&ltchars, i = 0; i < sizeof (ltchars); i++)
7377c478bdstevel@tonic-gate			(void) printf(" %s", show_char(cbuf, (int)*p++));
7387c478bdstevel@tonic-gate		(void) fputc('\n', stdout);
7397c478bdstevel@tonic-gate	}
7407c478bdstevel@tonic-gate}
7417c478bdstevel@tonic-gate
7427c478bdstevel@tonic-gatevoid
7437c478bdstevel@tonic-gateshow_tchars(private_t *pri, long offset)
7447c478bdstevel@tonic-gate{
7457c478bdstevel@tonic-gate	struct tchars tchars;
7467c478bdstevel@tonic-gate	char *p;
7477c478bdstevel@tonic-gate	char cbuf[8];
7487c478bdstevel@tonic-gate	int i;
7497c478bdstevel@tonic-gate
7507c478bdstevel@tonic-gate	if (Pread(Proc, &tchars, sizeof (tchars), offset) == sizeof (tchars)) {
7517c478bdstevel@tonic-gate		(void) printf("%s\t    cc: ", pri->pname);
7527c478bdstevel@tonic-gate		for (p = (char *)&tchars, i = 0; i < sizeof (tchars); i++)
7537c478bdstevel@tonic-gate			(void) printf(" %s", show_char(cbuf, (int)*p++));
7547c478bdstevel@tonic-gate		(void) fputc('\n', stdout);
7557c478bdstevel@tonic-gate	}
7567c478bdstevel@tonic-gate}
7577c478bdstevel@tonic-gate
7587c478bdstevel@tonic-gatevoid
7597c478bdstevel@tonic-gateshow_termcb(private_t *pri, long offset)
7607c478bdstevel@tonic-gate{
7617c478bdstevel@tonic-gate	struct termcb termcb;
7627c478bdstevel@tonic-gate
7637c478bdstevel@tonic-gate	if (Pread(Proc, &termcb, sizeof (termcb), offset) == sizeof (termcb)) {
7647c478bdstevel@tonic-gate		(void) printf(
765019c3c4raf		    "%s\tflgs=0%.2o termt=%d crow=%d ccol=%d vrow=%d lrow=%d\n",
766019c3c4raf		    pri->pname,
767019c3c4raf		    termcb.st_flgs&0xff,
768019c3c4raf		    termcb.st_termt&0xff,
769019c3c4raf		    termcb.st_crow&0xff,
770019c3c4raf		    termcb.st_ccol&0xff,
771019c3c4raf		    termcb.st_vrow&0xff,
772019c3c4raf		    termcb.st_lrow&0xff);
7737c478bdstevel@tonic-gate	}
7747c478bdstevel@tonic-gate}
7757c478bdstevel@tonic-gate
7767c478bdstevel@tonic-gate/* integer value pointed to by ioctl() arg */
7777c478bdstevel@tonic-gatevoid
7787c478bdstevel@tonic-gateshow_strint(private_t *pri, int code, long offset)
7797c478bdstevel@tonic-gate{
7807c478bdstevel@tonic-gate	int val;
7817c478bdstevel@tonic-gate
7827c478bdstevel@tonic-gate	if (Pread(Proc, &val, sizeof (val), offset) == sizeof (val)) {
7837c478bdstevel@tonic-gate		const char *s = NULL;
7847c478bdstevel@tonic-gate
7857c478bdstevel@tonic-gate		switch (code) {		/* interpret these symbolically */
7867c478bdstevel@tonic-gate		case I_GRDOPT:
7877c478bdstevel@tonic-gate			s = strrdopt(val);
7887c478bdstevel@tonic-gate			break;
7897c478bdstevel@tonic-gate		case I_GETSIG:
7907c478bdstevel@tonic-gate			s = strevents(pri, val);
7917c478bdstevel@tonic-gate			break;
7927c478bdstevel@tonic-gate		case TIOCFLUSH:
7937c478bdstevel@tonic-gate			s = tiocflush(pri, val);
7947c478bdstevel@tonic-gate			break;
7957c478bdstevel@tonic-gate		}
7967c478bdstevel@tonic-gate
7977c478bdstevel@tonic-gate		if (s == NULL)
7987c478bdstevel@tonic-gate			(void) printf("%s\t0x%.8lX: %d\n",
799019c3c4raf			    pri->pname, offset, val);
8007c478bdstevel@tonic-gate		else
8017c478bdstevel@tonic-gate			(void) printf("%s\t0x%.8lX: %s\n",
802019c3c4raf			    pri->pname, offset, s);
8037c478bdstevel@tonic-gate	}
8047c478bdstevel@tonic-gate}
8057c478bdstevel@tonic-gate
8067c478bdstevel@tonic-gatevoid
8077c478bdstevel@tonic-gateshow_strioctl(private_t *pri, long offset)
8087c478bdstevel@tonic-gate{
8097c478bdstevel@tonic-gate	struct strioctl strioctl;
8107c478bdstevel@tonic-gate
8117c478bdstevel@tonic-gate	if (Pread(Proc, &strioctl, sizeof (strioctl), offset) ==
8127c478bdstevel@tonic-gate	    sizeof (strioctl)) {
8137c478bdstevel@tonic-gate		(void) printf(
814019c3c4raf		    "%s\tcmd=%s timout=%d len=%d dp=0x%.8lX\n",
815019c3c4raf		    pri->pname,
816019c3c4raf		    ioctlname(pri, strioctl.ic_cmd),
817019c3c4raf		    strioctl.ic_timout,
818019c3c4raf		    strioctl.ic_len,
819019c3c4raf		    (long)strioctl.ic_dp);
8207c478bdstevel@tonic-gate
8217c478bdstevel@tonic-gate		if (pri->recur++ == 0)	/* avoid indefinite recursion */
8227c478bdstevel@tonic-gate			show_ioctl(pri, strioctl.ic_cmd,
823019c3c4raf			    (long)strioctl.ic_dp);
8247c478bdstevel@tonic-gate		--pri->recur;
8257c478bdstevel@tonic-gate	}
8267c478bdstevel@tonic-gate}
8277c478bdstevel@tonic-gate
8287c478bdstevel@tonic-gate#ifdef _LP64
8297c478bdstevel@tonic-gatevoid
8307c478bdstevel@tonic-gateshow_strioctl32(private_t *pri, long offset)
8317c478bdstevel@tonic-gate{
8327c478bdstevel@tonic-gate	struct strioctl32 strioctl;
8337c478bdstevel@tonic-gate
8347c478bdstevel@tonic-gate	if (Pread(Proc, &strioctl, sizeof (strioctl), offset) ==
8357c478bdstevel@tonic-gate	    sizeof (strioctl)) {
8367c478bdstevel@tonic-gate		(void) printf(
837019c3c4raf		    "%s\tcmd=%s timout=%d len=%d dp=0x%.8lX\n",
838019c3c4raf		    pri->pname,
839019c3c4raf		    ioctlname(pri, strioctl.ic_cmd),
840019c3c4raf		    strioctl.ic_timout,
841019c3c4raf		    strioctl.ic_len,
842019c3c4raf		    (long)strioctl.ic_dp);
8437c478bdstevel@tonic-gate
8447c478bdstevel@tonic-gate		if (pri->recur++ == 0)	/* avoid indefinite recursion */
8457c478bdstevel@tonic-gate			show_ioctl(pri, strioctl.ic_cmd,
846019c3c4raf			    (long)strioctl.ic_dp);
8477c478bdstevel@tonic-gate		--pri->recur;
8487c478bdstevel@tonic-gate	}
8497c478bdstevel@tonic-gate}
8507c478bdstevel@tonic-gate#endif	/* _LP64 */
8517c478bdstevel@tonic-gate
8527c478bdstevel@tonic-gatevoid
8537c478bdstevel@tonic-gateprint_strbuf(private_t *pri, struct strbuf *sp, const char *name, int dump)
8547c478bdstevel@tonic-gate{
8557c478bdstevel@tonic-gate	(void) printf(
856019c3c4raf	    "%s\t%s:  maxlen=%-4d len=%-4d buf=0x%.8lX",
857019c3c4raf	    pri->pname,
858019c3c4raf	    name,
859019c3c4raf	    sp->maxlen,
860019c3c4raf	    sp->len,
861019c3c4raf	    (long)sp->buf);
8627c478bdstevel@tonic-gate	/*
8637c478bdstevel@tonic-gate	 * Should we show the buffer contents?
8647c478bdstevel@tonic-gate	 * Keyed to the '-r fds' and '-w fds' options?
8657c478bdstevel@tonic-gate	 */
8667c478bdstevel@tonic-gate	if (sp->buf == NULL || sp->len <= 0)
8677c478bdstevel@tonic-gate		(void) fputc('\n', stdout);
8687c478bdstevel@tonic-gate	else {
8697c478bdstevel@tonic-gate		int nb = (sp->len > 8)? 8 : sp->len;
8707c478bdstevel@tonic-gate		char buffer[8];
8717c478bdstevel@tonic-gate		char obuf[40];
8727c478bdstevel@tonic-gate
8737c478bdstevel@tonic-gate		if (Pread(Proc, buffer, (size_t)nb, (long)sp->buf) == nb) {
8747c478bdstevel@tonic-gate			(void) strcpy(obuf, ": \"");
8757c478bdstevel@tonic-gate			showbytes(buffer, nb, obuf+3);
8767c478bdstevel@tonic-gate			(void) strcat(obuf,
877019c3c4raf			    (nb == sp->len)?
878019c3c4raf			    (const char *)"\"" : (const char *)"\"..");
8797c478bdstevel@tonic-gate			(void) fputs(obuf, stdout);
8807c478bdstevel@tonic-gate		}
8817c478bdstevel@tonic-gate		(void) fputc('\n', stdout);
8827c478bdstevel@tonic-gate		if (dump && sp->len > 8)
8837c478bdstevel@tonic-gate			showbuffer(pri, (long)sp->buf, (long)sp->len);
8847c478bdstevel@tonic-gate	}
8857c478bdstevel@tonic-gate}
8867c478bdstevel@tonic-gate
8877c478bdstevel@tonic-gate#ifdef _LP64
8887c478bdstevel@tonic-gatevoid
8897c478bdstevel@tonic-gateprint_strbuf32(private_t *pri, struct strbuf32 *sp, const char *name, int dump)
8907c478bdstevel@tonic-gate{
8917c478bdstevel@tonic-gate	(void) printf(
892019c3c4raf	    "%s\t%s:  maxlen=%-4d len=%-4d buf=0x%.8lX",
893019c3c4raf	    pri->pname,
894019c3c4raf	    name,
895019c3c4raf	    sp->maxlen,
896019c3c4raf	    sp->len,
897019c3c4raf	    (long)sp->buf);
8987c478bdstevel@tonic-gate	/*
8997c478bdstevel@tonic-gate	 * Should we show the buffer contents?
9007c478bdstevel@tonic-gate	 * Keyed to the '-r fds' and '-w fds' options?
9017c478bdstevel@tonic-gate	 */
90227aa481Toomas Soome	if (sp->buf == 0 || sp->len <= 0)
9037c478bdstevel@tonic-gate		(void) fputc('\n', stdout);
9047c478bdstevel@tonic-gate	else {
9057c478bdstevel@tonic-gate		int nb = (sp->len > 8)? 8 : sp->len;
9067c478bdstevel@tonic-gate		char buffer[8];
9077c478bdstevel@tonic-gate		char obuf[40];
9087c478bdstevel@tonic-gate
9097c478bdstevel@tonic-gate		if (Pread(Proc, buffer, (size_t)nb, (long)sp->buf) == nb) {
9107c478bdstevel@tonic-gate			(void) strcpy(obuf, ": \"");
9117c478bdstevel@tonic-gate			showbytes(buffer, nb, obuf+3);
9127c478bdstevel@tonic-gate			(void) strcat(obuf,
913019c3c4raf			    (nb == sp->len)?
914019c3c4raf			    (const char *)"\"" : (const char *)"\"..");
9157c478bdstevel@tonic-gate			(void) fputs(obuf, stdout);
9167c478bdstevel@tonic-gate		}
9177c478bdstevel@tonic-gate		(void) fputc('\n', stdout);
9187c478bdstevel@tonic-gate		if (dump && sp->len > 8)
9197c478bdstevel@tonic-gate			showbuffer(pri, (long)sp->buf, (long)sp->len);
9207c478bdstevel@tonic-gate	}
9217c478bdstevel@tonic-gate}
9227c478bdstevel@tonic-gate#endif	/* _LP64 */
9237c478bdstevel@tonic-gate
9247c478bdstevel@tonic-gate/* strpeek and strfdinsert flags word */
9257c478bdstevel@tonic-gateconst char *
9267c478bdstevel@tonic-gatestrflags(private_t *pri, int flags)
9277c478bdstevel@tonic-gate{
9287c478bdstevel@tonic-gate	const char *s;
9297c478bdstevel@tonic-gate
9307c478bdstevel@tonic-gate	switch (flags) {
9317c478bdstevel@tonic-gate	case 0:
9327c478bdstevel@tonic-gate		s = "0";
9337c478bdstevel@tonic-gate		break;
9347c478bdstevel@tonic-gate	case RS_HIPRI:
9357c478bdstevel@tonic-gate		s = "RS_HIPRI";
9367c478bdstevel@tonic-gate		break;
9377c478bdstevel@tonic-gate	default:
9387c478bdstevel@tonic-gate		(void) sprintf(pri->code_buf, "0x%.4X", flags);
9397c478bdstevel@tonic-gate		s = pri->code_buf;
9407c478bdstevel@tonic-gate	}
9417c478bdstevel@tonic-gate
9427c478bdstevel@tonic-gate	return (s);
9437c478bdstevel@tonic-gate}
9447c478bdstevel@tonic-gate
9457c478bdstevel@tonic-gatevoid
9467c478bdstevel@tonic-gateshow_strpeek(private_t *pri, long offset)
9477c478bdstevel@tonic-gate{
9487c478bdstevel@tonic-gate	struct strpeek strpeek;
9497c478bdstevel@tonic-gate
9507c478bdstevel@tonic-gate	if (Pread(Proc, &strpeek, sizeof (strpeek), offset)
9517c478bdstevel@tonic-gate	    == sizeof (strpeek)) {
9527c478bdstevel@tonic-gate
9537c478bdstevel@tonic-gate		print_strbuf(pri, &strpeek.ctlbuf, "ctl", FALSE);
9547c478bdstevel@tonic-gate		print_strbuf(pri, &strpeek.databuf, "dat", FALSE);
9557c478bdstevel@tonic-gate
9567c478bdstevel@tonic-gate		(void) printf("%s\tflags=%s\n",
957019c3c4raf		    pri->pname,
958019c3c4raf		    strflags(pri, strpeek.flags));
9597c478bdstevel@tonic-gate	}
9607c478bdstevel@tonic-gate}
9617c478bdstevel@tonic-gate
9627c478bdstevel@tonic-gate#ifdef _LP64
9637c478bdstevel@tonic-gatevoid
9647c478bdstevel@tonic-gateshow_strpeek32(private_t *pri, long offset)
9657c478bdstevel@tonic-gate{
9667c478bdstevel@tonic-gate	struct strpeek32 strpeek;
9677c478bdstevel@tonic-gate
9687c478bdstevel@tonic-gate	if (Pread(Proc, &strpeek, sizeof (strpeek), offset)
9697c478bdstevel@tonic-gate	    == sizeof (strpeek)) {
9707c478bdstevel@tonic-gate
9717c478bdstevel@tonic-gate		print_strbuf32(pri, &strpeek.ctlbuf, "ctl", FALSE);
9727c478bdstevel@tonic-gate		print_strbuf32(pri, &strpeek.databuf, "dat", FALSE);
9737c478bdstevel@tonic-gate
9747c478bdstevel@tonic-gate		(void) printf("%s\tflags=%s\n",
975019c3c4raf		    pri->pname,
976019c3c4raf		    strflags(pri, strpeek.flags));
9777c478bdstevel@tonic-gate	}
9787c478bdstevel@tonic-gate}
9797c478bdstevel@tonic-gate#endif	/* _LP64 */
9807c478bdstevel@tonic-gate
9817c478bdstevel@tonic-gatevoid
9827c478bdstevel@tonic-gateshow_strfdinsert(private_t *pri, long offset)
9837c478bdstevel@tonic-gate{
9847c478bdstevel@tonic-gate	struct strfdinsert strfdinsert;
9857c478bdstevel@tonic-gate
9867c478bdstevel@tonic-gate	if (Pread(Proc, &strfdinsert, sizeof (strfdinsert), offset) ==
9877c478bdstevel@tonic-gate	    sizeof (strfdinsert)) {
9887c478bdstevel@tonic-gate
9897c478bdstevel@tonic-gate		print_strbuf(pri, &strfdinsert.ctlbuf, "ctl", FALSE);
9907c478bdstevel@tonic-gate		print_strbuf(pri, &strfdinsert.databuf, "dat", FALSE);
9917c478bdstevel@tonic-gate
9927c478bdstevel@tonic-gate		(void) printf("%s\tflags=%s fildes=%d offset=%d\n",
993019c3c4raf		    pri->pname,
994019c3c4raf		    strflags(pri, strfdinsert.flags),
995019c3c4raf		    strfdinsert.fildes,
996019c3c4raf		    strfdinsert.offset);
9977c478bdstevel@tonic-gate	}
9987c478bdstevel@tonic-gate}
9997c478bdstevel@tonic-gate
10007c478bdstevel@tonic-gate#ifdef _LP64
10017c478bdstevel@tonic-gatevoid
10027c478bdstevel@tonic-gateshow_strfdinsert32(private_t *pri, long offset)
10037c478bdstevel@tonic-gate{
10047c478bdstevel@tonic-gate	struct strfdinsert32 strfdinsert;
10057c478bdstevel@tonic-gate
10067c478bdstevel@tonic-gate	if (Pread(Proc, &strfdinsert, sizeof (strfdinsert), offset) ==
10077c478bdstevel@tonic-gate	    sizeof (strfdinsert)) {
10087c478bdstevel@tonic-gate
10097c478bdstevel@tonic-gate		print_strbuf32(pri, &strfdinsert.ctlbuf, "ctl", FALSE);
10107c478bdstevel@tonic-gate		print_strbuf32(pri, &strfdinsert.databuf, "dat", FALSE);
10117c478bdstevel@tonic-gate
10127c478bdstevel@tonic-gate		(void) printf("%s\tflags=%s fildes=%d offset=%d\n",
1013019c3c4raf		    pri->pname,
1014019c3c4raf		    strflags(pri, strfdinsert.flags),
1015019c3c4raf		    strfdinsert.fildes,
1016019c3c4raf		    strfdinsert.offset);
10177c478bdstevel@tonic-gate	}
10187c478bdstevel@tonic-gate}
10197c478bdstevel@tonic-gate#endif	/* _LP64 */
10207c478bdstevel@tonic-gate
10217c478bdstevel@tonic-gatevoid
10227c478bdstevel@tonic-gateshow_strrecvfd(private_t *pri, long offset)
10237c478bdstevel@tonic-gate{
10247c478bdstevel@tonic-gate	struct strrecvfd strrecvfd;
10257c478bdstevel@tonic-gate
10267c478bdstevel@tonic-gate	if (Pread(Proc, &strrecvfd, sizeof (strrecvfd), offset) ==
10277c478bdstevel@tonic-gate	    sizeof (strrecvfd)) {
10287c478bdstevel@tonic-gate		(void) printf(
1029019c3c4raf		    "%s\tfd=%-5d uid=%-5u gid=%u\n",
1030019c3c4raf		    pri->pname,
1031019c3c4raf		    strrecvfd.fd,
1032019c3c4raf		    strrecvfd.uid,
1033019c3c4raf		    strrecvfd.gid);
10347c478bdstevel@tonic-gate	}
10357c478bdstevel@tonic-gate}
10367c478bdstevel@tonic-gate
10377c478bdstevel@tonic-gatevoid
10387c478bdstevel@tonic-gateshow_strlist(private_t *pri, long offset)
10397c478bdstevel@tonic-gate{
10407c478bdstevel@tonic-gate	struct str_list strlist;
10417c478bdstevel@tonic-gate	struct str_mlist list;
10427c478bdstevel@tonic-gate	int count;
10437c478bdstevel@tonic-gate
10447c478bdstevel@tonic-gate	if (Pread(Proc, &strlist, sizeof (strlist), offset) ==
10457c478bdstevel@tonic-gate	    sizeof (strlist)) {
10467c478bdstevel@tonic-gate		(void) printf("%s\tnmods=%d  modlist=0x%.8lX\n",
1047019c3c4raf		    pri->pname,
1048019c3c4raf		    strlist.sl_nmods,
1049019c3c4raf		    (long)strlist.sl_modlist);
10507c478bdstevel@tonic-gate
10517c478bdstevel@tonic-gate		count = strlist.sl_nmods;
10527c478bdstevel@tonic-gate		offset = (long)strlist.sl_modlist;
10537c478bdstevel@tonic-gate		while (!interrupt && --count >= 0) {
10547c478bdstevel@tonic-gate			if (Pread(Proc, &list, sizeof (list), offset) !=
10557c478bdstevel@tonic-gate			    sizeof (list))
10567c478bdstevel@tonic-gate				break;
10577c478bdstevel@tonic-gate			(void) printf("%s\t\t\"%.*s\"\n",
1058019c3c4raf			    pri->pname,
1059019c3c4raf			    (int)sizeof (list.l_name),
1060019c3c4raf			    list.l_name);
10617c478bdstevel@tonic-gate			offset += sizeof (struct str_mlist);
10627c478bdstevel@tonic-gate		}
10637c478bdstevel@tonic-gate	}
10647c478bdstevel@tonic-gate}
10657c478bdstevel@tonic-gate
10667c478bdstevel@tonic-gate#ifdef _LP64
10677c478bdstevel@tonic-gatevoid
10687c478bdstevel@tonic-gateshow_strlist32(private_t *pri, long offset)
10697c478bdstevel@tonic-gate{
10707c478bdstevel@tonic-gate	struct str_list32 strlist;
10717c478bdstevel@tonic-gate	struct str_mlist list;
10727c478bdstevel@tonic-gate	int count;
10737c478bdstevel@tonic-gate
10747c478bdstevel@tonic-gate	if (Pread(Proc, &strlist, sizeof (strlist), offset) ==
10757c478bdstevel@tonic-gate	    sizeof (strlist)) {
10767c478bdstevel@tonic-gate		(void) printf("%s\tnmods=%d  modlist=0x%.8lX\n",
1077019c3c4raf		    pri->pname,
1078019c3c4raf		    strlist.sl_nmods,
1079019c3c4raf		    (long)strlist.sl_modlist);
10807c478bdstevel@tonic-gate
10817c478bdstevel@tonic-gate		count = strlist.sl_nmods;
10827c478bdstevel@tonic-gate		offset = (long)strlist.sl_modlist;
10837c478bdstevel@tonic-gate		while (!interrupt && --count >= 0) {
10847c478bdstevel@tonic-gate			if (Pread(Proc, &list, sizeof (list), offset) !=
10857c478bdstevel@tonic-gate			    sizeof (list))
10867c478bdstevel@tonic-gate				break;
10877c478bdstevel@tonic-gate			(void) printf("%s\t\t\"%.*s\"\n",
1088019c3c4raf			    pri->pname,
1089019c3c4raf			    (int)sizeof (list.l_name),
1090019c3c4raf			    list.l_name);
10917c478bdstevel@tonic-gate			offset += sizeof (struct str_mlist);
10927c478bdstevel@tonic-gate		}
10937c478bdstevel@tonic-gate	}
10947c478bdstevel@tonic-gate}
10957c478bdstevel@tonic-gate#endif	/* _LP64 */
10967c478bdstevel@tonic-gate
10977c478bdstevel@tonic-gatevoid
10987c478bdstevel@tonic-gateshow_jwinsize(private_t *pri, long offset)
10997c478bdstevel@tonic-gate{
11007c478bdstevel@tonic-gate	struct jwinsize jwinsize;
11017c478bdstevel@tonic-gate
11027c478bdstevel@tonic-gate	if (Pread(Proc, &jwinsize, sizeof (jwinsize), offset) ==
11037c478bdstevel@tonic-gate	    sizeof (jwinsize)) {
11047c478bdstevel@tonic-gate		(void) printf(
1105019c3c4raf		    "%s\tbytesx=%-3u bytesy=%-3u bitsx=%-3u bitsy=%-3u\n",
1106019c3c4raf		    pri->pname,
1107019c3c4raf		    (unsigned)jwinsize.bytesx,
1108019c3c4raf		    (unsigned)jwinsize.bytesy,
1109019c3c4raf		    (unsigned)jwinsize.bitsx,
1110019c3c4raf		    (unsigned)jwinsize.bitsy);
11117c478bdstevel@tonic-gate	}
11127c478bdstevel@tonic-gate}
11137c478bdstevel@tonic-gate
11147c478bdstevel@tonic-gatevoid
11157c478bdstevel@tonic-gateshow_winsize(private_t *pri, long offset)
11167c478bdstevel@tonic-gate{
11177c478bdstevel@tonic-gate	struct winsize winsize;
11187c478bdstevel@tonic-gate
11197c478bdstevel@tonic-gate	if (Pread(Proc, &winsize, sizeof (winsize), offset)
11207c478bdstevel@tonic-gate	    == sizeof (winsize)) {
11217c478bdstevel@tonic-gate		(void) printf(
1122019c3c4raf		    "%s\trow=%-3d col=%-3d xpixel=%-3d ypixel=%-3d\n",
1123019c3c4raf		    pri->pname,
1124019c3c4raf		    winsize.ws_row,
1125019c3c4raf		    winsize.ws_col,
1126019c3c4raf		    winsize.ws_xpixel,
1127019c3c4raf		    winsize.ws_ypixel);
11287c478bdstevel@tonic-gate	}
11297c478bdstevel@tonic-gate}
11307c478bdstevel@tonic-gate
11317c478bdstevel@tonic-gatestruct audio_stuff {
11327c478bdstevel@tonic-gate	uint_t	bit;
11337c478bdstevel@tonic-gate	const char *str;
11347c478bdstevel@tonic-gate};
11357c478bdstevel@tonic-gate
11367c478bdstevel@tonic-gateconst struct audio_stuff audio_output_ports[] = {
11377c478bdstevel@tonic-gate	{ AUDIO_SPEAKER, "SPEAKER" },
11387c478bdstevel@tonic-gate	{ AUDIO_HEADPHONE, "HEADPHONE" },
11397c478bdstevel@tonic-gate	{ AUDIO_LINE_OUT, "LINE_OUT" },
11407c478bdstevel@tonic-gate	{ AUDIO_SPDIF_OUT, "SPDIF_OUT" },
11417c478bdstevel@tonic-gate	{ AUDIO_AUX1_OUT, "AUX1_OUT" },
11427c478bdstevel@tonic-gate	{ AUDIO_AUX2_OUT, "AUX2_OUT" },
11437c478bdstevel@tonic-gate	{ 0, NULL }
11447c478bdstevel@tonic-gate};
11457c478bdstevel@tonic-gate
11467c478bdstevel@tonic-gateconst struct audio_stuff audio_input_ports[] = {
11477c478bdstevel@tonic-gate	{ AUDIO_MICROPHONE, "MICROPHONE" },
11487c478bdstevel@tonic-gate	{ AUDIO_LINE_IN, "LINE_IN" },
11497c478bdstevel@tonic-gate	{ AUDIO_CD, "CD" },
11507c478bdstevel@tonic-gate	{ AUDIO_SPDIF_IN, "SPDIF_IN" },
11517c478bdstevel@tonic-gate	{ AUDIO_AUX1_IN, "AUX1_IN" },
11527c478bdstevel@tonic-gate	{ AUDIO_AUX2_IN, "AUX2_IN" },
11537c478bdstevel@tonic-gate	{ AUDIO_CODEC_LOOPB_IN, "CODEC_LOOPB_IN" },
11547c478bdstevel@tonic-gate	{ AUDIO_SUNVTS, "SUNVTS" },
11557c478bdstevel@tonic-gate	{ 0, NULL }
11567c478bdstevel@tonic-gate};
11577c478bdstevel@tonic-gate
11587c478bdstevel@tonic-gatestatic const struct audio_stuff audio_hw_features[] = {
11597c478bdstevel@tonic-gate	{ AUDIO_HWFEATURE_DUPLEX, "DUPLEX" },
11607c478bdstevel@tonic-gate	{ AUDIO_HWFEATURE_MSCODEC, "MSCODEC" },
11617c478bdstevel@tonic-gate	{ AUDIO_HWFEATURE_IN2OUT, "IN2OUT" },
11627c478bdstevel@tonic-gate	{ AUDIO_HWFEATURE_PLAY, "PLAY" },
11637c478bdstevel@tonic-gate	{ AUDIO_HWFEATURE_RECORD, "RECORD" },
11647c478bdstevel@tonic-gate	{ 0, NULL }
11657c478bdstevel@tonic-gate};
11667c478bdstevel@tonic-gate
11677c478bdstevel@tonic-gatestatic const struct audio_stuff audio_sw_features[] = {
11687c478bdstevel@tonic-gate	{ AUDIO_SWFEATURE_MIXER, "MIXER" },
11697c478bdstevel@tonic-gate	{ 0, NULL }
11707c478bdstevel@tonic-gate};
11717c478bdstevel@tonic-gate
11727c478bdstevel@tonic-gatevoid
11737c478bdstevel@tonic-gateshow_audio_features(const private_t *pri,
11740b09d75Toomas Soome    const struct audio_stuff *audio_porttab, uint_t features,
11750b09d75Toomas Soome    const char *name)
11767c478bdstevel@tonic-gate{
11777c478bdstevel@tonic-gate	(void) printf("%s\t%s=", pri->pname, name);
11787c478bdstevel@tonic-gate	if (features == 0) {
11797c478bdstevel@tonic-gate		(void) printf("0\n");
11807c478bdstevel@tonic-gate		return;
11817c478bdstevel@tonic-gate	}
11827c478bdstevel@tonic-gate
11837c478bdstevel@tonic-gate	for (; audio_porttab->bit != 0; ++audio_porttab) {
11847c478bdstevel@tonic-gate		if (features & audio_porttab->bit) {
11857c478bdstevel@tonic-gate			(void) printf(audio_porttab->str);
11867c478bdstevel@tonic-gate			features &= ~audio_porttab->bit;
11877c478bdstevel@tonic-gate			if (features)
11887c478bdstevel@tonic-gate				(void) putchar('|');
11897c478bdstevel@tonic-gate		}
11907c478bdstevel@tonic-gate	}
11917c478bdstevel@tonic-gate	if (features)
11927c478bdstevel@tonic-gate		(void) printf("0x%x", features);
11937c478bdstevel@tonic-gate	(void) putchar('\n');
11947c478bdstevel@tonic-gate}
11957c478bdstevel@tonic-gate
11967c478bdstevel@tonic-gatevoid
11977c478bdstevel@tonic-gateshow_audio_ports(private_t *pri, const char *mode,
11980b09d75Toomas Soome    const char *field, uint_t ports)
11997c478bdstevel@tonic-gate{
12007c478bdstevel@tonic-gate	const struct audio_stuff *audio_porttab;
12017c478bdstevel@tonic-gate
12027c478bdstevel@tonic-gate	(void) printf("%s\t%s\t%s=", pri->pname, mode, field);
12037c478bdstevel@tonic-gate	if (ports == 0) {
12047c478bdstevel@tonic-gate		(void) printf("0\n");
12057c478bdstevel@tonic-gate		return;
12067c478bdstevel@tonic-gate	}
12077c478bdstevel@tonic-gate	if (*mode == 'p')
12087c478bdstevel@tonic-gate		audio_porttab = audio_output_ports;
12097c478bdstevel@tonic-gate	else
12107c478bdstevel@tonic-gate		audio_porttab = audio_input_ports;
12117c478bdstevel@tonic-gate	for (; audio_porttab->bit != 0; ++audio_porttab) {
12127c478bdstevel@tonic-gate		if (ports & audio_porttab->bit) {
12137c478bdstevel@tonic-gate			(void) printf(audio_porttab->str);
12147c478bdstevel@tonic-gate			ports &= ~audio_porttab->bit;
12157c478bdstevel@tonic-gate			if (ports)
12167c478bdstevel@tonic-gate				(void) putchar('|');
12177c478bdstevel@tonic-gate		}
12187c478bdstevel@tonic-gate	}
12197c478bdstevel@tonic-gate	if (ports)
12207c478bdstevel@tonic-gate		(void) printf("0x%x", ports);
12217c478bdstevel@tonic-gate	(void) putchar('\n');
12227c478bdstevel@tonic-gate}
12237c478bdstevel@tonic-gate
12247c478bdstevel@tonic-gatevoid
12257c478bdstevel@tonic-gateshow_audio_prinfo(private_t *pri, const char *mode, struct audio_prinfo *au_pr)
12267c478bdstevel@tonic-gate{
12277c478bdstevel@tonic-gate	const char *s;
12287c478bdstevel@tonic-gate
12297c478bdstevel@tonic-gate	/*
12307c478bdstevel@tonic-gate	 * The following values describe the audio data encoding.
12317c478bdstevel@tonic-gate	 */
12327c478bdstevel@tonic-gate
12337c478bdstevel@tonic-gate	(void) printf("%s\t%s\tsample_rate=%u channels=%u precision=%u\n",
1234019c3c4raf	    pri->pname, mode,
1235019c3c4raf	    au_pr->sample_rate,
1236019c3c4raf	    au_pr->channels,
1237019c3c4raf	    au_pr->precision);
12387c478bdstevel@tonic-gate
12397c478bdstevel@tonic-gate	s = NULL;
12407c478bdstevel@tonic-gate	switch (au_pr->encoding) {
12417c478bdstevel@tonic-gate	case AUDIO_ENCODING_NONE:	s = "NONE";	break;
12427c478bdstevel@tonic-gate	case AUDIO_ENCODING_ULAW:	s = "ULAW";	break;
12437c478bdstevel@tonic-gate	case AUDIO_ENCODING_ALAW:	s = "ALAW";	break;
12447c478bdstevel@tonic-gate	case AUDIO_ENCODING_LINEAR:	s = "LINEAR";	break;
12457c478bdstevel@tonic-gate	case AUDIO_ENCODING_DVI:	s = "DVI";	break;
12467c478bdstevel@tonic-gate	case AUDIO_ENCODING_LINEAR8:	s = "LINEAR8";	break;
12477c478bdstevel@tonic-gate	}
12487c478bdstevel@tonic-gate	if (s)
12497c478bdstevel@tonic-gate		(void) printf("%s\t%s\tencoding=%s\n", pri->pname, mode, s);
12507c478bdstevel@tonic-gate	else {
12517c478bdstevel@tonic-gate		(void) printf("%s\t%s\tencoding=%u\n",
1252019c3c4raf		    pri->pname, mode, au_pr->encoding);
12537c478bdstevel@tonic-gate	}
12547c478bdstevel@tonic-gate
12557c478bdstevel@tonic-gate	/*
12567c478bdstevel@tonic-gate	 * The following values control audio device configuration
12577c478bdstevel@tonic-gate	 */
12587c478bdstevel@tonic-gate
12597c478bdstevel@tonic-gate	(void) printf(
1260019c3c4raf	    "%s\t%s\tgain=%u buffer_size=%u\n",
1261019c3c4raf	    pri->pname, mode,
1262019c3c4raf	    au_pr->gain,
1263019c3c4raf	    au_pr->buffer_size);
12647c478bdstevel@tonic-gate	show_audio_ports(pri, mode, "port", au_pr->port);
12657c478bdstevel@tonic-gate	show_audio_ports(pri, mode, "avail_ports", au_pr->avail_ports);
12667c478bdstevel@tonic-gate	show_audio_ports(pri, mode, "mod_ports", au_pr->mod_ports);
12677c478bdstevel@tonic-gate
12687c478bdstevel@tonic-gate	/*
12697c478bdstevel@tonic-gate	 * The following values describe driver state
12707c478bdstevel@tonic-gate	 */
12717c478bdstevel@tonic-gate
12727c478bdstevel@tonic-gate	(void) printf("%s\t%s\tsamples=%u eof=%u pause=%u error=%u\n",
1273019c3c4raf	    pri->pname, mode,
1274019c3c4raf	    au_pr->samples,
1275019c3c4raf	    au_pr->eof,
1276019c3c4raf	    au_pr->pause,
1277019c3c4raf	    au_pr->error);
12787c478bdstevel@tonic-gate	(void) printf("%s\t%s\twaiting=%u balance=%u minordev=%u\n",
1279019c3c4raf	    pri->pname, mode,
1280019c3c4raf	    au_pr->waiting,
1281019c3c4raf	    au_pr->balance,
1282019c3c4raf	    au_pr->minordev);
12837c478bdstevel@tonic-gate
12847c478bdstevel@tonic-gate	/*
12857c478bdstevel@tonic-gate	 * The following values are read-only state flags
12867c478bdstevel@tonic-gate	 */
12877c478bdstevel@tonic-gate	(void) printf("%s\t%s\topen=%u active=%u\n",
1288019c3c4raf	    pri->pname, mode,
1289019c3c4raf	    au_pr->open,
1290019c3c4raf	    au_pr->active);
12917c478bdstevel@tonic-gate}
12927c478bdstevel@tonic-gate
12937c478bdstevel@tonic-gatevoid
12947c478bdstevel@tonic-gateshow_audio_info(private_t *pri, long offset)
12957c478bdstevel@tonic-gate{
12967c478bdstevel@tonic-gate	struct audio_info au;
12977c478bdstevel@tonic-gate
12987c478bdstevel@tonic-gate	if (Pread(Proc, &au, sizeof (au), offset) == sizeof (au)) {
12997c478bdstevel@tonic-gate		show_audio_prinfo(pri, "play", &au.play);
13007c478bdstevel@tonic-gate		show_audio_prinfo(pri, "record", &au.record);
13017c478bdstevel@tonic-gate		(void) printf("%s\tmonitor_gain=%u output_muted=%u\n",
1302019c3c4raf		    pri->pname, au.monitor_gain, au.output_muted);
13037c478bdstevel@tonic-gate		show_audio_features(pri, audio_hw_features, au.hw_features,
13047c478bdstevel@tonic-gate		    "hw_features");
13057c478bdstevel@tonic-gate		show_audio_features(pri, audio_sw_features, au.sw_features,
13067c478bdstevel@tonic-gate		    "sw_features");
13077c478bdstevel@tonic-gate		show_audio_features(pri, audio_sw_features,
13087c478bdstevel@tonic-gate		    au.sw_features_enabled, "sw_features_enabled");
13097c478bdstevel@tonic-gate	}
13107c478bdstevel@tonic-gate}
13117c478bdstevel@tonic-gate
13127c478bdstevel@tonic-gatevoid
13137c478bdstevel@tonic-gateshow_ioctl(private_t *pri, int code, long offset)
13147c478bdstevel@tonic-gate{
13157c478bdstevel@tonic-gate	int lp64 = (data_model == PR_MODEL_LP64);
13167c478bdstevel@tonic-gate	int err = pri->Errno;	/* don't display output parameters */
13177c478bdstevel@tonic-gate				/* for a failed system call */
13187c478bdstevel@tonic-gate#ifndef _LP64
13197c478bdstevel@tonic-gate	if (lp64)
13207c478bdstevel@tonic-gate		return;
13217c478bdstevel@tonic-gate#endif
13223b862e9Roger A. Faulkner	if (offset == 0)
13237c478bdstevel@tonic-gate		return;
13247c478bdstevel@tonic-gate
13257c478bdstevel@tonic-gate	switch (code) {
13267c478bdstevel@tonic-gate	case TCGETA:
13277c478bdstevel@tonic-gate		if (err)
13287c478bdstevel@tonic-gate			break;
13297c478bdstevel@tonic-gate		/*FALLTHROUGH*/
13307c478bdstevel@tonic-gate	case TCSETA:
13317c478bdstevel@tonic-gate	case TCSETAW:
13327c478bdstevel@tonic-gate	case TCSETAF:
13337c478bdstevel@tonic-gate		show_termio(pri, offset);
13347c478bdstevel@tonic-gate		break;
13357c478bdstevel@tonic-gate	case TCGETS:
13367c478bdstevel@tonic-gate		if (err)
13377c478bdstevel@tonic-gate			break;
13387c478bdstevel@tonic-gate		/*FALLTHROUGH*/
13397c478bdstevel@tonic-gate	case TCSETS:
13407c478bdstevel@tonic-gate	case TCSETSW:
13417c478bdstevel@tonic-gate	case TCSETSF:
13427c478bdstevel@tonic-gate		show_termios(pri, offset);
13437c478bdstevel@tonic-gate		break;
13447c478bdstevel@tonic-gate	case TCGETX:
13457c478bdstevel@tonic-gate		if (err)
13467c478bdstevel@tonic-gate			break;
13477c478bdstevel@tonic-gate		/*FALLTHROUGH*/
13487c478bdstevel@tonic-gate	case TCSETX:
13497c478bdstevel@tonic-gate	case TCSETXW:
13507c478bdstevel@tonic-gate	case TCSETXF:
13517c478bdstevel@tonic-gate		show_termiox(pri, offset);
13527c478bdstevel@tonic-gate		break;
13537c478bdstevel@tonic-gate	case TIOCGETP:
13547c478bdstevel@tonic-gate		if (err)
13557c478bdstevel@tonic-gate			break;
13567c478bdstevel@tonic-gate		/*FALLTHROUGH*/
13577c478bdstevel@tonic-gate	case TIOCSETN:
13587c478bdstevel@tonic-gate	case TIOCSETP:
13597c478bdstevel@tonic-gate		show_sgttyb(pri, offset);
13607c478bdstevel@tonic-gate		break;
13617c478bdstevel@tonic-gate	case TIOCGLTC:
13627c478bdstevel@tonic-gate		if (err)
13637c478bdstevel@tonic-gate			break;
13647c478bdstevel@tonic-gate		/*FALLTHROUGH*/
13657c478bdstevel@tonic-gate	case TIOCSLTC:
13667c478bdstevel@tonic-gate		show_ltchars(pri, offset);
13677c478bdstevel@tonic-gate		break;
13687c478bdstevel@tonic-gate	case TIOCGETC:
13697c478bdstevel@tonic-gate		if (err)
13707c478bdstevel@tonic-gate			break;
13717c478bdstevel@tonic-gate		/*FALLTHROUGH*/
13727c478bdstevel@tonic-gate	case TIOCSETC:
13737c478bdstevel@tonic-gate		show_tchars(pri, offset);
13747c478bdstevel@tonic-gate		break;
13757c478bdstevel@tonic-gate	case LDGETT:
13767c478bdstevel@tonic-gate		if (err)
13777c478bdstevel@tonic-gate			break;
13787c478bdstevel@tonic-gate		/*FALLTHROUGH*/
13797c478bdstevel@tonic-gate	case LDSETT:
13807c478bdstevel@tonic-gate		show_termcb(pri, offset);
13817c478bdstevel@tonic-gate		break;
13827c478bdstevel@tonic-gate	/* streams ioctl()s */
13837c478bdstevel@tonic-gate#if 0
13847c478bdstevel@tonic-gate		/* these are displayed as strings in the arg list */
13857c478bdstevel@tonic-gate		/* by prt_ioa().  don't display them again here */
13867c478bdstevel@tonic-gate	case I_PUSH:
13877c478bdstevel@tonic-gate	case I_LOOK:
13887c478bdstevel@tonic-gate	case I_FIND:
13897c478bdstevel@tonic-gate		/* these are displayed as decimal in the arg list */
13907c478bdstevel@tonic-gate		/* by prt_ioa().  don't display them again here */
13917c478bdstevel@tonic-gate	case I_LINK:
13927c478bdstevel@tonic-gate	case I_UNLINK:
13937c478bdstevel@tonic-gate	case I_SENDFD:
13947c478bdstevel@tonic-gate		/* these are displayed symbolically in the arg list */
13957c478bdstevel@tonic-gate		/* by prt_ioa().  don't display them again here */
13967c478bdstevel@tonic-gate	case I_SRDOPT:
13977c478bdstevel@tonic-gate	case I_SETSIG:
13987c478bdstevel@tonic-gate	case I_FLUSH:
13997c478bdstevel@tonic-gate		break;
14007c478bdstevel@tonic-gate		/* this one just ignores the argument */
14017c478bdstevel@tonic-gate	case I_POP:
14027c478bdstevel@tonic-gate		break;
14037c478bdstevel@tonic-gate#endif
14047c478bdstevel@tonic-gate		/* these return something in an int pointed to by arg */
14057c478bdstevel@tonic-gate	case I_NREAD:
14067c478bdstevel@tonic-gate	case I_GRDOPT:
14077c478bdstevel@tonic-gate	case I_GETSIG:
14087c478bdstevel@tonic-gate	case TIOCGSID:
14097c478bdstevel@tonic-gate	case TIOCGPGRP:
14107c478bdstevel@tonic-gate	case TIOCLGET:
14117c478bdstevel@tonic-gate	case FIONREAD:
14127c478bdstevel@tonic-gate	case FIORDCHK:
14137c478bdstevel@tonic-gate		if (err)
14147c478bdstevel@tonic-gate			break;
14157c478bdstevel@tonic-gate		/*FALLTHROUGH*/
14167c478bdstevel@tonic-gate		/* these pass something in an int pointed to by arg */
14177c478bdstevel@tonic-gate	case TIOCSPGRP:
14187c478bdstevel@tonic-gate	case TIOCFLUSH:
14197c478bdstevel@tonic-gate	case TIOCLBIS:
14207c478bdstevel@tonic-gate	case TIOCLBIC:
14217c478bdstevel@tonic-gate	case TIOCLSET:
14227c478bdstevel@tonic-gate		show_strint(pri, code, offset);
14237c478bdstevel@tonic-gate		break;
14247c478bdstevel@tonic-gate		/* these all point to structures */
14257c478bdstevel@tonic-gate	case I_STR:
14267c478bdstevel@tonic-gate#ifdef _LP64
14277c478bdstevel@tonic-gate		if (lp64)
14287c478bdstevel@tonic-gate			show_strioctl(pri, offset);
14297c478bdstevel@tonic-gate		else
14307c478bdstevel@tonic-gate			show_strioctl32(pri, offset);
14317c478bdstevel@tonic-gate#else
14327c478bdstevel@tonic-gate		show_strioctl(pri, offset);
14337c478bdstevel@tonic-gate#endif
14347c478bdstevel@tonic-gate		break;
14357c478bdstevel@tonic-gate	case I_PEEK:
14367c478bdstevel@tonic-gate#ifdef _LP64
14377c478bdstevel@tonic-gate		if (lp64)
14387c478bdstevel@tonic-gate			show_strpeek(pri, offset);
14397c478bdstevel@tonic-gate		else
14407c478bdstevel@tonic-gate			show_strpeek32(pri, offset);
14417c478bdstevel@tonic-gate#else
14427c478bdstevel@tonic-gate		show_strpeek(pri, offset);
14437c478bdstevel@tonic-gate#endif
14447c478bdstevel@tonic-gate		break;
14457c478bdstevel@tonic-gate	case I_FDINSERT:
14467c478bdstevel@tonic-gate#ifdef _LP64
14477c478bdstevel@tonic-gate		if (lp64)
14487c478bdstevel@tonic-gate			show_strfdinsert(pri, offset);
14497c478bdstevel@tonic-gate		else
14507c478bdstevel@tonic-gate			show_strfdinsert32(pri, offset);
14517c478bdstevel@tonic-gate#else
14527c478bdstevel@tonic-gate		show_strfdinsert(pri, offset);
14537c478bdstevel@tonic-gate#endif
14547c478bdstevel@tonic-gate		break;
14557c478bdstevel@tonic-gate	case I_RECVFD:
14567c478bdstevel@tonic-gate		if (err)
14577c478bdstevel@tonic-gate			break;
14587c478bdstevel@tonic-gate		show_strrecvfd(pri, offset);
14597c478bdstevel@tonic-gate		break;
14607c478bdstevel@tonic-gate	case I_LIST:
14617c478bdstevel@tonic-gate		if (err)
14627c478bdstevel@tonic-gate			break;
14637c478bdstevel@tonic-gate#ifdef _LP64
14647c478bdstevel@tonic-gate		if (lp64)
14657c478bdstevel@tonic-gate			show_strlist(pri, offset);
14667c478bdstevel@tonic-gate		else
14677c478bdstevel@tonic-gate			show_strlist32(pri, offset);
14687c478bdstevel@tonic-gate#else
14697c478bdstevel@tonic-gate		show_strlist(pri, offset);
14707c478bdstevel@tonic-gate#endif
14717c478bdstevel@tonic-gate		break;
14727c478bdstevel@tonic-gate	case JWINSIZE:
14737c478bdstevel@tonic-gate		if (err)
14747c478bdstevel@tonic-gate			break;
14757c478bdstevel@tonic-gate		show_jwinsize(pri, offset);
14767c478bdstevel@tonic-gate		break;
14777c478bdstevel@tonic-gate	case TIOCGWINSZ:
14787c478bdstevel@tonic-gate		if (err)
14797c478bdstevel@tonic-gate			break;
14807c478bdstevel@tonic-gate		/*FALLTHROUGH*/
14817c478bdstevel@tonic-gate	case TIOCSWINSZ:
14827c478bdstevel@tonic-gate		show_winsize(pri, offset);
14837c478bdstevel@tonic-gate		break;
14847c478bdstevel@tonic-gate	case AUDIO_GETINFO:
14857c478bdstevel@tonic-gate	case (int)AUDIO_SETINFO:
14867c478bdstevel@tonic-gate		show_audio_info(pri, offset);
14877c478bdstevel@tonic-gate		break;
14887c478bdstevel@tonic-gate
14897c478bdstevel@tonic-gate	default:
1490a803cc2Gordon Ross		if ((code & ~0xff) == ZFS_IOC) {
1491a803cc2Gordon Ross			show_zfs_ioc(pri, offset);
1492a803cc2Gordon Ross			break;
1493a803cc2Gordon Ross		}
1494a803cc2Gordon Ross
14957c478bdstevel@tonic-gate		if (code & IOC_INOUT) {
14967c478bdstevel@tonic-gate			const char *str = ioctldatastruct(code);
14977c478bdstevel@tonic-gate
14987c478bdstevel@tonic-gate			(void) printf("\t\t%s",
14997c478bdstevel@tonic-gate			    (code & IOC_INOUT) == IOC_INOUT ? "write/read" :
15007c478bdstevel@tonic-gate			    code & IOC_IN ? "write" : "read");
15017c478bdstevel@tonic-gate			if (str != NULL) {
15027c478bdstevel@tonic-gate				(void) printf(" (struct %s)\n", str);
15037c478bdstevel@tonic-gate			} else {
15047c478bdstevel@tonic-gate				(void) printf(" %d bytes\n",
15057c478bdstevel@tonic-gate				    (code >> 16) & IOCPARM_MASK);
15067c478bdstevel@tonic-gate			}
15077c478bdstevel@tonic-gate		}
15087c478bdstevel@tonic-gate	}
15097c478bdstevel@tonic-gate}
15107c478bdstevel@tonic-gate
15117c478bdstevel@tonic-gatevoid
15127c478bdstevel@tonic-gateshow_statvfs(private_t *pri)
15137c478bdstevel@tonic-gate{
15147c478bdstevel@tonic-gate	long offset;
15157c478bdstevel@tonic-gate	struct statvfs statvfs;
15167c478bdstevel@tonic-gate	char *cp;
15177c478bdstevel@tonic-gate
151827aa481Toomas Soome	if (pri->sys_nargs > 1 && (offset = pri->sys_args[1]) != 0 &&
15197c478bdstevel@tonic-gate	    Pread(Proc, &statvfs, sizeof (statvfs), offset)
15207c478bdstevel@tonic-gate	    == sizeof (statvfs)) {
15217c478bdstevel@tonic-gate		(void) printf(
15227c478bdstevel@tonic-gate		"%s\tbsize=%-10lu frsize=%-9lu blocks=%-8llu bfree=%-9llu\n",
1523019c3c4raf		    pri->pname,
1524019c3c4raf		    statvfs.f_bsize,
1525019c3c4raf		    statvfs.f_frsize,
1526019c3c4raf		    (u_longlong_t)statvfs.f_blocks,
1527019c3c4raf		    (u_longlong_t)statvfs.f_bfree);
15287c478bdstevel@tonic-gate		(void) printf(
15297c478bdstevel@tonic-gate		"%s\tbavail=%-9llu files=%-10llu ffree=%-9llu favail=%-9llu\n",
1530019c3c4raf		    pri->pname,
1531019c3c4raf		    (u_longlong_t)statvfs.f_bavail,
1532019c3c4raf		    (u_longlong_t)statvfs.f_files,
1533019c3c4raf		    (u_longlong_t)statvfs.f_ffree,
1534019c3c4raf		    (u_longlong_t)statvfs.f_favail);
15357c478bdstevel@tonic-gate		(void) printf(
1536019c3c4raf		    "%s\tfsid=0x%-9.4lX basetype=%-7.16s namemax=%ld\n",
1537019c3c4raf		    pri->pname,
1538019c3c4raf		    statvfs.f_fsid,
1539019c3c4raf		    statvfs.f_basetype,
1540019c3c4raf		    (long)statvfs.f_namemax);
15417c478bdstevel@tonic-gate		(void) printf(
1542019c3c4raf		    "%s\tflag=%s\n",
1543019c3c4raf		    pri->pname,
1544019c3c4raf		    svfsflags(pri, (ulong_t)statvfs.f_flag));
15457c478bdstevel@tonic-gate		cp = statvfs.f_fstr + strlen(statvfs.f_fstr);
15467c478bdstevel@tonic-gate		if (cp < statvfs.f_fstr + sizeof (statvfs.f_fstr) - 1 &&
15477c478bdstevel@tonic-gate		    *(cp+1) != '\0')
15487c478bdstevel@tonic-gate			*cp = ' ';
15497c478bdstevel@tonic-gate		(void) printf("%s\tfstr=\"%.*s\"\n",
1550019c3c4raf		    pri->pname,
1551019c3c4raf		    (int)sizeof (statvfs.f_fstr),
1552019c3c4raf		    statvfs.f_fstr);
15537c478bdstevel@tonic-gate	}
15547c478bdstevel@tonic-gate}
15557c478bdstevel@tonic-gate
15567c478bdstevel@tonic-gate#ifdef _LP64
15577c478bdstevel@tonic-gatevoid
15587c478bdstevel@tonic-gateshow_statvfs32(private_t *pri)
15597c478bdstevel@tonic-gate{
15607c478bdstevel@tonic-gate	long offset;
15617c478bdstevel@tonic-gate	struct statvfs32 statvfs;
15627c478bdstevel@tonic-gate	char *cp;
15637c478bdstevel@tonic-gate
156427aa481Toomas Soome	if (pri->sys_nargs > 1 && (offset = pri->sys_args[1]) != 0 &&
15657c478bdstevel@tonic-gate	    Pread(Proc, &statvfs, sizeof (statvfs), offset)
15667c478bdstevel@tonic-gate	    == sizeof (statvfs)) {
15677c478bdstevel@tonic-gate		(void) printf(
1568019c3c4raf		    "%s\tbsize=%-10u frsize=%-9u blocks=%-8u bfree=%-9u\n",
1569019c3c4raf		    pri->pname,
1570019c3c4raf		    statvfs.f_bsize,
1571019c3c4raf		    statvfs.f_frsize,
1572019c3c4raf		    statvfs.f_blocks,
1573019c3c4raf		    statvfs.f_bfree);
15747c478bdstevel@tonic-gate		(void) printf(
1575019c3c4raf		    "%s\tbavail=%-9u files=%-10u ffree=%-9u favail=%-9u\n",
1576019c3c4raf		    pri->pname,
1577019c3c4raf		    statvfs.f_bavail,
1578019c3c4raf		    statvfs.f_files,
1579019c3c4raf		    statvfs.f_ffree,
1580019c3c4raf		    statvfs.f_favail);
15817c478bdstevel@tonic-gate		(void) printf(
1582019c3c4raf		    "%s\tfsid=0x%-9.4X basetype=%-7.16s namemax=%d\n",
1583019c3c4raf		    pri->pname,
1584019c3c4raf		    statvfs.f_fsid,
1585019c3c4raf		    statvfs.f_basetype,
1586019c3c4raf		    (int)statvfs.f_namemax);
15877c478bdstevel@tonic-gate		(void) printf(
1588019c3c4raf		    "%s\tflag=%s\n",
1589019c3c4raf		    pri->pname,
1590019c3c4raf		    svfsflags(pri, (ulong_t)statvfs.f_flag));
15917c478bdstevel@tonic-gate		cp = statvfs.f_fstr + strlen(statvfs.f_fstr);
15927c478bdstevel@tonic-gate		if (cp < statvfs.f_fstr + sizeof (statvfs.f_fstr) - 1 &&
15937c478bdstevel@tonic-gate		    *(cp+1) != '\0')
15947c478bdstevel@tonic-gate			*cp = ' ';
15957c478bdstevel@tonic-gate		(void) printf("%s\tfstr=\"%.*s\"\n",
1596019c3c4raf		    pri->pname,
1597019c3c4raf		    (int)sizeof (statvfs.f_fstr),
1598019c3c4raf		    statvfs.f_fstr);
15997c478bdstevel@tonic-gate	}
16007c478bdstevel@tonic-gate}
16017c478bdstevel@tonic-gate#endif	/* _LP64 */
16027c478bdstevel@tonic-gate
16037c478bdstevel@tonic-gatevoid
16047c478bdstevel@tonic-gateshow_statvfs64(private_t *pri)
16057c478bdstevel@tonic-gate{
16067c478bdstevel@tonic-gate	long offset;
16077c478bdstevel@tonic-gate	struct statvfs64_32 statvfs;
16087c478bdstevel@tonic-gate	char *cp;
16097c478bdstevel@tonic-gate
161027aa481Toomas Soome	if (pri->sys_nargs > 1 && (offset = pri->sys_args[1]) != 0 &&
16117c478bdstevel@tonic-gate	    Pread(Proc, &statvfs, sizeof (statvfs), offset)
16127c478bdstevel@tonic-gate	    == sizeof (statvfs)) {
16137c478bdstevel@tonic-gate		(void) printf(
1614019c3c4raf		    "%s\tbsize=%-10u frsize=%-9u blocks=%-8llu bfree=%-9llu\n",
1615019c3c4raf		    pri->pname,
1616019c3c4raf		    statvfs.f_bsize,
1617019c3c4raf		    statvfs.f_frsize,
1618019c3c4raf		    (u_longlong_t)statvfs.f_blocks,
1619019c3c4raf		    (u_longlong_t)statvfs.f_bfree);
16207c478bdstevel@tonic-gate		(void) printf(
16217c478bdstevel@tonic-gate		"%s\tbavail=%-9llu files=%-10llu ffree=%-9llu favail=%-9llu\n",
1622019c3c4raf		    pri->pname,
1623019c3c4raf		    (u_longlong_t)statvfs.f_bavail,
1624019c3c4raf		    (u_longlong_t)statvfs.f_files,
1625019c3c4raf		    (u_longlong_t)statvfs.f_ffree,
1626019c3c4raf		    (u_longlong_t)statvfs.f_favail);
16277c478bdstevel@tonic-gate		(void) printf(
1628019c3c4raf		    "%s\tfsid=0x%-9.4X basetype=%-7.16s namemax=%d\n",
1629019c3c4raf		    pri->pname,
1630019c3c4raf		    statvfs.f_fsid,
1631019c3c4raf		    statvfs.f_basetype,
1632019c3c4raf		    (int)statvfs.f_namemax);
16337c478bdstevel@tonic-gate		(void) printf(
1634019c3c4raf		    "%s\tflag=%s\n",
1635019c3c4raf		    pri->pname,
1636019c3c4raf		    svfsflags(pri, (ulong_t)statvfs.f_flag));
16377c478bdstevel@tonic-gate		cp = statvfs.f_fstr + strlen(statvfs.f_fstr);
16387c478bdstevel@tonic-gate		if (cp < statvfs.f_fstr + sizeof (statvfs.f_fstr) - 1 &&
16397c478bdstevel@tonic-gate		    *(cp+1) != '\0')
16407c478bdstevel@tonic-gate			*cp = ' ';
16417c478bdstevel@tonic-gate		(void) printf("%s\tfstr=\"%.*s\"\n",
1642019c3c4raf		    pri->pname,
1643019c3c4raf		    (int)sizeof (statvfs.f_fstr),
1644019c3c4raf		    statvfs.f_fstr);
16457c478bdstevel@tonic-gate	}
16467c478bdstevel@tonic-gate}
16477c478bdstevel@tonic-gate
16487c478bdstevel@tonic-gatevoid
16497c478bdstevel@tonic-gateshow_statfs(private_t *pri)
16507c478bdstevel@tonic-gate{
16517c478bdstevel@tonic-gate	long offset;
16527c478bdstevel@tonic-gate	struct statfs statfs;
16537c478bdstevel@tonic-gate
165427aa481Toomas Soome	if (pri->sys_nargs >= 2 && (offset = pri->sys_args[1]) != 0 &&
16557c478bdstevel@tonic-gate	    Pread(Proc, &statfs, sizeof (statfs), offset) == sizeof (statfs)) {
16567c478bdstevel@tonic-gate		(void) printf(
16577c478bdstevel@tonic-gate		"%s\tfty=%d bsz=%ld fsz=%ld blk=%ld bfr=%ld fil=%lu ffr=%lu\n",
1658019c3c4raf		    pri->pname,
1659019c3c4raf		    statfs.f_fstyp,
1660019c3c4raf		    statfs.f_bsize,
1661019c3c4raf		    statfs.f_frsize,
1662019c3c4raf		    statfs.f_blocks,
1663019c3c4raf		    statfs.f_bfree,
1664019c3c4raf		    statfs.f_files,
1665019c3c4raf		    statfs.f_ffree);
16667c478bdstevel@tonic-gate		(void) printf("%s\t    fname=%.6s fpack=%.6s\n",
1667019c3c4raf		    pri->pname,
1668019c3c4raf		    statfs.f_fname,
1669019c3c4raf		    statfs.f_fpack);
16707c478bdstevel@tonic-gate	}
16717c478bdstevel@tonic-gate}
16727c478bdstevel@tonic-gate
16737c478bdstevel@tonic-gate#ifdef _LP64
16747c478bdstevel@tonic-gatevoid
16757c478bdstevel@tonic-gateshow_statfs32(private_t *pri)
16767c478bdstevel@tonic-gate{
16777c478bdstevel@tonic-gate	long offset;
16787c478bdstevel@tonic-gate	struct statfs32 statfs;
16797c478bdstevel@tonic-gate
168027aa481Toomas Soome	if (pri->sys_nargs >= 2 && (offset = pri->sys_args[1]) != 0 &&
16817c478bdstevel@tonic-gate	    Pread(Proc, &statfs, sizeof (statfs), offset) == sizeof (statfs)) {
16827c478bdstevel@tonic-gate		(void) printf(
1683019c3c4raf		    "%s\tfty=%d bsz=%d fsz=%d blk=%d bfr=%d fil=%u ffr=%u\n",
1684019c3c4raf		    pri->pname,
1685019c3c4raf		    statfs.f_fstyp,
1686019c3c4raf		    statfs.f_bsize,
1687019c3c4raf		    statfs.f_frsize,
1688019c3c4raf		    statfs.f_blocks,
1689019c3c4raf		    statfs.f_bfree,
1690019c3c4raf		    statfs.f_files,
1691019c3c4raf		    statfs.f_ffree);
16927c478bdstevel@tonic-gate		(void) printf("%s\t    fname=%.6s fpack=%.6s\n",
1693019c3c4raf		    pri->pname,
1694019c3c4raf		    statfs.f_fname,
1695019c3c4raf		    statfs.f_fpack);
16967c478bdstevel@tonic-gate	}
16977c478bdstevel@tonic-gate}
16987c478bdstevel@tonic-gate#endif	/* _LP64 */
16997c478bdstevel@tonic-gate
17007c478bdstevel@tonic-gatevoid
17017c478bdstevel@tonic-gateshow_flock32(private_t *pri, long offset)
17027c478bdstevel@tonic-gate{
17037c478bdstevel@tonic-gate	struct flock32 flock;
17047c478bdstevel@tonic-gate
17057c478bdstevel@tonic-gate	if (Pread(Proc, &flock, sizeof (flock), offset) == sizeof (flock)) {
17067c478bdstevel@tonic-gate		const char *str = NULL;
17077c478bdstevel@tonic-gate
17087c478bdstevel@tonic-gate		(void) printf("%s\ttyp=", pri->pname);
17097c478bdstevel@tonic-gate
17107c478bdstevel@tonic-gate		switch (flock.l_type) {
17117c478bdstevel@tonic-gate		case F_RDLCK:
17127c478bdstevel@tonic-gate			str = "F_RDLCK";
17137c478bdstevel@tonic-gate			break;
17147c478bdstevel@tonic-gate		case F_WRLCK:
17157c478bdstevel@tonic-gate			str = "F_WRLCK";
17167c478bdstevel@tonic-gate			break;
17177c478bdstevel@tonic-gate		case F_UNLCK:
17187c478bdstevel@tonic-gate			str = "F_UNLCK";
17197c478bdstevel@tonic-gate			break;
17207c478bdstevel@tonic-gate		}
17217c478bdstevel@tonic-gate		if (str != NULL)
17227c478bdstevel@tonic-gate			(void) printf("%s", str);
17237c478bdstevel@tonic-gate		else
17247c478bdstevel@tonic-gate			(void) printf("%-7d", flock.l_type);
17257c478bdstevel@tonic-gate
17267c478bdstevel@tonic-gate		str = whencearg(flock.l_whence);
17277c478bdstevel@tonic-gate		if (str != NULL)
17287c478bdstevel@tonic-gate			(void) printf("  whence=%s", str);
17297c478bdstevel@tonic-gate		else
17307c478bdstevel@tonic-gate			(void) printf("  whence=%-8u", flock.l_whence);
17317c478bdstevel@tonic-gate
17327c478bdstevel@tonic-gate		(void) printf(
1733019c3c4raf		    " start=%-5d len=%-5d sys=%-2u pid=%d\n",
1734019c3c4raf		    flock.l_start,
1735019c3c4raf		    flock.l_len,
1736019c3c4raf		    flock.l_sysid,
1737019c3c4raf		    flock.l_pid);
17387c478bdstevel@tonic-gate	}
17397c478bdstevel@tonic-gate}
17407c478bdstevel@tonic-gate
17417c478bdstevel@tonic-gatevoid
17427c478bdstevel@tonic-gateshow_flock64(private_t *pri, long offset)
17437c478bdstevel@tonic-gate{
17447c478bdstevel@tonic-gate	struct flock64 flock;
17457c478bdstevel@tonic-gate
17467c478bdstevel@tonic-gate	if (Pread(Proc, &flock, sizeof (flock), offset) == sizeof (flock)) {
17477c478bdstevel@tonic-gate		const char *str = NULL;
17487c478bdstevel@tonic-gate
17497c478bdstevel@tonic-gate		(void) printf("%s\ttyp=", pri->pname);
17507c478bdstevel@tonic-gate
17517c478bdstevel@tonic-gate		switch (flock.l_type) {
17527c478bdstevel@tonic-gate		case F_RDLCK:
17537c478bdstevel@tonic-gate			str = "F_RDLCK";
17547c478bdstevel@tonic-gate			break;
17557c478bdstevel@tonic-gate		case F_WRLCK:
17567c478bdstevel@tonic-gate			str = "F_WRLCK";
17577c478bdstevel@tonic-gate			break;
17587c478bdstevel@tonic-gate		case F_UNLCK:
17597c478bdstevel@tonic-gate			str = "F_UNLCK";
17607c478bdstevel@tonic-gate			break;
17617c478bdstevel@tonic-gate		}
17627c478bdstevel@tonic-gate		if (str != NULL)
17637c478bdstevel@tonic-gate			(void) printf("%s", str);
17647c478bdstevel@tonic-gate		else
17657c478bdstevel@tonic-gate			(void) printf("%-7d", flock.l_type);
17667c478bdstevel@tonic-gate
17677c478bdstevel@tonic-gate		str = whencearg(flock.l_whence);
17687c478bdstevel@tonic-gate		if (str != NULL)
17697c478bdstevel@tonic-gate			(void) printf("  whence=%s", str);
17707c478bdstevel@tonic-gate		else
17717c478bdstevel@tonic-gate			(void) printf("  whence=%-8u", flock.l_whence);
17727c478bdstevel@tonic-gate
17737c478bdstevel@tonic-gate		(void) printf(
1774019c3c4raf		    " start=%-5lld len=%-5lld sys=%-2u pid=%d\n",
1775019c3c4raf		    (long long)flock.l_start,
1776019c3c4raf		    (long long)flock.l_len,
1777019c3c4raf		    flock.l_sysid,
1778019c3c4raf		    (int)flock.l_pid);
17797c478bdstevel@tonic-gate	}
17807c478bdstevel@tonic-gate}
17817c478bdstevel@tonic-gate
17827c478bdstevel@tonic-gatevoid
17837c478bdstevel@tonic-gateshow_share(private_t *pri, long offset)
17847c478bdstevel@tonic-gate{
17857c478bdstevel@tonic-gate	struct fshare fshare;
17867c478bdstevel@tonic-gate
17877c478bdstevel@tonic-gate	if (Pread(Proc, &fshare, sizeof (fshare), offset) == sizeof (fshare)) {
17887c478bdstevel@tonic-gate		const char *str = NULL;
17897c478bdstevel@tonic-gate		int manddny = 0;
17907c478bdstevel@tonic-gate
17917c478bdstevel@tonic-gate		(void) printf("%s\taccess=", pri->pname);
17927c478bdstevel@tonic-gate
17937c478bdstevel@tonic-gate		switch (fshare.f_access) {
17947c478bdstevel@tonic-gate		case F_RDACC:
17957c478bdstevel@tonic-gate			str = "F_RDACC";
17967c478bdstevel@tonic-gate			break;
17977c478bdstevel@tonic-gate		case F_WRACC:
17987c478bdstevel@tonic-gate			str = "F_WRACC";
17997c478bdstevel@tonic-gate			break;
18007c478bdstevel@tonic-gate		case F_RWACC:
18017c478bdstevel@tonic-gate			str = "F_RWACC";
18027c478bdstevel@tonic-gate			break;
18037c478bdstevel@tonic-gate		}
18047c478bdstevel@tonic-gate		if (str != NULL)
18057c478bdstevel@tonic-gate			(void) printf("%s", str);
18067c478bdstevel@tonic-gate		else
18077c478bdstevel@tonic-gate			(void) printf("%-7d", fshare.f_access);
18087c478bdstevel@tonic-gate
18097c478bdstevel@tonic-gate		str = NULL;
18107c478bdstevel@tonic-gate		if (fshare.f_deny & F_MANDDNY) {
18117c478bdstevel@tonic-gate			fshare.f_deny &= ~F_MANDDNY;
18127c478bdstevel@tonic-gate			manddny = 1;
18137c478bdstevel@tonic-gate		}
18147c478bdstevel@tonic-gate		switch (fshare.f_deny) {
18157c478bdstevel@tonic-gate		case F_NODNY:
18167c478bdstevel@tonic-gate			str = "F_NODNY";
18177c478bdstevel@tonic-gate			break;
18187c478bdstevel@tonic-gate		case F_RDDNY:
18197c478bdstevel@tonic-gate			str = "F_RDDNY";
18207c478bdstevel@tonic-gate			break;
18217c478bdstevel@tonic-gate		case F_WRDNY:
18227c478bdstevel@tonic-gate			str = "F_WRDNY";
18237c478bdstevel@tonic-gate			break;
18247c478bdstevel@tonic-gate		case F_RWDNY:
18257c478bdstevel@tonic-gate			str = "F_RWDNY";
18267c478bdstevel@tonic-gate			break;
18277c478bdstevel@tonic-gate		case F_COMPAT:
18287c478bdstevel@tonic-gate			str = "F_COMPAT";
18297c478bdstevel@tonic-gate			break;
18307c478bdstevel@tonic-gate		}
18317c478bdstevel@tonic-gate		if (str != NULL) {
18327c478bdstevel@tonic-gate			if (manddny)
18337c478bdstevel@tonic-gate				(void) printf("  deny=F_MANDDNY|%s", str);
18347c478bdstevel@tonic-gate			else
18357c478bdstevel@tonic-gate				(void) printf("  deny=%s", str);
18367c478bdstevel@tonic-gate		} else {
18377c478bdstevel@tonic-gate			(void) printf("  deny=0x%x", manddny?
1838019c3c4raf			    fshare.f_deny | F_MANDDNY : fshare.f_deny);
18397c478bdstevel@tonic-gate		}
18407c478bdstevel@tonic-gate
18417c478bdstevel@tonic-gate		(void) printf("  id=%x\n", fshare.f_id);
18427c478bdstevel@tonic-gate	}
18437c478bdstevel@tonic-gate}
18447c478bdstevel@tonic-gate
18457c478bdstevel@tonic-gatevoid
18467c478bdstevel@tonic-gateshow_ffg(private_t *pri)
18477c478bdstevel@tonic-gate{
18487c478bdstevel@tonic-gate	(void) putchar('\t');
18497c478bdstevel@tonic-gate	(void) putchar('\t');
18507c478bdstevel@tonic-gate	prt_ffg(pri, 0, pri->Rval1);
18517c478bdstevel@tonic-gate	(void) puts(pri->sys_string);
18527c478bdstevel@tonic-gate}
18537c478bdstevel@tonic-gate
18547c478bdstevel@tonic-gate/* print values in fcntl() pointed-to structure */
18557c478bdstevel@tonic-gatevoid
18567c478bdstevel@tonic-gateshow_fcntl(private_t *pri)
18577c478bdstevel@tonic-gate{
18587c478bdstevel@tonic-gate	long offset;
18597c478bdstevel@tonic-gate
18607c478bdstevel@tonic-gate	if (pri->sys_nargs >= 2 && pri->sys_args[1] == F_GETFL) {
18617c478bdstevel@tonic-gate		show_ffg(pri);
18627c478bdstevel@tonic-gate		return;
18637c478bdstevel@tonic-gate	}
18647c478bdstevel@tonic-gate
186527aa481Toomas Soome	if (pri->sys_nargs < 3 || (offset = pri->sys_args[2]) == 0)
18667c478bdstevel@tonic-gate		return;
18677c478bdstevel@tonic-gate
18687c478bdstevel@tonic-gate	switch (pri->sys_args[1]) {
18697c478bdstevel@tonic-gate#ifdef _LP64
18707c478bdstevel@tonic-gate	case F_GETLK:
18717c478bdstevel@tonic-gate	case F_SETLK:
18727c478bdstevel@tonic-gate	case F_SETLKW:
18737c478bdstevel@tonic-gate	case F_FREESP:
18747c478bdstevel@tonic-gate	case F_ALLOCSP:
18757c478bdstevel@tonic-gate	case F_SETLK_NBMAND:
18767a5aac9Jerry Jelinek	case F_OFD_GETLK:
18777a5aac9Jerry Jelinek	case F_OFD_SETLK:
18787a5aac9Jerry Jelinek	case F_OFD_SETLKW:
18797a5aac9Jerry Jelinek	case F_FLOCK:
18807a5aac9Jerry Jelinek	case F_FLOCKW:
18817c478bdstevel@tonic-gate		if (data_model == PR_MODEL_LP64)
18827c478bdstevel@tonic-gate			show_flock64(pri, offset);
18837c478bdstevel@tonic-gate		else
18847c478bdstevel@tonic-gate			show_flock32(pri, offset);
18857c478bdstevel@tonic-gate		break;
18867c478bdstevel@tonic-gate	case 33:	/* F_GETLK64 */
18877c478bdstevel@tonic-gate	case 34:	/* F_SETLK64 */
18887c478bdstevel@tonic-gate	case 35:	/* F_SETLKW64 */
18897c478bdstevel@tonic-gate	case 27:	/* F_FREESP64 */
1890019c3c4raf	case 28:	/* F_ALLOCSP64 */
18917c478bdstevel@tonic-gate	case 44:	/* F_SETLK64_NBMAND */
18927a5aac9Jerry Jelinek	case 50:	/* F_OFD_GETLK64 */
18937a5aac9Jerry Jelinek	case 51:	/* F_OFD_SETLK64 */
18947a5aac9Jerry Jelinek	case 52:	/* F_OFD_SETLKW64 */
18957a5aac9Jerry Jelinek	case 55:	/* F_FLOCK64 */
18967a5aac9Jerry Jelinek	case 56:	/* F_FLOCKW64 */
18977c478bdstevel@tonic-gate		show_flock64(pri, offset);
18987c478bdstevel@tonic-gate		break;
18997c478bdstevel@tonic-gate#else	/* _LP64 */
19007c478bdstevel@tonic-gate	case F_GETLK:
19017c478bdstevel@tonic-gate	case F_SETLK:
19027c478bdstevel@tonic-gate	case F_SETLKW:
19037c478bdstevel@tonic-gate	case F_FREESP:
19047c478bdstevel@tonic-gate	case F_ALLOCSP:
19057c478bdstevel@tonic-gate	case F_SETLK_NBMAND:
19067c478bdstevel@tonic-gate		show_flock32(pri, offset);
19077c478bdstevel@tonic-gate		break;
19087c478bdstevel@tonic-gate	case F_GETLK64:
19097c478bdstevel@tonic-gate	case F_SETLK64:
19107c478bdstevel@tonic-gate	case F_SETLKW64:
19117c478bdstevel@tonic-gate	case F_FREESP64:
1912019c3c4raf	case F_ALLOCSP64:
19137c478bdstevel@tonic-gate	case F_SETLK64_NBMAND:
19147a5aac9Jerry Jelinek	case F_OFD_GETLK64:
19157a5aac9Jerry Jelinek	case F_OFD_SETLK64:
19167a5aac9Jerry Jelinek	case F_OFD_SETLKW64:
19177a5aac9Jerry Jelinek	case F_FLOCK64:
19187a5aac9Jerry Jelinek	case F_FLOCKW64:
19197c478bdstevel@tonic-gate		show_flock64(pri, offset);
19207c478bdstevel@tonic-gate		break;
19217c478bdstevel@tonic-gate#endif	/* _LP64 */
19227c478bdstevel@tonic-gate	case F_SHARE:
19237c478bdstevel@tonic-gate	case F_UNSHARE:
19247c478bdstevel@tonic-gate		show_share(pri, offset);
19257c478bdstevel@tonic-gate		break;
19267c478bdstevel@tonic-gate	}
19277c478bdstevel@tonic-gate}
19287c478bdstevel@tonic-gate
19297c478bdstevel@tonic-gatevoid
19307c478bdstevel@tonic-gateshow_strbuf(private_t *pri, long offset, const char *name, int dump)
19317c478bdstevel@tonic-gate{
19327c478bdstevel@tonic-gate	struct strbuf strbuf;
19337c478bdstevel@tonic-gate
19347c478bdstevel@tonic-gate	if (Pread(Proc, &strbuf, sizeof (strbuf), offset) == sizeof (strbuf))
19357c478bdstevel@tonic-gate		print_strbuf(pri, &strbuf, name, dump);
19367c478bdstevel@tonic-gate}
19377c478bdstevel@tonic-gate
19387c478bdstevel@tonic-gate#ifdef _LP64
19397c478bdstevel@tonic-gatevoid
19407c478bdstevel@tonic-gateshow_strbuf32(private_t *pri, long offset, const char *name, int dump)
19417c478bdstevel@tonic-gate{
19427c478bdstevel@tonic-gate	struct strbuf32 strbuf;
19437c478bdstevel@tonic-gate
19447c478bdstevel@tonic-gate	if (Pread(Proc, &strbuf, sizeof (strbuf), offset) == sizeof (strbuf))
19457c478bdstevel@tonic-gate		print_strbuf32(pri, &strbuf, name, dump);
19467c478bdstevel@tonic-gate}
19477c478bdstevel@tonic-gate#endif	/* _LP64 */
19487c478bdstevel@tonic-gate
19497c478bdstevel@tonic-gatevoid
19507c478bdstevel@tonic-gateshow_gp_msg(private_t *pri, int what)
19517c478bdstevel@tonic-gate{
19527c478bdstevel@tonic-gate	long offset;
19537c478bdstevel@tonic-gate	int dump = FALSE;
19547c478bdstevel@tonic-gate	int fdp1 = pri->sys_args[0] + 1;
19557c478bdstevel@tonic-gate
19567c478bdstevel@tonic-gate	switch (what) {
19577c478bdstevel@tonic-gate	case SYS_getmsg:
19587c478bdstevel@tonic-gate	case SYS_getpmsg:
19597c478bdstevel@tonic-gate		if (pri->Errno == 0 && prismember(&readfd, fdp1))
19607c478bdstevel@tonic-gate			dump = TRUE;
19617c478bdstevel@tonic-gate		break;
19627c478bdstevel@tonic-gate	case SYS_putmsg:
19637c478bdstevel@tonic-gate	case SYS_putpmsg:
19647c478bdstevel@tonic-gate		if (prismember(&writefd, fdp1))
19657c478bdstevel@tonic-gate			dump = TRUE;
19667c478bdstevel@tonic-gate		break;
19677c478bdstevel@tonic-gate	}
19687c478bdstevel@tonic-gate
19697c478bdstevel@tonic-gate	/* enter region of lengthy output */
19707c478bdstevel@tonic-gate	if (dump)
19717c478bdstevel@tonic-gate		Eserialize();
19727c478bdstevel@tonic-gate
19737c478bdstevel@tonic-gate#ifdef _LP64
197427aa481Toomas Soome	if (pri->sys_nargs >= 2 && (offset = pri->sys_args[1]) != 0) {
19757c478bdstevel@tonic-gate		if (data_model == PR_MODEL_LP64)
19767c478bdstevel@tonic-gate			show_strbuf(pri, offset, "ctl", dump);
19777c478bdstevel@tonic-gate		else
19787c478bdstevel@tonic-gate			show_strbuf32(pri, offset, "ctl", dump);
19797c478bdstevel@tonic-gate	}
198027aa481Toomas Soome	if (pri->sys_nargs >= 3 && (offset = pri->sys_args[2]) != 0) {
19817c478bdstevel@tonic-gate		if (data_model == PR_MODEL_LP64)
19827c478bdstevel@tonic-gate			show_strbuf(pri, offset, "dat", dump);
19837c478bdstevel@tonic-gate		else
19847c478bdstevel@tonic-gate			show_strbuf32(pri, offset, "dat", dump);
19857c478bdstevel@tonic-gate	}
19867c478bdstevel@tonic-gate#else	/* _LP64 */
198727aa481Toomas Soome	if (