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 /*
23 * Copyright 2009 Sun Microsystems, Inc. All rights reserved.
24 * Use is subject to license terms.
25 */
26
27 /*
28 * Copyright (c) 2012, Joyent, Inc. All rights reserved.
29 */
30
31 /* Copyright (c) 1984, 1986, 1987, 1988, 1989 AT&T */
32 /* All Rights Reserved */
33
34 /*
35 * ps -- print things about processes.
36 */
37 #include <stdio.h>
38 #include <ctype.h>
39 #include <string.h>
40 #include <errno.h>
41 #include <fcntl.h>
42 #include <pwd.h>
59 #include <libw.h>
60 #include <stdarg.h>
61 #include <sys/proc.h>
62 #include <sys/pset.h>
63 #include <project.h>
64 #include <zone.h>
65
66 #define min(a, b) ((a) > (b) ? (b) : (a))
67 #define max(a, b) ((a) < (b) ? (b) : (a))
68
69 #define NTTYS 20 /* initial size of table for -t option */
70 #define SIZ 30 /* initial size of tables for -p, -s, -g, -h and -z */
71
72 /*
73 * Size of buffer holding args for t, p, s, g, u, U, G, z options.
74 * Set to ZONENAME_MAX, the minimum value needed to allow any
75 * zone to be specified.
76 */
77 #define ARGSIZ ZONENAME_MAX
78
79 #define MAXUGNAME 10 /* max chars in a user/group name or printed u/g id */
80
81 /* Structure for storing user or group info */
82 struct ugdata {
83 id_t id; /* numeric user-id or group-id */
84 char name[MAXUGNAME+1]; /* user/group name, null terminated */
85 };
86
87 struct ughead {
88 size_t size; /* number of ugdata structs allocated */
89 size_t nent; /* number of active entries */
90 struct ugdata *ent; /* pointer to array of actual entries */
91 };
92
93 enum fname { /* enumeration of field names */
94 F_USER, /* effective user of the process */
95 F_RUSER, /* real user of the process */
96 F_GROUP, /* effective group of the process */
97 F_RGROUP, /* real group of the process */
98 F_UID, /* numeric effective uid of the process */
99 F_RUID, /* numeric real uid of the process */
|
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 /*
23 * Copyright (c) 2013 Gary Mills
24 *
25 * Copyright 2009 Sun Microsystems, Inc. All rights reserved.
26 * Use is subject to license terms.
27 */
28
29 /*
30 * Copyright (c) 2012, Joyent, Inc. All rights reserved.
31 */
32
33 /* Copyright (c) 1984, 1986, 1987, 1988, 1989 AT&T */
34 /* All Rights Reserved */
35
36 /*
37 * ps -- print things about processes.
38 */
39 #include <stdio.h>
40 #include <ctype.h>
41 #include <string.h>
42 #include <errno.h>
43 #include <fcntl.h>
44 #include <pwd.h>
61 #include <libw.h>
62 #include <stdarg.h>
63 #include <sys/proc.h>
64 #include <sys/pset.h>
65 #include <project.h>
66 #include <zone.h>
67
68 #define min(a, b) ((a) > (b) ? (b) : (a))
69 #define max(a, b) ((a) < (b) ? (b) : (a))
70
71 #define NTTYS 20 /* initial size of table for -t option */
72 #define SIZ 30 /* initial size of tables for -p, -s, -g, -h and -z */
73
74 /*
75 * Size of buffer holding args for t, p, s, g, u, U, G, z options.
76 * Set to ZONENAME_MAX, the minimum value needed to allow any
77 * zone to be specified.
78 */
79 #define ARGSIZ ZONENAME_MAX
80
81 #ifdef LOGNAME_MAX_ILLUMOS
82 #define MAXUGNAME (LOGNAME_MAX_ILLUMOS+2) /* max chars in a user/group */
83 /* name or printed u/g id */
84 #else /* LOGNAME_MAX_ILLUMOS */
85 #define MAXUGNAME 10 /* max chars in a user/group name or printed u/g id */
86 #endif /* LOGNAME_MAX_ILLUMOS */
87
88 /* Structure for storing user or group info */
89 struct ugdata {
90 id_t id; /* numeric user-id or group-id */
91 char name[MAXUGNAME+1]; /* user/group name, null terminated */
92 };
93
94 struct ughead {
95 size_t size; /* number of ugdata structs allocated */
96 size_t nent; /* number of active entries */
97 struct ugdata *ent; /* pointer to array of actual entries */
98 };
99
100 enum fname { /* enumeration of field names */
101 F_USER, /* effective user of the process */
102 F_RUSER, /* real user of the process */
103 F_GROUP, /* effective group of the process */
104 F_RGROUP, /* real group of the process */
105 F_UID, /* numeric effective uid of the process */
106 F_RUID, /* numeric real uid of the process */
|