summaryrefslogtreecommitdiffstats
path: root/bin/ps
diff options
context:
space:
mode:
authortrasz <trasz@FreeBSD.org>2011-06-14 16:50:16 +0000
committertrasz <trasz@FreeBSD.org>2011-06-14 16:50:16 +0000
commit0b41fa9638f2db7aece9c1ee748bf6b0e621df18 (patch)
treefb18221bf363482b28baee819b51740b100f4755 /bin/ps
parent9d45c190c83f9be0326790e82d82a5eb1ce395c7 (diff)
downloadFreeBSD-src-0b41fa9638f2db7aece9c1ee748bf6b0e621df18.zip
FreeBSD-src-0b41fa9638f2db7aece9c1ee748bf6b0e621df18.tar.gz
Add "gid" and "group" keywords to display the effective group ID
and effective group name. Also, add "egid", "egroup" and "euid" aliases. PR: bin/146331 Submitted by: Jeremie Le Hen <jeremie at le-hen dot org>
Diffstat (limited to 'bin/ps')
-rw-r--r--bin/ps/extern.h2
-rw-r--r--bin/ps/keyword.c7
-rw-r--r--bin/ps/print.c16
-rw-r--r--bin/ps/ps.111
4 files changed, 34 insertions, 2 deletions
diff --git a/bin/ps/extern.h b/bin/ps/extern.h
index 4321285..7b5522d 100644
--- a/bin/ps/extern.h
+++ b/bin/ps/extern.h
@@ -70,6 +70,7 @@ void pmem(KINFO *, VARENT *);
void pri(KINFO *, VARENT *);
void printheader(void);
void priorityr(KINFO *, VARENT *);
+void egroupname(KINFO *, VARENT *);
void rgroupname(KINFO *, VARENT *);
void runame(KINFO *, VARENT *);
void rvar(KINFO *, VARENT *);
@@ -78,6 +79,7 @@ int s_cputime(KINFO *);
int s_label(KINFO *);
int s_loginclass(KINFO *);
int s_logname(KINFO *);
+int s_egroupname(KINFO *);
int s_rgroupname(KINFO *);
int s_runame(KINFO *);
int s_systime(KINFO *);
diff --git a/bin/ps/keyword.c b/bin/ps/keyword.c
index 136d084..c446756 100644
--- a/bin/ps/keyword.c
+++ b/bin/ps/keyword.c
@@ -88,12 +88,19 @@ static VAR var[] = {
{"cpu", "CPU", NULL, 0, kvar, NULL, 3, KOFF(ki_estcpu), UINT, "d",
0},
{"cputime", "", "time", 0, NULL, NULL, 0, 0, CHAR, NULL, 0},
+ {"egid", "", "gid", 0, NULL, NULL, 0, 0, CHAR, NULL, 0},
+ {"egroup", "", "group", 0, NULL, NULL, 0, 0, CHAR, NULL, 0},
{"emul", "EMUL", NULL, LJUST, emulname, NULL, EMULLEN, 0, CHAR,
NULL, 0},
{"etime", "ELAPSED", NULL, USER, elapsed, NULL, 12, 0, CHAR, NULL, 0},
{"etimes", "ELAPSED", NULL, USER, elapseds, NULL, 12, 0, CHAR, NULL, 0},
+ {"euid", "", "uid", 0, NULL, NULL, 0, 0, CHAR, NULL, 0},
{"f", "F", NULL, 0, kvar, NULL, 8, KOFF(ki_flag), INT, "x", 0},
{"flags", "", "f", 0, NULL, NULL, 0, 0, CHAR, NULL, 0},
+ {"gid", "GID", NULL, 0, kvar, NULL, UIDLEN, KOFF(ki_groups),
+ UINT, UIDFMT, 0},
+ {"group", "GROUP", NULL, LJUST, egroupname, s_egroupname,
+ USERLEN, 0, CHAR, NULL, 0},
{"ignored", "", "sigignore", 0, NULL, NULL, 0, 0, CHAR, NULL, 0},
{"inblk", "INBLK", NULL, USER, rvar, NULL, 4, ROFF(ru_inblock), LONG,
"ld", 0},
diff --git a/bin/ps/print.c b/bin/ps/print.c
index 432cffa..02c6112 100644
--- a/bin/ps/print.c
+++ b/bin/ps/print.c
@@ -341,6 +341,22 @@ s_uname(KINFO *k)
}
void
+egroupname(KINFO *k, VARENT *ve)
+{
+ VAR *v;
+
+ v = ve->var;
+ (void)printf("%-*s", v->width,
+ group_from_gid(k->ki_p->ki_groups[0], 0));
+}
+
+int
+s_egroupname(KINFO *k)
+{
+ return (strlen(group_from_gid(k->ki_p->ki_groups[0], 0)));
+}
+
+void
rgroupname(KINFO *k, VARENT *ve)
{
VAR *v;
diff --git a/bin/ps/ps.1 b/bin/ps/ps.1
index 2465df3..10dd6af 100644
--- a/bin/ps/ps.1
+++ b/bin/ps/ps.1
@@ -29,7 +29,7 @@
.\" @(#)ps.1 8.3 (Berkeley) 4/18/94
.\" $FreeBSD$
.\"
-.Dd April 18, 2011
+.Dd June 14, 2011
.Dt PS 1
.Os
.Sh NAME
@@ -502,6 +502,12 @@ elapsed running time, in decimal integer seconds
.It Cm flags
the process flags, in hexadecimal (alias
.Cm f )
+.It Cm gid
+effective group ID (alias
+.Cm egid )
+.It Cm group
+group name (from egid) (alias
+.Cm egroup )
.It Cm inblk
total blocks read (alias
.Cm inblock )
@@ -629,7 +635,8 @@ process pointer
.It Cm ucomm
name to be used for accounting
.It Cm uid
-effective user ID
+effective user ID (alias
+.Cm euid )
.It Cm upr
scheduling priority on return from system call (alias
.Cm usrpri )
OpenPOWER on IntegriCloud