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