1*0Sstevel@tonic-gate /*
2*0Sstevel@tonic-gate * CDDL HEADER START
3*0Sstevel@tonic-gate *
4*0Sstevel@tonic-gate * The contents of this file are subject to the terms of the
5*0Sstevel@tonic-gate * Common Development and Distribution License, Version 1.0 only
6*0Sstevel@tonic-gate * (the "License"). You may not use this file except in compliance
7*0Sstevel@tonic-gate * with the License.
8*0Sstevel@tonic-gate *
9*0Sstevel@tonic-gate * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
10*0Sstevel@tonic-gate * or http://www.opensolaris.org/os/licensing.
11*0Sstevel@tonic-gate * See the License for the specific language governing permissions
12*0Sstevel@tonic-gate * and limitations under the License.
13*0Sstevel@tonic-gate *
14*0Sstevel@tonic-gate * When distributing Covered Code, include this CDDL HEADER in each
15*0Sstevel@tonic-gate * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
16*0Sstevel@tonic-gate * If applicable, add the following below this CDDL HEADER, with the
17*0Sstevel@tonic-gate * fields enclosed by brackets "[]" replaced with your own identifying
18*0Sstevel@tonic-gate * information: Portions Copyright [yyyy] [name of copyright owner]
19*0Sstevel@tonic-gate *
20*0Sstevel@tonic-gate * CDDL HEADER END
21*0Sstevel@tonic-gate */
22*0Sstevel@tonic-gate /*
23*0Sstevel@tonic-gate * Copyright 2004 Sun Microsystems, Inc. All rights reserved.
24*0Sstevel@tonic-gate * Use is subject to license terms.
25*0Sstevel@tonic-gate */
26*0Sstevel@tonic-gate
27*0Sstevel@tonic-gate /* Copyright (c) 1984, 1986, 1987, 1988, 1989 AT&T */
28*0Sstevel@tonic-gate /* All Rights Reserved */
29*0Sstevel@tonic-gate
30*0Sstevel@tonic-gate
31*0Sstevel@tonic-gate #pragma ident "%Z%%M% %I% %E% SMI"
32*0Sstevel@tonic-gate
33*0Sstevel@tonic-gate #include <stdio.h>
34*0Sstevel@tonic-gate #include <stdlib.h>
35*0Sstevel@tonic-gate #include <unistd.h>
36*0Sstevel@tonic-gate #include <string.h>
37*0Sstevel@tonic-gate #include <sys/types.h>
38*0Sstevel@tonic-gate #include <sys/wait.h>
39*0Sstevel@tonic-gate #include <libproc.h>
40*0Sstevel@tonic-gate #include "ramdata.h"
41*0Sstevel@tonic-gate #include "proto.h"
42*0Sstevel@tonic-gate
43*0Sstevel@tonic-gate /*
44*0Sstevel@tonic-gate * Function prototypes for static routines in this module.
45*0Sstevel@tonic-gate */
46*0Sstevel@tonic-gate const char *idop_enum(private_t *, idop_t);
47*0Sstevel@tonic-gate
48*0Sstevel@tonic-gate void
show_procset(private_t * pri,long offset)49*0Sstevel@tonic-gate show_procset(private_t *pri, long offset)
50*0Sstevel@tonic-gate {
51*0Sstevel@tonic-gate procset_t procset;
52*0Sstevel@tonic-gate procset_t *psp = &procset;
53*0Sstevel@tonic-gate
54*0Sstevel@tonic-gate if (Pread(Proc, psp, sizeof (*psp), offset) == sizeof (*psp)) {
55*0Sstevel@tonic-gate (void) printf("%s\top=%s",
56*0Sstevel@tonic-gate pri->pname, idop_enum(pri, psp->p_op));
57*0Sstevel@tonic-gate (void) printf(" ltyp=%s lid=%ld",
58*0Sstevel@tonic-gate idtype_enum(pri, psp->p_lidtype), (long)psp->p_lid);
59*0Sstevel@tonic-gate (void) printf(" rtyp=%s rid=%ld\n",
60*0Sstevel@tonic-gate idtype_enum(pri, psp->p_ridtype), (long)psp->p_rid);
61*0Sstevel@tonic-gate }
62*0Sstevel@tonic-gate }
63*0Sstevel@tonic-gate
64*0Sstevel@tonic-gate const char *
idop_enum(private_t * pri,idop_t arg)65*0Sstevel@tonic-gate idop_enum(private_t *pri, idop_t arg)
66*0Sstevel@tonic-gate {
67*0Sstevel@tonic-gate const char *str;
68*0Sstevel@tonic-gate
69*0Sstevel@tonic-gate switch (arg) {
70*0Sstevel@tonic-gate case POP_DIFF: str = "POP_DIFF"; break;
71*0Sstevel@tonic-gate case POP_AND: str = "POP_AND"; break;
72*0Sstevel@tonic-gate case POP_OR: str = "POP_OR"; break;
73*0Sstevel@tonic-gate case POP_XOR: str = "POP_XOR"; break;
74*0Sstevel@tonic-gate default:
75*0Sstevel@tonic-gate (void) sprintf(pri->code_buf, "%d", arg);
76*0Sstevel@tonic-gate str = (const char *)pri->code_buf;
77*0Sstevel@tonic-gate break;
78*0Sstevel@tonic-gate }
79*0Sstevel@tonic-gate
80*0Sstevel@tonic-gate return (str);
81*0Sstevel@tonic-gate }
82*0Sstevel@tonic-gate
83*0Sstevel@tonic-gate const char *
idtype_enum(private_t * pri,long arg)84*0Sstevel@tonic-gate idtype_enum(private_t *pri, long arg)
85*0Sstevel@tonic-gate {
86*0Sstevel@tonic-gate const char *str;
87*0Sstevel@tonic-gate
88*0Sstevel@tonic-gate switch (arg) {
89*0Sstevel@tonic-gate case P_PID: str = "P_PID"; break;
90*0Sstevel@tonic-gate case P_PPID: str = "P_PPID"; break;
91*0Sstevel@tonic-gate case P_PGID: str = "P_PGID"; break;
92*0Sstevel@tonic-gate case P_SID: str = "P_SID"; break;
93*0Sstevel@tonic-gate case P_CID: str = "P_CID"; break;
94*0Sstevel@tonic-gate case P_UID: str = "P_UID"; break;
95*0Sstevel@tonic-gate case P_GID: str = "P_GID"; break;
96*0Sstevel@tonic-gate case P_ALL: str = "P_ALL"; break;
97*0Sstevel@tonic-gate case P_LWPID: str = "P_LWPID"; break;
98*0Sstevel@tonic-gate case P_TASKID: str = "P_TASKID"; break;
99*0Sstevel@tonic-gate case P_PROJID: str = "P_PROJID"; break;
100*0Sstevel@tonic-gate case P_ZONEID: str = "P_ZONEID"; break;
101*0Sstevel@tonic-gate case P_CTID: str = "P_CTID"; break;
102*0Sstevel@tonic-gate default:
103*0Sstevel@tonic-gate (void) sprintf(pri->code_buf, "%ld", arg);
104*0Sstevel@tonic-gate str = (const char *)pri->code_buf;
105*0Sstevel@tonic-gate break;
106*0Sstevel@tonic-gate }
107*0Sstevel@tonic-gate
108*0Sstevel@tonic-gate return (str);
109*0Sstevel@tonic-gate }
110*0Sstevel@tonic-gate
111*0Sstevel@tonic-gate const char *
woptions(private_t * pri,int arg)112*0Sstevel@tonic-gate woptions(private_t *pri, int arg)
113*0Sstevel@tonic-gate {
114*0Sstevel@tonic-gate char *str = pri->code_buf;
115*0Sstevel@tonic-gate
116*0Sstevel@tonic-gate if (arg == 0)
117*0Sstevel@tonic-gate return ("0");
118*0Sstevel@tonic-gate if (arg &
119*0Sstevel@tonic-gate ~(WEXITED|WTRAPPED|WSTOPPED|WCONTINUED|WNOHANG|WNOWAIT))
120*0Sstevel@tonic-gate return (NULL);
121*0Sstevel@tonic-gate
122*0Sstevel@tonic-gate *str = '\0';
123*0Sstevel@tonic-gate if (arg & WEXITED)
124*0Sstevel@tonic-gate (void) strcat(str, "|WEXITED");
125*0Sstevel@tonic-gate if (arg & WTRAPPED)
126*0Sstevel@tonic-gate (void) strcat(str, "|WTRAPPED");
127*0Sstevel@tonic-gate if (arg & WSTOPPED)
128*0Sstevel@tonic-gate (void) strcat(str, "|WSTOPPED");
129*0Sstevel@tonic-gate if (arg & WCONTINUED)
130*0Sstevel@tonic-gate (void) strcat(str, "|WCONTINUED");
131*0Sstevel@tonic-gate if (arg & WNOHANG)
132*0Sstevel@tonic-gate (void) strcat(str, "|WNOHANG");
133*0Sstevel@tonic-gate if (arg & WNOWAIT)
134*0Sstevel@tonic-gate (void) strcat(str, "|WNOWAIT");
135*0Sstevel@tonic-gate
136*0Sstevel@tonic-gate return ((const char *)(str+1));
137*0Sstevel@tonic-gate }
138