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