summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--bin/ps/extern.h1
-rw-r--r--bin/ps/keyword.c2
-rw-r--r--bin/ps/print.c20
-rw-r--r--bin/ps/ps.16
-rw-r--r--sys/compat/freebsd32/freebsd32.h3
-rw-r--r--sys/kern/kern_proc.c4
-rw-r--r--sys/sys/user.h4
7 files changed, 37 insertions, 3 deletions
diff --git a/bin/ps/extern.h b/bin/ps/extern.h
index b177b47..faeeb19 100644
--- a/bin/ps/extern.h
+++ b/bin/ps/extern.h
@@ -55,6 +55,7 @@ const char *fmt_argv(char **, char *, size_t);
double getpcpu(const KINFO *);
void kvar(KINFO *, VARENT *);
void label(KINFO *, VARENT *);
+void loginclass(KINFO *, VARENT *);
void logname(KINFO *, VARENT *);
void longtname(KINFO *, VARENT *);
void lstarted(KINFO *, VARENT *);
diff --git a/bin/ps/keyword.c b/bin/ps/keyword.c
index 561b087..3bcc23b 100644
--- a/bin/ps/keyword.c
+++ b/bin/ps/keyword.c
@@ -79,6 +79,8 @@ static VAR var[] = {
CHAR, NULL, 0},
{"blocked", "", "sigmask", 0, NULL, NULL, 0, 0, CHAR, NULL, 0},
{"caught", "", "sigcatch", 0, NULL, NULL, 0, 0, CHAR, NULL, 0},
+ {"class", "CLASS", NULL, LJUST, loginclass, NULL, MAXLOGNAME-1, 0,
+ CHAR, NULL, 0},
{"comm", "COMMAND", NULL, LJUST|DSIZ, ucomm, s_comm,
COMMLEN + OCOMMLEN + 1, 0, CHAR, NULL, 0},
{"command", "COMMAND", NULL, COMM|LJUST|USER, command, NULL, 16, 0,
diff --git a/bin/ps/print.c b/bin/ps/print.c
index 5aa27c0..46b979b 100644
--- a/bin/ps/print.c
+++ b/bin/ps/print.c
@@ -862,6 +862,26 @@ out:
return;
}
+void
+loginclass(KINFO *k, VARENT *ve)
+{
+ VAR *v;
+ char *s;
+
+ v = ve->var;
+ /*
+ * Don't display login class for system processes;
+ * login classes are used for resource limits,
+ * and limits don't apply to system processes.
+ */
+ if (k->ki_p->ki_flag & P_SYSTEM) {
+ (void)printf("%-*s", v->width, " -");
+ return;
+ }
+ s = k->ki_p->ki_loginclass;
+ (void)printf("%-*s", v->width, *s ? s : "-");
+}
+
int
s_comm(KINFO *k)
{
diff --git a/bin/ps/ps.1 b/bin/ps/ps.1
index 9dd7a47..5ae7c54 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 July 24, 2010
+.Dd March 5, 2011
.Dt PS 1
.Os
.Sh NAME
@@ -280,6 +280,8 @@ be very young) it is possible for the sum of all
fields to exceed 100%.
.It Cm %mem
The percentage of real memory used by this process.
+.It Cm class
+Login class associated with the process.
.It Cm flags
The flags associated with the process as in
the include file
@@ -475,6 +477,8 @@ accounting flag (alias
.Cm acflg )
.It Cm args
command and arguments
+.It Cm class
+login class
.It Cm comm
command
.It Cm command
diff --git a/sys/compat/freebsd32/freebsd32.h b/sys/compat/freebsd32/freebsd32.h
index bfc27c2..e04d202 100644
--- a/sys/compat/freebsd32/freebsd32.h
+++ b/sys/compat/freebsd32/freebsd32.h
@@ -316,7 +316,8 @@ struct kinfo_proc32 {
char ki_lockname[LOCKNAMELEN+1];
char ki_comm[COMMLEN+1];
char ki_emul[KI_EMULNAMELEN+1];
- char ki_sparestrings[68];
+ char ki_loginclass[LOGINCLASSLEN+1];
+ char ki_sparestrings[50];
int ki_spareints[KI_NSPARE_INT];
u_int ki_cr_flags;
int ki_jid;
diff --git a/sys/kern/kern_proc.c b/sys/kern/kern_proc.c
index 1e576ed..e02b5b2 100644
--- a/sys/kern/kern_proc.c
+++ b/sys/kern/kern_proc.c
@@ -44,6 +44,7 @@ __FBSDID("$FreeBSD$");
#include <sys/kernel.h>
#include <sys/limits.h>
#include <sys/lock.h>
+#include <sys/loginclass.h>
#include <sys/malloc.h>
#include <sys/mount.h>
#include <sys/mutex.h>
@@ -745,6 +746,8 @@ fill_kinfo_proc_only(struct proc *p, struct kinfo_proc *kp)
if (cred->cr_prison != curthread->td_ucred->cr_prison)
kp->ki_jid = cred->cr_prison->pr_id;
}
+ strlcpy(kp->ki_loginclass, cred->cr_loginclass->lc_name,
+ sizeof(kp->ki_loginclass));
}
ps = p->p_sigacts;
if (ps) {
@@ -1059,6 +1062,7 @@ freebsd32_kinfo_proc_out(const struct kinfo_proc *ki, struct kinfo_proc32 *ki32)
bcopy(ki->ki_lockname, ki32->ki_lockname, LOCKNAMELEN + 1);
bcopy(ki->ki_comm, ki32->ki_comm, COMMLEN + 1);
bcopy(ki->ki_emul, ki32->ki_emul, KI_EMULNAMELEN + 1);
+ bcopy(ki->ki_loginclass, ki32->ki_loginclass, LOGINCLASSLEN + 1);
CP(*ki, *ki32, ki_cr_flags);
CP(*ki, *ki32, ki_jid);
CP(*ki, *ki32, ki_numthreads);
diff --git a/sys/sys/user.h b/sys/sys/user.h
index 5c34c9d..5c5cbd4 100644
--- a/sys/sys/user.h
+++ b/sys/sys/user.h
@@ -100,6 +100,7 @@
#define KI_EMULNAMELEN 16 /* size of returned ki_emul */
#define KI_NGROUPS 16 /* number of groups in ki_groups */
#define LOGNAMELEN 17 /* size of returned ki_login */
+#define LOGINCLASSLEN 17 /* size of returned ki_loginclass */
/* Flags for the process credential. */
#define KI_CRF_CAPABILITY_MODE 0x00000001
@@ -172,12 +173,13 @@ struct kinfo_proc {
char ki_lockname[LOCKNAMELEN+1]; /* lock name */
char ki_comm[COMMLEN+1]; /* command name */
char ki_emul[KI_EMULNAMELEN+1]; /* emulation name */
+ char ki_loginclass[LOGINCLASSLEN+1]; /* login class */
/*
* When adding new variables, take space for char-strings from the
* front of ki_sparestrings, and ints from the end of ki_spareints.
* That way the spare room from both arrays will remain contiguous.
*/
- char ki_sparestrings[68]; /* spare string space */
+ char ki_sparestrings[50]; /* spare string space */
int ki_spareints[KI_NSPARE_INT]; /* spare room for growth */
u_int ki_cr_flags; /* Credential flags */
int ki_jid; /* Process jail ID */
OpenPOWER on IntegriCloud