bin/146331: [PATCH] Grow ps(1) with "gid" and "group" keywords
Jeremie Le Hen
jeremie at le-hen.org
Tue Aug 10 07:40:07 UTC 2010
The following reply was made to PR bin/146331; it has been noted by GNATS.
From: Jeremie Le Hen <jeremie at le-hen.org>
To: Chip Camden <sterling at camdensoftware.com>
Cc: bug-followup at FreeBSD.org, jeremie at le-hen.org
Subject: Re: bin/146331: [PATCH] Grow ps(1) with "gid" and "group" keywords
Date: Tue, 10 Aug 2010 09:19:14 +0200
--jI8keyz6grp/JLjh
Content-Type: text/plain; charset=us-ascii
Content-Disposition: inline
Hi Chip,
Thanks for looking at this patch.
On Mon, Aug 09, 2010 at 04:04:54PM -0700, Chip Camden wrote:
> (Bugathon)
>
> For some reason, the patch did not apply cleanly to keyword.c. I
> couldn't see anything different with it, so I patched that file by hand. It
> all seems to work except for the 'euid' synonym, for some strange reason.
>
> Tested on 8.1-RELEASE, i386.
This patch is against -CURRENT. I will willingly create a patch against
RELENG_8 and RELENG_7 for the MFC if this finally gets commited.
I can confirm that "euid" did't work. I've attached a corrected
patch. The problem was that the list was not alphabetically sorted.
Regards,
--
Jeremie Le Hen
Humans are born free and equal. But some are more equal than others.
Coluche
--jI8keyz6grp/JLjh
Content-Type: text/x-diff; charset=us-ascii
Content-Disposition: attachment; filename="ps.egid.diff"
Index: extern.h
===================================================================
RCS file: /mnt/repos/freebsd-cvsroot/src/bin/ps/extern.h,v
retrieving revision 1.40
diff -u -p -u -p -r1.40 extern.h
--- extern.h 17 Mar 2010 22:57:58 -0000 1.40
+++ extern.h 5 May 2010 13:51:43 -0000
@@ -69,11 +69,13 @@ 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 *);
int s_comm(KINFO *);
int s_label(KINFO *);
+int s_egroupname(KINFO *);
int s_rgroupname(KINFO *);
int s_runame(KINFO *);
int s_uname(KINFO *);
Index: keyword.c
===================================================================
RCS file: /mnt/repos/freebsd-cvsroot/src/bin/ps/keyword.c,v
retrieving revision 1.83
diff -u -p -u -p -r1.83 keyword.c
--- keyword.c 24 Jul 2010 15:37:36 -0000 1.83
+++ keyword.c 10 Aug 2010 07:16:00 -0000
@@ -86,12 +86,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|DSIZ, 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},
Index: print.c
===================================================================
RCS file: /mnt/repos/freebsd-cvsroot/src/bin/ps/print.c,v
retrieving revision 1.101
diff -u -p -u -p -r1.101 print.c
--- print.c 17 Mar 2010 22:57:58 -0000 1.101
+++ print.c 5 May 2010 13:53:24 -0000
@@ -340,6 +340,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;
Index: ps.1
===================================================================
RCS file: /mnt/repos/freebsd-cvsroot/src/bin/ps/ps.1,v
retrieving revision 1.96
diff -u -p -u -p -r1.96 ps.1
--- ps.1 24 Jul 2010 15:24:12 -0000 1.96
+++ ps.1 10 Aug 2010 06:59:42 -0000
@@ -490,6 +490,12 @@ elapsed running time, in decimal integer
.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 )
@@ -613,7 +619,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 )
--jI8keyz6grp/JLjh--
More information about the freebsd-bugs
mailing list