xref: /titanic_52/usr/src/cmd/prstat/prtable.h (revision 0eb822a1c0c2bea495647510b75f77f0e57633eb)
1 /*
2  * CDDL HEADER START
3  *
4  * The contents of this file are subject to the terms of the
5  * Common Development and Distribution License, Version 1.0 only
6  * (the "License").  You may not use this file except in compliance
7  * with the License.
8  *
9  * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
10  * or http://www.opensolaris.org/os/licensing.
11  * See the License for the specific language governing permissions
12  * and limitations under the License.
13  *
14  * When distributing Covered Code, include this CDDL HEADER in each
15  * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
16  * If applicable, add the following below this CDDL HEADER, with the
17  * fields enclosed by brackets "[]" replaced with your own identifying
18  * information: Portions Copyright [yyyy] [name of copyright owner]
19  *
20  * CDDL HEADER END
21  */
22 /*
23  * Copyright 2003 Sun Microsystems, Inc.  All rights reserved.
24  * Use is subject to license terms.
25  */
26 
27 #ifndef	_PRTABLE_H
28 #define	_PRTABLE_H
29 
30 #pragma ident	"%Z%%M%	%I%	%E% SMI"
31 
32 #ifdef	__cplusplus
33 extern "C" {
34 #endif
35 
36 #include <limits.h>
37 #include <zone.h>
38 #include "prstat.h"
39 
40 #define	PLWP_TBL_SZ	4096	/* hash table of plwp_t structures */
41 #define	LWP_ACTIVE	1
42 
43 typedef struct {
44 	size_t		t_size;
45 	size_t		t_nent;
46 	long		*t_list;
47 } table_t;
48 
49 typedef struct {
50 	uid_t		u_id;
51 	char		u_name[LOGNAME_MAX+1];
52 } name_t;
53 
54 typedef struct {
55 	size_t		n_size;
56 	size_t		n_nent;
57 	name_t		*n_list;
58 } nametbl_t;
59 
60 typedef struct {
61 	zoneid_t	z_id;
62 	char		z_name[ZONENAME_MAX];
63 } zonename_t;
64 
65 typedef struct {
66 	size_t		z_size;
67 	size_t		z_nent;
68 	zonename_t	*z_list;
69 } zonetbl_t;
70 
71 typedef struct plwp {		/* linked list of pointers to lwps */
72 	pid_t		l_pid;
73 	id_t		l_lwpid;
74 	int		l_active;
75 	lwp_info_t	*l_lwp;
76 	struct plwp	*l_next;
77 } plwp_t;
78 
79 extern void pwd_getname(int, char *, int);
80 extern void add_uid(nametbl_t *, char *);
81 extern int has_uid(nametbl_t *, uid_t);
82 extern void add_element(table_t *, long);
83 extern int has_element(table_t *, long);
84 extern void add_zone(zonetbl_t *, char *);
85 extern int has_zone(zonetbl_t *, zoneid_t);
86 extern void convert_zone(zonetbl_t *);
87 extern int foreach_element(table_t *, void *, void (*)(long, void *));
88 extern void lwpid_init();
89 extern void lwpid_add(lwp_info_t *, pid_t, id_t);
90 extern lwp_info_t *lwpid_get(pid_t, id_t);
91 extern int lwpid_pidcheck(pid_t);
92 extern void lwpid_del(pid_t, id_t);
93 extern void lwpid_set_active(pid_t, id_t);
94 extern int lwpid_is_active(pid_t, id_t);
95 
96 #ifdef	__cplusplus
97 }
98 #endif
99 
100 #endif	/* _PRTABLE_H */
101