From owner-svn-src-all@FreeBSD.ORG Fri May 2 20:19:16 2014 Return-Path: Delivered-To: svn-src-all@FreeBSD.org Received: from mx1.freebsd.org (mx1.freebsd.org [8.8.178.115]) (using TLSv1 with cipher ADH-AES256-SHA (256/256 bits)) (No client certificate requested) by hub.freebsd.org (Postfix) with ESMTPS id 27E65283; Fri, 2 May 2014 20:19:15 +0000 (UTC) Received: from mho-01-ewr.mailhop.org (mho-03-ewr.mailhop.org [204.13.248.66]) (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id 9DE0016CB; Fri, 2 May 2014 20:19:14 +0000 (UTC) Received: from c-24-8-230-52.hsd1.co.comcast.net ([24.8.230.52] helo=damnhippie.dyndns.org) by mho-01-ewr.mailhop.org with esmtpsa (TLSv1:AES256-SHA:256) (Exim 4.72) (envelope-from ) id 1WgJvN-0006Mt-2q; Fri, 02 May 2014 20:19:13 +0000 Received: from [172.22.42.240] (revolution.hippie.lan [172.22.42.240]) by damnhippie.dyndns.org (8.14.3/8.14.3) with ESMTP id s42KJArW020619; Fri, 2 May 2014 14:19:10 -0600 (MDT) (envelope-from ian@FreeBSD.org) X-Mail-Handler: Dyn Standard SMTP by Dyn X-Originating-IP: 24.8.230.52 X-Report-Abuse-To: abuse@dyndns.com (see http://www.dyndns.com/services/sendlabs/outbound_abuse.html for abuse reporting information) X-MHO-User: U2FsdGVkX1/cMhyH2CgoxFDJ/cZWzvPj Subject: Re: svn commit: r265229 - head/bin/ps From: Ian Lepore To: Bryan Drewery In-Reply-To: <201405021505.s42F5lQO099446@svn.freebsd.org> References: <201405021505.s42F5lQO099446@svn.freebsd.org> Content-Type: text/plain; charset="us-ascii" Date: Fri, 02 May 2014 14:19:10 -0600 Message-ID: <1399061950.22079.195.camel@revolution.hippie.lan> Mime-Version: 1.0 X-Mailer: Evolution 2.32.1 FreeBSD GNOME Team Port Content-Transfer-Encoding: 7bit Cc: svn-src-head@FreeBSD.org, svn-src-all@FreeBSD.org, src-committers@FreeBSD.org X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.17 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 02 May 2014 20:19:16 -0000 On Fri, 2014-05-02 at 15:05 +0000, Bryan Drewery wrote: > Author: bdrewery > Date: Fri May 2 15:05:47 2014 > New Revision: 265229 > URL: http://svnweb.freebsd.org/changeset/base/265229 > > Log: > Add -J to filter by matching jail IDs and names. > > -J 0 can be used to show only host processes. > > Patch partially based on work by bz@ > > PR: bin/78763 > MFC after: 2 weeks > Relnotes: yes > > Modified: > head/bin/ps/Makefile > head/bin/ps/ps.1 > head/bin/ps/ps.c > > Modified: head/bin/ps/Makefile > ============================================================================== > --- head/bin/ps/Makefile Fri May 2 14:47:53 2014 (r265228) > +++ head/bin/ps/Makefile Fri May 2 15:05:47 2014 (r265229) > @@ -11,7 +11,7 @@ SRCS= fmt.c keyword.c nlist.c print.c ps > # on large systems. > # > CFLAGS+=-DLAZY_PS > -DPADD= ${LIBM} ${LIBKVM} > -LDADD= -lm -lkvm > +DPADD= ${LIBM} ${LIBKVM} ${LIBJAIL} > +LDADD= -lm -lkvm -ljail > > .include > > Modified: head/bin/ps/ps.1 > ============================================================================== > --- head/bin/ps/ps.1 Fri May 2 14:47:53 2014 (r265228) > +++ head/bin/ps/ps.1 Fri May 2 15:05:47 2014 (r265229) > @@ -29,7 +29,7 @@ > .\" @(#)ps.1 8.3 (Berkeley) 4/18/94 > .\" $FreeBSD$ > .\" > -.Dd December 27, 2013 > +.Dd May 2, 2014 > .Dt PS 1 > .Os > .Sh NAME > @@ -40,6 +40,7 @@ > .Op Fl aCcdefHhjlmrSTuvwXxZ > .Op Fl O Ar fmt | Fl o Ar fmt > .Op Fl G Ar gid Ns Op , Ns Ar gid Ns Ar ... > +.Op Fl J Ar jid Ns Op , Ns Ar jid Ns Ar ... > .Op Fl M Ar core > .Op Fl N Ar system > .Op Fl p Ar pid Ns Op , Ns Ar pid Ns Ar ... > @@ -62,7 +63,7 @@ will also display processes that do not > .Pp > A different set of processes can be selected for display by using any > combination of the > -.Fl a , G , p , T , t , > +.Fl a , G , J , p , T , t , > and > .Fl U > options. > @@ -152,6 +153,20 @@ Print information associated with the fo > .Cm user , pid , ppid , pgid , sid , jobc , state , tt , time , > and > .Cm command . > +.It Fl J > +Display information about processes which match the specified jail IDs. > +This may be either the > +.Cm jid > +or > +.Cm name > +of the jail. > +Use > +.Fl J > +.Sy 0 > +to display only host processes. > +This flag implies > +.Fl x > +by default. > .It Fl L > List the set of keywords available for the > .Fl O > > Modified: head/bin/ps/ps.c > ============================================================================== > --- head/bin/ps/ps.c Fri May 2 14:47:53 2014 (r265228) > +++ head/bin/ps/ps.c Fri May 2 15:05:47 2014 (r265229) > @@ -50,6 +50,7 @@ static char sccsid[] = "@(#)ps.c 8.4 (Be > __FBSDID("$FreeBSD$"); > > #include > +#include > #include > #include > #include > @@ -62,6 +63,7 @@ __FBSDID("$FreeBSD$"); > #include > #include > #include > +#include > #include > #include > #include > @@ -124,6 +126,7 @@ struct listinfo { > const char *lname; > union { > gid_t *gids; > + int *jids; > pid_t *pids; > dev_t *ttys; > uid_t *uids; > @@ -132,6 +135,7 @@ struct listinfo { > }; > > static int addelem_gid(struct listinfo *, const char *); > +static int addelem_jid(struct listinfo *, const char *); > static int addelem_pid(struct listinfo *, const char *); > static int addelem_tty(struct listinfo *, const char *); > static int addelem_uid(struct listinfo *, const char *); > @@ -163,12 +167,12 @@ static char vfmt[] = "pid,state,time,sl, > "%cpu,%mem,command"; > static char Zfmt[] = "label"; > > -#define PS_ARGS "AaCcde" OPT_LAZY_f "G:gHhjLlM:mN:O:o:p:rSTt:U:uvwXxZ" > +#define PS_ARGS "AaCcde" OPT_LAZY_f "G:gHhjJ:LlM:mN:O:o:p:rSTt:U:uvwXxZ" > > int > main(int argc, char *argv[]) > { > - struct listinfo gidlist, pgrplist, pidlist; > + struct listinfo gidlist, jidlist, pgrplist, pidlist; > struct listinfo ruidlist, sesslist, ttylist, uidlist; > struct kinfo_proc *kp; > KINFO *kinfo = NULL, *next_KINFO; > @@ -208,6 +212,7 @@ main(int argc, char *argv[]) > prtheader = showthreads = wflag = xkeep_implied = 0; > xkeep = -1; /* Neither -x nor -X. */ > init_list(&gidlist, addelem_gid, sizeof(gid_t), "group"); > + init_list(&jidlist, addelem_jid, sizeof(int), "jail id"); > init_list(&pgrplist, addelem_pid, sizeof(pid_t), "process group"); > init_list(&pidlist, addelem_pid, sizeof(pid_t), "process id"); > init_list(&ruidlist, addelem_uid, sizeof(uid_t), "ruser"); > @@ -275,6 +280,11 @@ main(int argc, char *argv[]) > case 'h': > prtheader = ws.ws_row > 5 ? ws.ws_row : 22; > break; > + case 'J': > + add_list(&jidlist, optarg); > + xkeep_implied = 1; > + nselectors++; > + break; > case 'j': > parsefmt(jfmt, 0); > _fmt = 1; > @@ -538,6 +548,11 @@ main(int argc, char *argv[]) > if (kp->ki_rgid == gidlist.l.gids[elem]) > goto keepit; > } > + if (jidlist.count > 0) { > + for (elem = 0; elem < jidlist.count; elem++) > + if (kp->ki_jid == jidlist.l.jids[elem]) > + goto keepit; > + } > if (pgrplist.count > 0) { > for (elem = 0; elem < pgrplist.count; elem++) > if (kp->ki_pgid == > @@ -666,6 +681,7 @@ main(int argc, char *argv[]) > } > } > free_list(&gidlist); > + free_list(&jidlist); > free_list(&pidlist); > free_list(&pgrplist); > free_list(&ruidlist); > @@ -727,6 +743,30 @@ addelem_gid(struct listinfo *inf, const > } > > static int > +addelem_jid(struct listinfo *inf, const char *elem) > +{ > + int tempid; > + > + if (*elem == '\0') { > + warnx("Invalid (zero-length) jail id"); > + optfatal = 1; > + return (0); /* Do not add this value. */ > + } > + > + tempid = jail_getid(elem); > + if (tempid < 0) { > + warnx("Invalid %s: %s", inf->lname, elem); > + optfatal = 1; > + return (0); > + } > + > + if (inf->count >= inf->maxcount) > + expand_list(inf); > + inf->l.jids[(inf->count)++] = tempid; > + return (1); > +} > + > +static int > addelem_pid(struct listinfo *inf, const char *elem) > { > char *endp; > @@ -1373,7 +1413,7 @@ usage(void) > > (void)fprintf(stderr, "%s\n%s\n%s\n%s\n", > "usage: ps " SINGLE_OPTS " [-O fmt | -o fmt] [-G gid[,gid...]]", > - " [-M core] [-N system]", > + " [-J jid[,jid...]] [-M core] [-N system]", > " [-p pid[,pid...]] [-t tty[,tty...]] [-U user[,user...]]", > " ps [-L]"); > exit(1); > I'm getting an error building rescue after this change: --- rescue.all__D --- ps.lo: In function `_$$hide$$ ps.lo $a': _$$hide$$ ps.lo ps.c:(.text+0x26ec): undefined reference to `jail_getid' *** [rescue] Error code 1 bmake[4]: stopped in /local/build/staging/freebsd/wand/obj/arm.armv6/local/build/staging/freebsd/wand/src/rescue/rescue 1 error This is on arm, building with gcc, but I'm not sure whether that's germane or not. -- Ian