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